Merge branch 'r-1902001-01-dev' of gitlab.com:code2lab/SXRestaurant into r-1902001-01-dev
This commit is contained in:
@@ -1404,7 +1404,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
if payment_type.present?
|
||||
sale_payment = sale_payment.where(payment_method: payment_type)
|
||||
end
|
||||
|
||||
|
||||
return payments_total, sale_payment
|
||||
end
|
||||
|
||||
@@ -1438,10 +1438,10 @@ end
|
||||
cash = 0.0
|
||||
self.sale_payments.each do |pay|
|
||||
if pay.payment_method == 'cash'
|
||||
cash = pay.payment_amount-self.amount_changed
|
||||
cash += pay.payment_amount
|
||||
end
|
||||
end
|
||||
return cash
|
||||
return cash - self.amount_changed
|
||||
end
|
||||
|
||||
def get_credit_amount
|
||||
|
||||
@@ -70,7 +70,7 @@ class SalePayment < ApplicationRecord
|
||||
self.sale = invoice
|
||||
self.received_amount = cash_amount
|
||||
self.payment_reference = remark
|
||||
|
||||
|
||||
self.action_by = action_by
|
||||
#get all payment for this invoices
|
||||
if payment_for
|
||||
@@ -637,15 +637,14 @@ class SalePayment < ApplicationRecord
|
||||
def sale_update_payment_status(paid_amount, check_foc = false)
|
||||
#update amount_outstanding
|
||||
sale = self.sale
|
||||
total_payment_amount = sale.sale_payments.reload.sum(&:payment_amount)
|
||||
sale.amount_received = sale.amount_received.to_f + paid_amount.to_f
|
||||
sale.amount_changed = sale.amount_received.to_f - sale.grand_total.to_f
|
||||
|
||||
all_received_amount = sale.sale_payments.reload.sum(&:payment_amount)
|
||||
sale.amount_changed = total_payment_amount - sale.grand_total.to_f
|
||||
|
||||
is_credit = sale.sale_payments.any? { |x| x.payment_method == "creditnote" }
|
||||
is_foc = sale.sale_payments.any? { |x| x.payment_method == "foc" }
|
||||
|
||||
if sale.grand_total <= all_received_amount && sale.sale_status == "new"
|
||||
if sale.grand_total <= total_payment_amount && sale.sale_status == "new"
|
||||
sale.payment_status = "paid"
|
||||
if is_credit
|
||||
sale.payment_status = "outstanding"
|
||||
@@ -957,7 +956,6 @@ class SalePayment < ApplicationRecord
|
||||
def self.get_sale_payment_for_credit(sale_data)
|
||||
sale_data.sale_payments
|
||||
.joins(:sale_audit)
|
||||
.where(created_at: 1.days.ago.beginning_of_day..DateTime::Infinity.new)
|
||||
end
|
||||
|
||||
def get_credit_payment_left
|
||||
|
||||
@@ -17,7 +17,7 @@ class SeedGenerator < ApplicationRecord
|
||||
end
|
||||
|
||||
seed = self.update_seed(model_name)
|
||||
length = 15 - prefix.length
|
||||
length = 16 - prefix.length
|
||||
prefix + seed.to_s.rjust(length, '0')
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ class SeedGenerator < ApplicationRecord
|
||||
|
||||
start = self.update_seed(model_name, count)
|
||||
stop = start + count - 1
|
||||
length = 15 - prefix.length
|
||||
length = 16 - prefix.length
|
||||
(start..stop).map { |c| prefix + c.to_s.rjust(length, '0') }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user