update shift and multiple
This commit is contained in:
@@ -130,9 +130,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
if path.include? ("credit_payment")
|
if path.include? ("credit_payment")
|
||||||
sale_payment.process_payment(saleObj, current_user.name, cash, "cash", nil, true)
|
sale_payment.process_payment(saleObj, current_user, cash, "cash", nil, true)
|
||||||
else
|
else
|
||||||
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||||
end
|
end
|
||||||
|
|
||||||
if !path.include? ("credit_payment")
|
if !path.include? ("credit_payment")
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
|
|
||||||
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
|
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
|
||||||
|
|
||||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false)
|
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false)
|
||||||
self.sale = invoice
|
self.sale = invoice
|
||||||
self.received_amount = cash_amount
|
self.received_amount = cash_amount
|
||||||
self.payment_reference = remark
|
self.payment_reference = remark
|
||||||
|
puts action_by
|
||||||
|
puts "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
self.action_by = action_by
|
||||||
#get all payment for this invoices
|
#get all payment for this invoices
|
||||||
if payment_for
|
if payment_for
|
||||||
invoice_sale_payments = SalePayment.get_sale_payment_for_credit(invoice)
|
invoice_sale_payments = SalePayment.get_sale_payment_for_credit(invoice)
|
||||||
@@ -84,12 +86,12 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
remark = "#{self.sale_payment_id}||#{shift_sale_id} -> #{remark}"
|
remark = "#{self.sale_payment_id}||#{shift_sale_id} -> #{remark}"
|
||||||
|
|
||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by.name)
|
||||||
if payment_method == "cash"
|
if payment_method == "cash"
|
||||||
update_shift_for_credit_payment
|
update_shift_for_credit_payment
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# update complete order items in oqs
|
# update complete order items in oqs
|
||||||
@@ -107,7 +109,7 @@ class SalePayment < ApplicationRecord
|
|||||||
else
|
else
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
|
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by.name)
|
||||||
|
|
||||||
return false, "No outstanding Amount"
|
return false, "No outstanding Amount"
|
||||||
end
|
end
|
||||||
@@ -620,15 +622,25 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
# update for cashier shift
|
# update for cashier shift
|
||||||
def update_shift
|
def update_shift
|
||||||
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
|
||||||
|
shift = ShiftSale.current_open_shift(self.action_by.id)
|
||||||
|
|
||||||
|
if shift.nil?
|
||||||
|
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
||||||
|
end
|
||||||
|
|
||||||
if !shift.nil?
|
if !shift.nil?
|
||||||
shift.update(self.sale)
|
shift.update(self.sale)
|
||||||
self.sale.shift_sale_id = shift.id
|
self.sale.shift_sale_id = shift.id
|
||||||
|
self.sale.cashier_id = shift.employee_id
|
||||||
|
self.sale.cashier_name = Employee.find(shift.employee_id).name
|
||||||
self.sale.save
|
self.sale.save
|
||||||
else
|
else
|
||||||
shift = ShiftSale.current_shift
|
shift = ShiftSale.current_shift
|
||||||
shift.update(self.sale)
|
shift.update(self.sale)
|
||||||
self.sale.shift_sale_id = shift.id
|
self.sale.shift_sale_id = shift.id
|
||||||
|
self.sale.cashier_id = shift.employee_id
|
||||||
|
self.sale.cashier_name = Employee.find(shift.employee_id).name
|
||||||
self.sale.save
|
self.sale.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,24 +43,36 @@
|
|||||||
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
<% if @print_settings.precision.to_i > 0
|
||||||
|
precision = @print_settings.precision
|
||||||
|
else
|
||||||
|
precision = 0
|
||||||
|
end
|
||||||
|
#check delimiter
|
||||||
|
if @print_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end
|
||||||
|
%>
|
||||||
<% unless @sale_data.empty? %>
|
<% unless @sale_data.empty? %>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @sale_data.each do |sale| %>
|
<% @sale_data.each do |sale| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:unionpay_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:alipay_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:paymal_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:dinga_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:junctionpay_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td><%= number_with_delimiter(sprintf("%.2f",sale[:giftvoucher_amount]), :delimiter => ',') rescue '-'%></td>
|
<td><%= number_with_precision(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -81,7 +93,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||||
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||||
<th> <%= t :payment_method %></th>
|
<th> <%= t :payment_method %></th>
|
||||||
<th> <%= t("views.right_panel.detail.amount") %> </th>
|
<th> <%= t("views.right_panel.detail.amount") %> </th>
|
||||||
@@ -91,7 +103,11 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% total = 0 %>
|
<% total = 0 %>
|
||||||
<% @pyament_method.each do |payment| %>
|
<% @pyament_method.each do |payment| %>
|
||||||
<% total += payment.payment_amount %>
|
<% if payment.payment_method === 'cash'
|
||||||
|
total += payment.payment_amount - payment.change_amount
|
||||||
|
else
|
||||||
|
total += payment.payment_amount
|
||||||
|
end%>
|
||||||
<tr>
|
<tr>
|
||||||
<% if @shift_from.nil? && @shift_to.nil? %>
|
<% if @shift_from.nil? && @shift_to.nil? %>
|
||||||
<td><%= payment.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
<td><%= payment.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
||||||
@@ -102,8 +118,12 @@
|
|||||||
<td><%= payment.cashier_name rescue '-' %></td>
|
<td><%= payment.cashier_name rescue '-' %></td>
|
||||||
<!--<td><%= payment.sale.customer.name rescue '-' %></td>-->
|
<!--<td><%= payment.sale.customer.name rescue '-' %></td>-->
|
||||||
<td><%= payment.payment_method rescue '-' %></td>
|
<td><%= payment.payment_method rescue '-' %></td>
|
||||||
<td><%= payment.payment_amount rescue '-' %></td>
|
<% if payment.payment_method === 'cash' %>
|
||||||
<td><%= payment.sale.grand_total rescue '-' %></td>
|
<td><%= number_with_precision(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||||
|
<%else%>
|
||||||
|
<td><%= number_with_precision(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||||
|
<%end%>
|
||||||
|
<td><%= number_with_precision(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -111,7 +131,7 @@
|
|||||||
<%if total>0%>
|
<%if total>0%>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" style="text-align: right;"><strong >Total </strong></td>
|
<td colspan="4" style="text-align: right;"><strong >Total </strong></td>
|
||||||
<td colspan="2"><strong><%=total%></strong></td>
|
<td colspan="2"><strong><%=number_with_precision(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<%end%>
|
<%end%>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user