Merge branch 'r-1902001-01-dev' of gitlab.com:code2lab/SXRestaurant into r-1902001-01-dev
This commit is contained in:
@@ -242,7 +242,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -136,23 +136,24 @@
|
||||
<% sale_payments = result.sale_payments %>
|
||||
<% if sale_payments.length > 0%>
|
||||
<% sale_payments.each do |rec| %>
|
||||
<% next if rec.payment_method == 'credit_note' && result.payments_for_credits_amount < rec.payment_amount %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||
<td><%= number_format(rec.payment_amount, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %> ( <%= rec.payment_status %> )</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<% if rec.payment_amount > 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment Ref.</td>
|
||||
<td><%= rec.payment_reference %></td>
|
||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||
<td><%= number_format(rec.payment_amount, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %> ( <%= rec.payment_status %> )</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment Ref.</td>
|
||||
<td><%= rec.payment_reference %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if result.amount_changed != 0 %>
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% sale_payments = SalePayment.get_sale_payments(result) %>
|
||||
<% sale_payments = result.sale_payments %>
|
||||
<% if sale_payments.length > 0%>
|
||||
<% sale_payments.each do |rec| %>
|
||||
<%if rec.payment_amount.to_f > 0 %>
|
||||
|
||||
Reference in New Issue
Block a user