add req and fix for shift

This commit is contained in:
Yan
2017-07-07 17:19:14 +06:30
parent 1b0bcbffea
commit 3fe0f708bd
9 changed files with 104 additions and 25 deletions

View File

@@ -52,11 +52,34 @@ class ShiftSale < ApplicationRecord
self.cash_sales = self.cash_sales.to_f + cash.to_f
self.credit_sales = self.credit_sales.to_i + credit.to_f
self.other_sales = self.other_sales.to_i + other_sales.to_f
self.nett_sales = saleobj.total_amount.to_f #self.grand_total.to_i - self.commercial_taxes
self.nett_sales = self.nett_sales + saleobj.total_amount.to_f #self.grand_total.to_i - self.commercial_taxes
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
self.total_receipt = self.total_receipt + 1
self.save
end
# Calculate by type and update
def calculate(sale, type)
saleobj = Sale.find_by_sale_id(sale)
cash = saleobj.get_cash_amount
credit = saleobj.get_credit_amount
other_sales = saleobj.get_other_amount
tax = saleobj.get_commerical_tax
if type == "void"
self.total_revenue = self.total_revenue.to_f - saleobj.total_amount.to_f
self.total_discounts = self.total_discounts - saleobj.total_discount
self.total_taxes = self.total_taxes - saleobj.total_tax
self.grand_total = self.grand_total - saleobj.grand_total
self.cash_sales = self.cash_sales.to_f - cash.to_f
self.credit_sales = self.credit_sales.to_i - credit.to_f
self.other_sales = self.other_sales.to_i - other_sales.to_f
self.nett_sales = self.nett_sales - saleobj.total_amount.to_f #self.grand_total.to_i - self.commercial_taxes
self.commercial_taxes = self.commercial_taxes.to_i - tax.to_f
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
self.total_void = self.total_void + saleobj.grand_total
self.save
end
end
def get_closing_balance(shift)