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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="col-md-12">
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -18,9 +18,9 @@
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th colspan="7"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -28,9 +28,9 @@
|
||||
<th><b><%= t("views.right_panel.detail.shift_name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.table") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.receipt_no") %></b></th>
|
||||
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
|
||||
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.revenue") %></b></th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -47,7 +47,7 @@
|
||||
<td><%= @shift_from %> - <%= @shift_to %></td>
|
||||
<td><%= table_type %> - <%= table_name %></td>
|
||||
<td><%= result.receipt_no rescue '-' %> </td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%=result.grand_total%></td>
|
||||
<!-- <td> </td> -->
|
||||
</tr>
|
||||
@@ -66,8 +66,8 @@
|
||||
<% if item.price.to_i < 0.to_i %>
|
||||
<% if item.qty.to_i < 0.to_i%>
|
||||
[PROMO QTY]<%= item.product_name rescue '-' %>
|
||||
<% else %>
|
||||
[PROMO PRICE]<%= item.product_name rescue '-' %>
|
||||
<% else %>
|
||||
[PROMO PRICE]<%= item.product_name rescue '-' %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= item.product_name rescue '-' %>
|
||||
@@ -76,71 +76,71 @@
|
||||
<td><%= item.qty rescue '-' %></td>
|
||||
<td><%= item.unit_price rescue '-' %></td>
|
||||
<td><%= item.price rescue '-' %></td>
|
||||
<td><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> </td>
|
||||
<td><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
||||
<tr><td colspan="5"> </td></tr>
|
||||
|
||||
<%survey = Survey.find_by_receipt_no(result.receipt_no)%>
|
||||
<% if !survey.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>No. of Guest</td>
|
||||
<td><%= survey.total_customer rescue '-' %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if !result.total_amount.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= result.total_amount %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if result.total_discount.to_f > 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %>
|
||||
<%= t("views.right_panel.detail.discount") %>
|
||||
<%= t("views.right_panel.detail.discount") %>
|
||||
<%= t("views.right_panel.detail.amount") %></td>
|
||||
<td> - <%= result.total_discount %> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if !result.total_tax.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Tax Amount </td>
|
||||
<td><%= result.total_tax %> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% sale_payments = SalePayment.get_sale_payments(result) %>
|
||||
<% if sale_payments.length > 0%>
|
||||
|
||||
<% sale_payments = result.sale_payments %>
|
||||
<% if sale_payments.length > 0%>
|
||||
<% sale_payments.each do |rec| %>
|
||||
<%if rec.payment_amount.to_f > 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||
<td><%= rec.payment_amount %> ( <%= rec.payment_status %> )</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tr>
|
||||
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment Ref.</td>
|
||||
<td><%= rec.payment_reference %></td>
|
||||
<td> </td>
|
||||
@@ -148,10 +148,10 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if result.amount_changed != 0 && !result.amount_changed.nil? %>
|
||||
<% if result.amount_changed != 0 && !result.amount_changed.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= result.amount_changed %></td>
|
||||
<td> </td>
|
||||
@@ -160,32 +160,32 @@
|
||||
<% if !result.customer_id.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Customer</td>
|
||||
<td><%= result.customer.name rescue '-'%>
|
||||
<td><%= result.customer.name rescue '-'%>
|
||||
(<%= result.customer.company rescue '-' %>)
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% end %>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><b>Total Nett</b> - <b><%= grand_total %></b></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user