update shift close print

This commit is contained in:
Aung Myo
2017-07-01 20:05:26 +06:30
20 changed files with 379 additions and 141 deletions

View File

@@ -22,10 +22,10 @@ class Origami::DiscountsController < BaseOrigamiController
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_discount = overall_discount.to_f
sale.total_amount = sub_total.to_f
sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
sale.save
# sale.total_discount = overall_discount.to_f
# sale.total_amount = sub_total.to_f
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
# sale.save
if discount_items.length > 0
#save sale item for discount
discount_items.each do |di|
@@ -35,6 +35,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
sale_item.product_name = di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Discount"
sale_item.qty = 1
@@ -45,7 +46,10 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.price = di["price"]
sale_item.save
end
end
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
end
dining = {:table_id => table_id, :table_type => table_type }

View File

@@ -16,10 +16,11 @@ class Origami::OtherChargesController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_amount = sub_total.to_f
sale.grand_total = sub_total.to_f + sale.total_tax;
sale.save
table_type = DiningFacility.find(table_id).type
# sale.total_amount = sub_total.to_f
# sale.grand_total = sub_total.to_f + sale.total_tax;
# sale.save
if other_charges_items.length > 0
#save sale item for discount
other_charges_items.each do |di|
@@ -34,14 +35,17 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.qty = 1
sale_item.unit_price = di["price"]
sale_item.taxable_price = di["price"]
sale_item.taxable_price = 0
sale_item.is_taxable = 0
sale_item.price = di["price"]
sale_item.save
end
end
end
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
end
dining = {:table_id => table_id, :table_type => table_type }
render :json => dining.to_json

View File

@@ -23,6 +23,26 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.save
end
def item_edit
saleitemId = params[:sale_item_id]
update_qty = params[:update_qty]
update_price = params[:update_price]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'void'
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.save
@newsaleitem.qty = update_qty
@newsaleitem.price = update_price
@newsaleitem.unit_price = update_price
@newsaleitem.taxable_price = update_price
@newsaleitem.is_taxable = 0
@newsaleitem.remark = 'edit'
@newsaleitem.product_name = saleitemObj.product_name + " - updated"
@newsaleitem.save
end
# make cancel void item
def item_void_cancel
saleitemId = params[:sale_item_id]

View File

@@ -26,6 +26,9 @@ class Origami::SalesController < BaseOrigamiController
order.order_items.each do |orer_item|
saleobj.add_item (orer_item)
end
# Re-compute for add
saleobj.compute
saleobj.save
order.save
booking.save

View File

@@ -4,7 +4,6 @@ class Origami::ShiftsController < BaseOrigamiController
end
def show
puts current_user.id
@shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -15,8 +14,9 @@ class Origami::ShiftsController < BaseOrigamiController
def create
opening_balance = params[:opening_balance]
cashier_terminal = params[:cashier_terminal]
@shift = ShiftSale.new
@shift.create(opening_balance,current_user)
@shift.create(opening_balance,cashier_terminal, current_user)
end
def update_shift
@@ -27,10 +27,21 @@ class Origami::ShiftsController < BaseOrigamiController
@shift.shift_closed_at = DateTime.now.utc
@shift.closing_balance = closing_balance.to_f
@shift.save
end
end
unique_code = "CloseCashierPdf"
shop_details = Shop.find(1)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,@shift,shop_details)
end
end
def edit
end
end