item void
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
1
app/views/origami/sale_edit/apply_void.json.jbuilder
Normal file
1
app/views/origami/sale_edit/apply_void.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
|||||||
|
json.status true
|
||||||
Reference in New Issue
Block a user