to do req_bill_format and status changed after pay

This commit is contained in:
Yan
2017-06-12 00:45:26 +06:30
parent 518e15f5d1
commit f834911587
19 changed files with 567 additions and 248 deletions

View File

@@ -2,7 +2,7 @@ class Origami::DiscountsController < BaseOrigamiController
#discount page show from origami index with selected order
def index
sale_id = params[:id]
sale_id = params[:id]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
end
@@ -11,30 +11,32 @@ class Origami::DiscountsController < BaseOrigamiController
#discount for selected order
def create
sale_id = params[:sale_id]
sale_item_id = params[:sale_item_id]
discount_type = params[:discount_type]
discount_value = params[:discount_value]
discount_amount = params[:discount_amount]
grand_total = params[:grand_total]
discount_value = params[:discount_value]
discount_amount = params[:discount_amount]
grand_total = params[:grand_total]
if discount_type == 0
remark="Discount " + discount_amount + " as net"
else
remark="Discount " + discount_amount + " as percentage"
end
if discount_type == 0
remark="Discount " + discount_amount + " as net"
else
remark="Discount " + discount_amount + " as percentage"
end
#update discount for sale
sale = Sale.find(sale_id)
sale.total_discount = discount_amount
sale.grand_total = grand_total
sale.save
#update discount for sale
sale = Sale.find(sale_id)
sale.total_discount = sale.total_discount + discount_amount.to_f
sale.grand_total = grand_total
sale.save
#save sale item for discount
origin_sale_item = SaleItem.find(sale_item_id)
sale_item = SaleItem.new
#pull
sale_item.sale_id = sale_id
sale_item.product_code = 0
sale_item.product_name = "Discount"
sale_item.product_code = origin_sale_item.product_code
sale_item.product_name = origin_sale_item.product_name + " Discount"
sale_item.remark = remark
sale_item.qty = 1
@@ -45,7 +47,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.price = sale_item.qty * sale_item.unit_price
sale_item.save
redirect_to origami_root_path
redirect_to origami_path(sale_id)
end
end