Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into loyalty

This commit is contained in:
Moe Su
2017-06-08 18:22:27 +06:30
10 changed files with 79 additions and 487 deletions

View File

@@ -8,8 +8,44 @@ class Origami::DiscountsController < BaseOrigamiController
end
end
#discount for selected order
def create
sale_id = params[:sale_id]
discount_type = params[:discount_type]
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
#update discount for sale
sale = Sale.find(sale_id)
sale.total_discount = discount_amount
sale.grand_total = grand_total
sale.save
#save sale item for discount
sale_item = SaleItem.new
#pull
sale_item.sale_id = sale_id
sale_item.product_code = 0
sale_item.product_name = "Discount"
sale_item.remark = remark
sale_item.qty = 1
sale_item.unit_price = (0-discount_amount.to_f)
sale_item.taxable_price = discount_amount
sale_item.is_taxable = 0
sale_item.price = sale_item.qty * sale_item.unit_price
sale_item.save
redirect_to origami_root_path
end
end

View File

@@ -26,4 +26,4 @@ class Origami::RequestBillsController < BaseOrigamiController
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer_name)
redirect_to origami_root_path
end
end