update foc and pdf
This commit is contained in:
@@ -163,6 +163,35 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
|
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def foc
|
||||||
|
cash = params[:cash]
|
||||||
|
sale_id = params[:sale_id]
|
||||||
|
sub_total = params[:sub_total]
|
||||||
|
member_info = nil
|
||||||
|
rebate_amount = nil
|
||||||
|
|
||||||
|
if(Sale.exists?(sale_id))
|
||||||
|
saleObj = Sale.find(sale_id)
|
||||||
|
sale_payment = SalePayment.new
|
||||||
|
sale_payment.process_payment(saleObj, @user, cash, "foc")
|
||||||
|
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
customer= Customer.find(saleObj.customer_id)
|
||||||
|
|
||||||
|
#shop detail
|
||||||
|
shop_details = Shop.find(1)
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
# Calculate Food and Beverage Total
|
||||||
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def rounding_adj
|
def rounding_adj
|
||||||
|
|
||||||
saleObj = Sale.find(params[:sale_id])
|
saleObj = Sale.find(params[:sale_id])
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||||
#other payment details for mpu or visa like card
|
#other payment details for mpu or visa like card
|
||||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||||
#t details for mpu or visa like card
|
|
||||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
|
||||||
|
|
||||||
# Calculate price_by_accounts
|
# Calculate price_by_accounts
|
||||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ class Ability
|
|||||||
can :create, :payment
|
can :create, :payment
|
||||||
can :reprint, :payment
|
can :reprint, :payment
|
||||||
can :rounding_adj, :payment
|
can :rounding_adj, :payment
|
||||||
|
can :foc, :payment
|
||||||
|
|
||||||
|
|
||||||
can :move_dining, :movetable
|
can :move_dining, :movetable
|
||||||
can :moving, :movetable
|
can :moving, :movetable
|
||||||
@@ -96,17 +98,13 @@ class Ability
|
|||||||
can :create, :payment
|
can :create, :payment
|
||||||
can :reprint, :payment
|
can :reprint, :payment
|
||||||
can :rounding_adj, :payment
|
can :rounding_adj, :payment
|
||||||
|
can :foc, :payment
|
||||||
|
|
||||||
can :move_dining, :movetable
|
can :move_dining, :movetable
|
||||||
can :moving, :movetable
|
can :moving, :movetable
|
||||||
|
|
||||||
can :move_dining, :moveroom
|
can :move_dining, :moveroom
|
||||||
|
|
||||||
can :first_bill, :payment
|
|
||||||
can :show, :payment
|
|
||||||
can :create, :payment
|
|
||||||
can :reprint, :payment
|
|
||||||
|
|
||||||
can :manage, DiningQueue
|
can :manage, DiningQueue
|
||||||
|
|
||||||
elsif user.role == "account"
|
elsif user.role == "account"
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class SalePayment < ApplicationRecord
|
|||||||
payment_status = giftcard_payment
|
payment_status = giftcard_payment
|
||||||
when "paypar"
|
when "paypar"
|
||||||
payment_status = paypar_payment
|
payment_status = paypar_payment
|
||||||
|
when "foc"
|
||||||
|
payment_status = foc_payment
|
||||||
else
|
else
|
||||||
puts "it was something else"
|
puts "it was something else"
|
||||||
end
|
end
|
||||||
@@ -164,6 +166,17 @@ class SalePayment < ApplicationRecord
|
|||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def foc_payment
|
||||||
|
payment_status = false
|
||||||
|
self.payment_method = "foc"
|
||||||
|
self.payment_amount = self.received_amount
|
||||||
|
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||||
|
self.payment_status = "paid"
|
||||||
|
payment_method = self.save!
|
||||||
|
sale_update_payment_status(self.received_amount)
|
||||||
|
return payment_status
|
||||||
|
end
|
||||||
|
|
||||||
def creditnote_payment(customer_id)
|
def creditnote_payment(customer_id)
|
||||||
payment_status = false
|
payment_status = false
|
||||||
|
|
||||||
@@ -257,11 +270,15 @@ class SalePayment < ApplicationRecord
|
|||||||
all_received_amount = 0.0
|
all_received_amount = 0.0
|
||||||
sObj = Sale.find(self.sale_id)
|
sObj = Sale.find(self.sale_id)
|
||||||
is_credit = 0
|
is_credit = 0
|
||||||
|
is_foc = 0
|
||||||
sObj.sale_payments.each do |spay|
|
sObj.sale_payments.each do |spay|
|
||||||
all_received_amount += spay.payment_amount.to_f
|
all_received_amount += spay.payment_amount.to_f
|
||||||
if spay.payment_method == "creditnote"
|
if spay.payment_method == "creditnote"
|
||||||
is_credit = 1
|
is_credit = 1
|
||||||
end
|
end
|
||||||
|
if spay.payment_method == "foc"
|
||||||
|
is_foc = 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if (self.sale.grand_total <= all_received_amount)
|
if (self.sale.grand_total <= all_received_amount)
|
||||||
if is_credit == 0
|
if is_credit == 0
|
||||||
@@ -269,9 +286,16 @@ class SalePayment < ApplicationRecord
|
|||||||
else
|
else
|
||||||
self.sale.payment_status = "outstanding"
|
self.sale.payment_status = "outstanding"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if is_foc == 0
|
||||||
|
self.sale.payment_status = "paid"
|
||||||
|
else
|
||||||
|
self.sale.payment_status = "foc"
|
||||||
|
end
|
||||||
|
|
||||||
self.sale.sale_status = "completed"
|
self.sale.sale_status = "completed"
|
||||||
|
|
||||||
if MembershipSetting.find_by_rebate(1)
|
if MembershipSetting.find_by_rebate(1) && is_foc == 0
|
||||||
response = rebat(sObj)
|
response = rebat(sObj)
|
||||||
|
|
||||||
if !response.nil?
|
if !response.nil?
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ class ShiftSale < ApplicationRecord
|
|||||||
SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
|
SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
|
||||||
SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
|
SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
|
||||||
SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
|
SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
|
||||||
SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
|
SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
|
||||||
SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
|
SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
|
||||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||||
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
|
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
|
||||||
|
|||||||
@@ -223,6 +223,14 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
|
text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "FOC :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{other.foc_amount.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -418,32 +418,33 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|
||||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
move_down 35
|
move_down 70
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
move_down 38
|
move_down 73
|
||||||
text "Approved By" , :size => self.item_font_size,:align => :center
|
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if sale_data.sale_status == "FOC"
|
if sale_data.payment_status == "foc"
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|
||||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
move_down 35
|
move_down 70
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
bounding_box([0,y_position], :width =>self.item_width, :height => self.item_height) do
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
move_down 38
|
move_down 73
|
||||||
text "Acknowledged By", :size => self.item_font_size,:align => :center
|
text "Acknowledged By" , :size => self.item_font_size,:align => :center
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def footer(printed_status)
|
def footer(printed_status)
|
||||||
@@ -453,7 +454,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
text "#{printed_status}", :size => self.item_font_size,:align => :left
|
text "#{printed_status}",:style => :bold, :size => self.header_font_size,:align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
|
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
|
||||||
|
|||||||
@@ -41,24 +41,24 @@
|
|||||||
<% sub_total = 0
|
<% sub_total = 0
|
||||||
count = 0
|
count = 0
|
||||||
%>
|
%>
|
||||||
<% @sale_data.sale_items.each do |sale_item|
|
<% @sale_data.sale_items.each do |sale_item|
|
||||||
count += 1
|
count += 1
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<% sub_total += sale_item.price%>
|
<% sub_total += sale_item.price%>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= count %></td>
|
<td><%= count %></td>
|
||||||
<td style="width:60%; text-align:left">
|
<td style="width:60%; text-align:left">
|
||||||
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:20%; text-align:right">
|
<td style="width:20%; text-align:right">
|
||||||
<span id="item-qty"><%=sale_item.qty%></span>
|
<span id="item-qty"><%=sale_item.qty%></span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:20%; text-align:right">
|
<td style="width:20%; text-align:right">
|
||||||
<span id="item-total-price"><%=(sale_item.price)%></span>
|
<span id="item-total-price"><%=(sale_item.price)%></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%end %>
|
<%end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<%else%>
|
<%else%>
|
||||||
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
|
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
|
||||||
<%end%>
|
<%end%>
|
||||||
|
|
||||||
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
|
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -258,7 +258,7 @@
|
|||||||
<!-- Waiter Buttons -->
|
<!-- Waiter Buttons -->
|
||||||
|
|
||||||
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
|
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
|
||||||
<button type="button" class="btn btn-primary btn-block"> FOC </button>
|
<button type="button" class="btn btn-primary btn-block" id="foc"> FOC </button>
|
||||||
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
|
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -443,4 +443,44 @@ function update_balance(){
|
|||||||
$('#balance').text(result.toFixed(2));
|
$('#balance').text(result.toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#foc').click(function() {
|
||||||
|
|
||||||
|
$( "#loading_wrapper" ).show();
|
||||||
|
// payment
|
||||||
|
var cash = $('#amount_due').text();
|
||||||
|
var sub_total = $('#sub-total').text();
|
||||||
|
var sale_id = $('#sale_id').text();
|
||||||
|
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
|
||||||
|
$.ajax({type: "POST",
|
||||||
|
url: "<%= origami_payment_foc_path %>",
|
||||||
|
data: params,
|
||||||
|
success:function(result){
|
||||||
|
localStorage.removeItem("cash");
|
||||||
|
if (result.status) {
|
||||||
|
var msg = result.message;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
var msg = '';
|
||||||
|
}
|
||||||
|
$( "#loading_wrapper" ).hide();
|
||||||
|
|
||||||
|
$.confirm({
|
||||||
|
title: 'Infomation!',
|
||||||
|
content: 'Thank you !',
|
||||||
|
buttons: {
|
||||||
|
confirm: {
|
||||||
|
text: 'Ok',
|
||||||
|
btnClass: 'btn-green',
|
||||||
|
action: function(){
|
||||||
|
window.location.href = '/origami';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -153,6 +153,12 @@
|
|||||||
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
|
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
|
||||||
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
|
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<td style="text-align: right;"><strong>FOC </strong></td>
|
||||||
|
<td><%=other.foc_amount.round(2) rescue 0.0 %></td>
|
||||||
|
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
|
||||||
|
</tr>
|
||||||
<%end%>
|
<%end%>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ require 'sidekiq/web'
|
|||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
namespace :settings do
|
|
||||||
resources :item_sets
|
|
||||||
end
|
|
||||||
root 'home#index'
|
root 'home#index'
|
||||||
mount Sidekiq::Web => '/kiq'
|
mount Sidekiq::Web => '/kiq'
|
||||||
|
|
||||||
@@ -133,6 +130,7 @@ Rails.application.routes.draw do
|
|||||||
get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' }
|
get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' }
|
||||||
get 'sale/:sale_id/payment' => 'payments#show'
|
get 'sale/:sale_id/payment' => 'payments#show'
|
||||||
|
|
||||||
|
post 'payment/foc' => 'payments#foc', :defaults => { :format => 'json' }
|
||||||
post 'payment/cash' => 'payments#create'
|
post 'payment/cash' => 'payments#create'
|
||||||
post 'payment/mpu' => "mpu#create"
|
post 'payment/mpu' => "mpu#create"
|
||||||
post 'payment/jcb' => "jcb#create"
|
post 'payment/jcb' => "jcb#create"
|
||||||
@@ -219,6 +217,10 @@ Rails.application.routes.draw do
|
|||||||
resources :menu_categories, only: [:new, :create, :edit,:delete]
|
resources :menu_categories, only: [:new, :create, :edit,:delete]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :item_sets
|
||||||
|
|
||||||
|
resources :menu_item_sets
|
||||||
|
|
||||||
#accounts
|
#accounts
|
||||||
resources :accounts
|
resources :accounts
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user