close cashier pdf and receipt bill pdf changes for credit payment
This commit is contained in:
@@ -60,7 +60,9 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@account_arr =[]
|
@account_arr =[]
|
||||||
accounts.each do |acc|
|
accounts.each do |acc|
|
||||||
account = TaxProfile.find(acc)
|
account = TaxProfile.find(acc)
|
||||||
@account_arr.push(account)
|
if !account.nil?
|
||||||
|
@account_arr.push(account)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -83,7 +85,9 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@account_arr =[]
|
@account_arr =[]
|
||||||
accounts.each do |acc|
|
accounts.each do |acc|
|
||||||
account = TaxProfile.find(acc)
|
account = TaxProfile.find(acc)
|
||||||
@account_arr.push(account)
|
if !account.nil?
|
||||||
|
@account_arr.push(account)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@sale_taxes = []
|
@sale_taxes = []
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ class Origami::RoomsController < BaseOrigamiController
|
|||||||
@account_arr =[]
|
@account_arr =[]
|
||||||
accounts.each do |acc|
|
accounts.each do |acc|
|
||||||
account = TaxProfile.find(acc)
|
account = TaxProfile.find(acc)
|
||||||
@account_arr.push(account)
|
if !account.nil?
|
||||||
|
@account_arr.push(account)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -83,7 +85,9 @@ class Origami::RoomsController < BaseOrigamiController
|
|||||||
@account_arr =[]
|
@account_arr =[]
|
||||||
accounts.each do |acc|
|
accounts.each do |acc|
|
||||||
account = TaxProfile.find(acc)
|
account = TaxProfile.find(acc)
|
||||||
@account_arr.push(account)
|
if !account.nil?
|
||||||
|
@account_arr.push(account)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@sale_taxes = []
|
@sale_taxes = []
|
||||||
|
|||||||
@@ -96,12 +96,13 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
||||||
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||||
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||||
|
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||||
|
|
||||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile )
|
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Employee.logout(session[:session_token])
|
Employee.logout(session[:session_token])
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
# self.print(filename, cashier_terminal.printer_name)
|
# self.print(filename, cashier_terminal.printer_name)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
|
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
|
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
@@ -46,16 +46,16 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
cashier = shift_sale.employee.name
|
cashier = shift_sale.employee.name
|
||||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
|
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
||||||
|
|
||||||
if !close_cashier_pdf.empty?
|
if !close_cashier_pdf.empty?
|
||||||
close_cashier_pdf.each do |close_cashier|
|
close_cashier_pdf.each do |close_cashier|
|
||||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||||
if close_cashier[1] == '1'
|
if close_cashier[1] == '1'
|
||||||
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,@total_waste,@total_spoile)
|
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
else
|
else
|
||||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
|
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -889,25 +889,26 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_credit_payment_left
|
def get_credit_payment_left
|
||||||
query = SalePayment.select("(CASE WHEN (SUM(payment_amount) - (SELECT SUM(payment_amount)
|
sql = "SELECT SUM(payment_amount)
|
||||||
from sale_payments
|
from sale_payments
|
||||||
join sale_audits on SUBSTRING_INDEX(remark,'||',1)=sale_payment_id
|
join sale_audits on SUBSTRING_INDEX(remark,'||',1)=sale_payment_id
|
||||||
where sale_payments.sale_id = '#{self.sale_id}')) > 0 THEN (SUM(payment_amount) - (SELECT SUM(payment_amount)
|
where sale_payments.sale_id = '#{self.sale_id}'"
|
||||||
from sale_payments
|
|
||||||
join sale_audits on SUBSTRING_INDEX(remark,'||',1)=sale_payment_id
|
query = SalePayment.select("(CASE WHEN (SUM(payment_amount) - (#{sql})) > 0 THEN (SUM(payment_amount) - (#{sql})) ELSE 0 END) as payment_amount")
|
||||||
where sale_payments.sale_id = '#{self.sale_id}')) ELSE 0 END) as payment_amount")
|
|
||||||
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{self.sale_id}'")
|
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{self.sale_id}'")
|
||||||
return query
|
return query
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_sale_payments(sale_data)
|
def self.get_sale_payments(sale_data)
|
||||||
query = sale_data.sale_payments
|
sql = "SELECT SUM(payment_amount)
|
||||||
.where("CASE WHEN ((SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}') -
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
(SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}')
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
|
query = sale_data.sale_payments
|
||||||
|
.where("CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
ELSE SUM(payment_amount) END
|
ELSE SUM(payment_amount) END
|
||||||
FROM sale_payments
|
FROM sale_payments
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
||||||
|
|||||||
@@ -178,4 +178,11 @@ class ShiftSale < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_shift_sales_with_credit_payment(shift_id)
|
||||||
|
query = SalePayment.select("(CASE WHEN SUM(sale_payments.payment_amount) > 0 THEN SUM(sale_payments.payment_amount) ELSE 0 END) as total_credit_payments")
|
||||||
|
.joins(" JOIN sale_audits sa ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id")
|
||||||
|
.where("SUBSTRING_INDEX(SUBSTRING_INDEX(sa.remark,'||',-1),' -> ',1) = #{shift_id}")
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
|||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
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,:text_width
|
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,:text_width
|
||||||
|
|
||||||
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges)
|
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||||
self.page_height = printer_settings.page_height
|
self.page_height = printer_settings.page_height
|
||||||
self.header_font_size = printer_settings.header_font_size.to_i
|
self.header_font_size = printer_settings.header_font_size.to_i
|
||||||
@@ -54,7 +54,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
|||||||
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|
||||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges)
|
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
end
|
end
|
||||||
|
|
||||||
def header (shop_details)
|
def header (shop_details)
|
||||||
@@ -70,7 +70,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
|||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_spoile)
|
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
move_down 7
|
move_down 7
|
||||||
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
|
||||||
@@ -438,6 +438,16 @@ class CloseCashierCustomisePdf < Prawn::Document
|
|||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if total_credit_payments && total_credit_payments.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
#end for service charges and commercial tax
|
#end for service charges and commercial tax
|
||||||
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
||||||
# y_position = cursor
|
# y_position = cursor
|
||||||
@@ -520,7 +530,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
|||||||
if @overall > 0
|
if @overall > 0
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
|
text "Total Discount :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
@@ -531,7 +541,25 @@ class CloseCashierCustomisePdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
#end total over all discount
|
#end total over all discount
|
||||||
|
|
||||||
|
if total_waste.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Waste :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if total_spoile.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Spoile :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
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,:text_width
|
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,:text_width
|
||||||
|
|
||||||
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
|
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||||
self.page_height = printer_settings.page_height
|
self.page_height = printer_settings.page_height
|
||||||
self.header_font_size = printer_settings.header_font_size.to_i
|
self.header_font_size = printer_settings.header_font_size.to_i
|
||||||
@@ -54,7 +54,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|
||||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges)
|
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||||
end
|
end
|
||||||
|
|
||||||
def header (shop_details)
|
def header (shop_details)
|
||||||
@@ -70,7 +70,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges)
|
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||||
move_down 7
|
move_down 7
|
||||||
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
|
||||||
@@ -346,6 +346,16 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if total_credit_payments && total_credit_payments.to_f > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
#end for service charges and commercial tax
|
#end for service charges and commercial tax
|
||||||
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
||||||
# y_position = cursor
|
# y_position = cursor
|
||||||
|
|||||||
@@ -371,13 +371,15 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
def sale_payment(sale_data,precision,delimiter)
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
# move_down 10
|
# move_down 10
|
||||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
sql = "SELECT SUM(payment_amount)
|
||||||
.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}') -
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
(SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}')
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
|
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
||||||
|
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
ELSE SUM(payment_amount) END
|
ELSE SUM(payment_amount) END
|
||||||
FROM sale_payments
|
FROM sale_payments
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
||||||
@@ -587,12 +589,14 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sign(sale_data)
|
def sign(sale_data)
|
||||||
SalePayment.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
sql = "SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}') -
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
(SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}')
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
|
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
ELSE SUM(payment_amount) END
|
ELSE SUM(payment_amount) END
|
||||||
FROM sale_payments
|
FROM sale_payments
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
||||||
|
|||||||
@@ -369,13 +369,15 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
def sale_payment(sale_data,precision,delimiter)
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
#move_down line_move
|
#move_down line_move
|
||||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
sql = "SELECT SUM(payment_amount)
|
||||||
.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}') -
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
(SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}')
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
|
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
||||||
|
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
ELSE SUM(payment_amount) END
|
ELSE SUM(payment_amount) END
|
||||||
FROM sale_payments
|
FROM sale_payments
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
||||||
@@ -588,12 +590,14 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sign(sale_data)
|
def sign(sale_data)
|
||||||
SalePayment.where("(CASE WHEN ((SELECT SUM(payment_amount)
|
sql = "SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}') -
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
(SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}')
|
and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
|
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
ELSE SUM(payment_amount) END
|
ELSE SUM(payment_amount) END
|
||||||
FROM sale_payments
|
FROM sale_payments
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ class CreateSaleAudits < ActiveRecord::Migration[5.1]
|
|||||||
create_table :sale_audits, :id => false do |t|
|
create_table :sale_audits, :id => false do |t|
|
||||||
t.string :sale_audit_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
t.string :sale_audit_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||||
|
|
||||||
t.string :sale_id, foreign_key: true, :limit => 16
|
t.string :sale_id, foreign_key: true, :index => true, :limit => 16
|
||||||
t.string :action, :null => false
|
t.string :action, :null => false, :index => true
|
||||||
t.datetime :action_at, :null => false
|
t.datetime :action_at, :null => false, :index => true
|
||||||
t.string :action_by, :null => false
|
t.string :action_by, :null => false
|
||||||
t.string :approved_by, :null => true
|
t.string :approved_by, :null => true
|
||||||
t.datetime :approved_at, :null => true
|
t.datetime :approved_at, :null => true
|
||||||
t.text :remark
|
t.text :remark, :index => true
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
add_index :sale_audits, [:sale_id, :action, :action_at, :remark]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
|
|||||||
def change
|
def change
|
||||||
create_table :customers, :id => false do |t|
|
create_table :customers, :id => false do |t|
|
||||||
t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
|
t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
|
||||||
t.string :name, :null => false
|
t.string :name, :null => false, :index => true
|
||||||
t.string :company
|
t.string :company
|
||||||
t.string :email
|
t.string :email
|
||||||
t.string :contact_no, :unique => true
|
t.string :contact_no, :unique => true
|
||||||
@@ -20,6 +20,6 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
|
|||||||
t.json :tax_profiles
|
t.json :tax_profiles
|
||||||
t.string :image_path
|
t.string :image_path
|
||||||
end
|
end
|
||||||
add_index :customers, [:membership_id, :customer_type]
|
add_index :customers, [:name, :membership_id, :customer_type]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user