feat: add mmqr in shift sale report

This commit is contained in:
Pyae Bhone Zaw
2025-06-26 11:09:11 +06:30
parent ba57516cda
commit 82b6474bc7
3 changed files with 16 additions and 2 deletions

View File

@@ -826,7 +826,8 @@ def self.get_by_shiftsales(from,to,shift)
:shift_closed_at => shift_sale.shift_closed_at,
:cash_sales => shift_sale.cash_sales,
:credit_sales => shift_sale.credit_sales,
:other_sales => shift_sale.other_sales.to_f,
:other_sales => (shift_sale.other_sales.to_f - ShiftSale.get_by_shift_mmqr_payment(shift_sale.id).to_f).abs,
:mmqr_sales => ShiftSale.get_by_shift_mmqr_payment(shift_sale.id).to_f,
:foc_sales => foc,
:grand_total => shift_sale.grand_total,
:shift_id => shift_sale.id

View File

@@ -152,6 +152,15 @@ class ShiftSale < ApplicationRecord
return closing_balance
end
def self.get_by_shift_mmqr_payment(shift)
Sale.joins(:sale_payments)
.where(shift_sale_id: shift, sale_status: 'completed')
.where(sale_payments: { payment_method: 'mmqr' })
.where.not(sale_payments: { payment_status: 'cancelled' })
.where.not(sale_payments: { payment_amount: 0 })
.sum("sale_payments.payment_amount")
end
def self.get_by_shift_other_payment(shift)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)

View File

@@ -55,6 +55,7 @@
<!-- <th>Credit Charges</th> -->
<th><%= t("views.right_panel.detail.credit_payment") %></th>
<th class="d-none d-sm-table-cell"><%= t("views.btn.other_payment") %></th>
<th class="d-none d-sm-table-cell"><%= t("views.btn.mmqr_payment") %></th>
<th class="d-none d-sm-table-cell"><%= t("views.btn.foc") %> <%= t :payment %></th>
<!-- <th>Grand Total
<br/>Rounding Adj</th> -->
@@ -74,6 +75,7 @@
<% credit = 0%>
<% accept_credit = 0%>
<% foc = 0%>
<% mmqr = 0 %>
<% card = 0%>
<% total = 0%>
<% rounding_adj = 0%>
@@ -98,6 +100,7 @@
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
<td class="d-none d-sm-table-cell"><%= number_format(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td class="d-none d-sm-table-cell"><%= number_format(result[:mmqr_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td class="d-none d-sm-table-cell">
<%= number_format(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
</td>
@@ -113,7 +116,7 @@
<% credit += result[:credit_sales].to_f %>
<% card += result[:other_sales].to_f %>
<% foc += result[:foc_sales].to_f %>
<% mmqr += result[:mmqr_sales].to_f %>
<% total += result[:grand_total].to_f %>
<% g_total += grand_total.to_f %>
@@ -127,6 +130,7 @@
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td class="d-none d-sm-table-cell"><b><%= number_format(card, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
<td class="d-none d-sm-table-cell"><b><%= number_format(mmqr, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
<td class="d-none d-sm-table-cell"><b><%= number_format(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->