fixed otherpayment & redeem
This commit is contained in:
@@ -266,17 +266,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
if path.include? 'credit_payment'
|
if path.include? 'credit_payment'
|
||||||
@sale_payment = false
|
@sale_payment = false
|
||||||
@amount_due = @sale.sale_payments.where(payment_method: 'creditnote').pluck('SUM(payment_amount)').first
|
@amount_due = @sale.sale_payments.where(payment_method: 'creditnote').pluck('SUM(payment_amount)').first
|
||||||
payments = @sale.sale_payments.joins(:sale_audit).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
|
payments = @sale.sale_payments.joins(:sale_audit).group_by(&:payment_method).map { |method, payments| [method == 'paypar' ? 'redeem' : method, payments.sum { |payment| payment.payment_amount }] }
|
||||||
else
|
else
|
||||||
@sale_payment = true
|
@sale_payment = true
|
||||||
@amount_due = @sale.grand_total
|
@amount_due = @sale.grand_total
|
||||||
payments = @sale.sale_payments.left_joins(:sale_audit).where(sale_audits: {sale_audit_id: nil}).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
|
payments = @sale.sale_payments.left_joins(:sale_audit).where(sale_audits: {sale_audit_id: nil}).group_by(&:payment_method).map { |method, payments| [method == 'paypar' ? 'redeem' : method, payments.sum { |payment| payment.payment_amount }] }
|
||||||
end
|
end
|
||||||
|
|
||||||
@payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
|
@payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
|
||||||
@cash = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'cash' }
|
@cash = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'cash' }
|
||||||
@credit = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'creditnote' }
|
@credit = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'creditnote' }
|
||||||
@other_payments = payments.select { |payment| !['cash', 'creditnote'].include? payment[0] }.map { |method, amount| [ @payment_methods.find { |payment_method| payment_method.parameterize == method }, amount ] }
|
@other_payments = payments.select { |payment| !['cash', 'creditnote', 'foc'].include? payment[0] }.map { |method, amount| [ @payment_methods.find { |payment_method| payment_method.parameterize == method }, amount ] }
|
||||||
@other_payment = @other_payments.sum { |payment| payment[1] }
|
@other_payment = @other_payments.sum { |payment| payment[1] }
|
||||||
|
|
||||||
#total customer with individual total amount
|
#total customer with individual total amount
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Reports::DailysaleController < BaseReportController
|
|||||||
|
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
@print_settings = PrintSetting.get_precision_delimiter()
|
# @print_settings = PrintSetting.get_precision_delimiter()
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xls
|
format.xls
|
||||||
|
|||||||
@@ -753,7 +753,7 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
sales = select("
|
sales = select("
|
||||||
sales.*,
|
sales.*,
|
||||||
#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method}"}.join(', ')},
|
#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.join(', ')},
|
||||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||||
CASE WHEN SUM(case when sale_payments.payment_method not in('creditnote')
|
CASE WHEN SUM(case when sale_payments.payment_method not in('creditnote')
|
||||||
then sale_payments.payment_amount else 0 end) < sales.grand_total
|
then sale_payments.payment_amount else 0 end) < sales.grand_total
|
||||||
@@ -777,7 +777,7 @@ class Sale < ApplicationRecord
|
|||||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0))-(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
|
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0))-(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
|
||||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
|
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
|
||||||
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||||
#{payment_methods.map { |method| "SUM(#{method}) as #{method}"}.join(', ')},
|
#{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(#{pm}) as #{pm}"}.join(', ')},
|
||||||
SUM(cash_amount) as cash_amount,
|
SUM(cash_amount) as cash_amount,
|
||||||
SUM(credit_amount) as credit_amount,
|
SUM(credit_amount) as credit_amount,
|
||||||
SUM(foc_amount) as foc_amount
|
SUM(foc_amount) as foc_amount
|
||||||
@@ -1342,7 +1342,7 @@ def self.get_payment_method_by_shift(shift,from,to,payment_type)
|
|||||||
|
|
||||||
payments_total = SalePayment.select("
|
payments_total = SalePayment.select("
|
||||||
sales.receipt_date as sale_date,
|
sales.receipt_date as sale_date,
|
||||||
#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method}"}.join(', ')},
|
#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.join(', ')},
|
||||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then
|
SUM(case when (sale_payments.payment_method='cash') then
|
||||||
sales.amount_changed else 0 end) as total_change_amount,
|
sales.amount_changed else 0 end) as total_change_amount,
|
||||||
|
|||||||
@@ -142,8 +142,9 @@ class SaleAudit < ApplicationRecord
|
|||||||
if paymal[0]
|
if paymal[0]
|
||||||
remark = paymal[0].remark.split("}")
|
remark = paymal[0].remark.split("}")
|
||||||
response = "["+remark[0]+'}]'
|
response = "["+remark[0]+'}]'
|
||||||
response = JSON.parse(response)
|
|
||||||
# puts response
|
# puts response
|
||||||
|
# response = JSON.parse(response)
|
||||||
|
|
||||||
if response[0]["status"] == true
|
if response[0]["status"] == true
|
||||||
if response[0]["current_rebate_amount"].present?
|
if response[0]["current_rebate_amount"].present?
|
||||||
amount = response[0]["current_rebate_amount"]
|
amount = response[0]["current_rebate_amount"]
|
||||||
|
|||||||
@@ -680,7 +680,7 @@ $(document).ready(function(){
|
|||||||
$('#pay').click(function() {
|
$('#pay').click(function() {
|
||||||
sub_total = $('#sub-total').text();
|
sub_total = $('#sub-total').text();
|
||||||
member = $('#membership_id').text();
|
member = $('#membership_id').text();
|
||||||
if (payment_type && !other_payments.some(x => payment_type.indexOf(x[0]) >= 0 && x[1] > 0 ) && sub_total != 0.0 && member) {
|
if (payment_type && payment_type.length > 0 && !other_payments.some(x => payment_type.indexOf(x[0]) >= 0 && x[1] > 0) && sub_total != 0.0 && member) {
|
||||||
swal("Oops","Please Pay with " + payment_methods.find(x => payment_type.indexOf(x) >= 0) + " Payment","warning");
|
swal("Oops","Please Pay with " + payment_methods.find(x => payment_type.indexOf(x) >= 0) + " Payment","warning");
|
||||||
} else {
|
} else {
|
||||||
$( "#loading_wrapper").show();
|
$( "#loading_wrapper").show();
|
||||||
|
|||||||
Reference in New Issue
Block a user