item void

This commit is contained in:
Nweni
2017-06-26 17:07:17 +06:30
parent 04e44c4859
commit d4983fabf5
3 changed files with 42 additions and 14 deletions

View File

@@ -51,6 +51,8 @@ class Origami::SaleEditController < BaseOrigamiController
end end
def apply_void def apply_void
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void
end end
end end

View File

@@ -199,6 +199,31 @@ class Sale < ApplicationRecord
end end
def compute_without_void
sales_items = self.sale_items
#Computation Fields
subtotal_price = 0
total_taxable = 0
rounding_adjustment = 0
sales_items.each do |item|
if item.remark != 'void'
#compute each item and added to total
subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + item.taxable_price
end
end
apply_tax (total_taxable)
self.total_amount = subtotal_price
self.total_discount = total_discount
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
#compute rounding adjustment
adjust_rounding
self.save!
end
# Tax Calculate # Tax Calculate
def apply_tax(total_taxable) def apply_tax(total_taxable)
#if tax is not apply create new record #if tax is not apply create new record

View File

@@ -0,0 +1 @@
json.status true