update rounding adj
This commit is contained in:
@@ -41,10 +41,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = saleObj.grand_total - new_total
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = saleObj.grand_total - new_total
|
||||
|
||||
saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
|
||||
|
||||
rebate_amount = nil
|
||||
|
||||
@@ -144,4 +144,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
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)
|
||||
end
|
||||
|
||||
def rounding_adj
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,6 +52,7 @@ class Ability
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
can :reprint, :payment
|
||||
can :rounding_adj, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
@@ -88,6 +89,7 @@ class Ability
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
can :reprint, :payment
|
||||
can :rounding_adj, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
@@ -80,6 +80,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end until count == 0
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_close_cashier(printer_settings,shift_sale,shop_details)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details)
|
||||
pdf.render_file "tmp/print_close_cashier.pdf"
|
||||
self.print("tmp/print_close_cashier.pdf")
|
||||
end
|
||||
|
||||
#Queue No Print
|
||||
def print_queue_no(printer_settings,queue)
|
||||
#Use CUPS service
|
||||
|
||||
@@ -92,7 +92,6 @@ class Sale < ApplicationRecord
|
||||
link_order_sale(order.id)
|
||||
|
||||
end
|
||||
|
||||
self.save!
|
||||
|
||||
#compute sales summary
|
||||
@@ -379,6 +378,7 @@ class Sale < ApplicationRecord
|
||||
to_date = sale_date.end_of_day.utc - diff
|
||||
|
||||
total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
||||
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
||||
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj")
|
||||
@@ -386,6 +386,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
total_sale.each do |sale|
|
||||
grand_total = sale.grand_total
|
||||
old_grand_total = sale.old_grand_total
|
||||
total_discount = sale.total_discount
|
||||
void_amount = sale.void_amount
|
||||
total = {:sale_date => pay.sale_date,
|
||||
@@ -399,6 +400,7 @@ class Sale < ApplicationRecord
|
||||
:foc_amount => pay.foc_amount,
|
||||
:total_discount => total_discount,
|
||||
:grand_total => grand_total,
|
||||
:old_grand_total => old_grand_total,
|
||||
:void_amount => void_amount,
|
||||
:rounding_adj => sale.rounding_adj}
|
||||
daily_total.push(total)
|
||||
|
||||
109
app/pdf/close_cashier_pdf.rb
Normal file
109
app/pdf/close_cashier_pdf.rb
Normal file
@@ -0,0 +1,109 @@
|
||||
class CloseCashierPdf < Prawn::Document
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(printer_settings, shift_sale,shop_details)
|
||||
self.page_width = 210
|
||||
self.page_height = 7000
|
||||
self.margin = 5
|
||||
self.price_width = 40
|
||||
self.qty_width = 20
|
||||
self.total_width = 40
|
||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||
self.item_height = 15
|
||||
self.item_description_width = (self.page_width-20) / 2
|
||||
self.label_width = 100
|
||||
# @item_width = self.page_width.to_i / 2
|
||||
# @qty_width = @item_width.to_i / 3
|
||||
# @double = @qty_width * 1.3
|
||||
# @half_qty = @qty_width / 2
|
||||
#setting page margin and width
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 10
|
||||
self.item_font_size = 8
|
||||
|
||||
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(shift_sale)
|
||||
|
||||
footer
|
||||
|
||||
|
||||
end
|
||||
|
||||
def header (shop_details)
|
||||
move_down 7
|
||||
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||
move_down 5
|
||||
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||
# move_down self.item_height
|
||||
move_down 5
|
||||
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||
move_down 5
|
||||
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
def cashier_info(shift_sale)
|
||||
move_down 7
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Cashier: #{shift_sale.receipt_no}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Cashier Station Sta: #{shift_sale.receipt_no}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Opening Date", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Closing Date: #{shift_sale.receipt_no}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
|
||||
move_down 5
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def footer
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||
|
||||
move_down 5
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -447,7 +447,16 @@ $("#first_bill").on('click', function(){
|
||||
|
||||
$('#pay').on('click',function() {
|
||||
var sale_id = $('#sale_id').val();
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/origami/sale/'+ sale_id + "/rounding_adj",
|
||||
success:function(result){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Bill Request
|
||||
|
||||
@@ -215,7 +215,16 @@ $(document).ready(function(){
|
||||
});
|
||||
$('#pay').on('click',function() {
|
||||
var sale_id = $('#sale_id').val();
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
|
||||
alert(url)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/origami/sale/'+ sale_id + "/rounding_adj",
|
||||
success:function(result){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/origami/';
|
||||
|
||||
@@ -70,14 +70,20 @@
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</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>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Tax</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.total_tax rescue 0%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Rounding Adj:</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.rounding_adjustment rescue 0%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Grand Total</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
|
||||
</tr>
|
||||
<%if @balance > 0%>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong><%= @accountable_type %></strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@balance%></span></strong></td>
|
||||
</tr>
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
|
||||
@@ -112,6 +112,10 @@
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
@@ -139,7 +143,17 @@ $(document).ready(function(){
|
||||
});
|
||||
|
||||
$('#pay').on('click',function() {
|
||||
window.location.href = '/origami/sale/<%= @sale.id %>/payment';
|
||||
var sale_id = '<%= @sale.id %>';
|
||||
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
|
||||
alert(url)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/origami/sale/'+ sale_id + "/rounding_adj",
|
||||
success:function(result){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/origami/table/<%= @room.id %>';
|
||||
|
||||
@@ -203,6 +203,10 @@
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @obj.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @obj.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
@@ -424,12 +428,19 @@ $("#first_bill").on('click', function(){
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#pay').on('click',function() {
|
||||
var sale_id = $('#sale_id').val();
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
|
||||
alert(url)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/origami/sale/'+ sale_id + "/rounding_adj",
|
||||
success:function(result){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Bill Request
|
||||
$('#request_bills').click(function() {
|
||||
var order_id = $('#save_order_id').attr('data-order');
|
||||
|
||||
@@ -171,6 +171,10 @@
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= @sale.grand_total rescue 0%></strong></td>
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
|
||||
@@ -112,6 +112,10 @@
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
@@ -139,8 +143,23 @@ $(document).ready(function(){
|
||||
})
|
||||
});
|
||||
|
||||
// $('#pay').on('click',function() {
|
||||
// window.location.href = '/origami/sale/<%= @sale.id %>/payment';
|
||||
// });
|
||||
|
||||
$('#pay').on('click',function() {
|
||||
window.location.href = '/origami/sale/<%= @sale.id %>/payment';
|
||||
var sale_id = '<%= @sale.id %>';
|
||||
|
||||
var url = '<%= @calculate_rouding_adj_path %>';
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
success:function(result){
|
||||
// location.reload();
|
||||
}
|
||||
});
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
});
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/origami/table/<%= @table.id %>';
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<% credit += sale[:credit_amount] %>
|
||||
<% foc += sale[:foc_amount] %>
|
||||
<% discount += sale[:total_discount] %>
|
||||
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||
<% total += sale[:old_grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||
<% grand_total += sale[:grand_total].to_f %>
|
||||
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||
<tr>
|
||||
@@ -90,7 +90,7 @@
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:old_grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>
|
||||
</tr>
|
||||
|
||||
@@ -121,6 +121,7 @@ Rails.application.routes.draw do
|
||||
#payment - Outing payments - Cash only [ *Misc expeness tracking]
|
||||
|
||||
#--------- Payment ------------#
|
||||
post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj',:as => "calculate_rouding_adjs"
|
||||
get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' }
|
||||
get 'sale/:sale_id/payment' => 'payments#show'
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ class CreateSales < ActiveRecord::Migration[5.1]
|
||||
t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.integer :shift_sale_id, :null => false
|
||||
t.integer :shift_sale_id
|
||||
t.decimal :old_grand_total
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user