fixed conflict

This commit is contained in:
Nweni
2019-11-08 16:08:45 +06:30
19 changed files with 585 additions and 955 deletions

View File

@@ -7,9 +7,9 @@ class Origami::DiscountsController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter()
@webview = false
if check_mobile
@webview = true
@webview = true
end
sale_id = params[:id]
@cashier_type = params[:type]
if Sale.exists?(sale_id)
@@ -32,7 +32,7 @@ class Origami::DiscountsController < BaseOrigamiController
discount_items = JSON.parse(params[:discount_items])
overall_discount = params[:overall_discount]
sub_total = params[:sub_total]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -44,26 +44,29 @@ class Origami::DiscountsController < BaseOrigamiController
table_id = nil
end
# sale.total_discount = overall_discount.to_f
# 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.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|
origin_sale_item = SaleItem.find(di["id"])
sale_item = SaleItem.new
if !origin_sale_item.nil?
menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
if !menu_category.nil?
sale_item.menu_category_code = menu_category.code
sale_item.menu_category_name = menu_category.name
end
end
# if !origin_sale_item.nil?
# menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
# if !menu_category.nil?
# sale_item.menu_category_code = menu_category.code
# sale_item.menu_category_name = menu_category.name
# end
# end
sale_item.menu_category_code = origin_sale_item.menu_category_code
sale_item.menu_category_name = origin_sale_item.menu_category_name
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
@@ -73,7 +76,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.status = "Discount"
sale_item.qty = -1
sale_item.unit_price = di["price"].to_f * (-1)
sale_item.unit_price = di["price"].to_f * -1
sale_item.taxable_price = di["price"]
sale_item.is_taxable = 1
sale_item.account_id = origin_sale_item.account_id
@@ -83,11 +86,11 @@ class Origami::DiscountsController < BaseOrigamiController
action_by = current_user.name
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
end
end
end
end
# Re-calc All Amount in Sale
if overall_discount.to_f > 0
@@ -97,24 +100,24 @@ class Origami::DiscountsController < BaseOrigamiController
else
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
end
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
end
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
if !table.nil?
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Success" }
end
else
else
if !table.nil?
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Please, Check Again!" }
end
end
end
render :json => result.to_json
end
@@ -131,45 +134,45 @@ class Origami::DiscountsController < BaseOrigamiController
else
table_id = nil
table = nil
end
if discount_items.length > 0
end
if discount_items.length > 0
#destroy sale item for discount
discount_items.each do |di|
sale_item = SaleItem.find(di["id"])
discount_items.each do |di|
sale_item = SaleItem.find(di["id"])
sale.total_amount = (sale.total_amount + sale_item.price.abs)
action_by = current_user.name
if table.nil?
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table "
else
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEITEMDISCOUNT" )
sale_item.destroy
end
end
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
sale_item.destroy
end
end
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
end
else
else
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
end
end
end
render :json => result.to_json
end
@@ -180,29 +183,29 @@ class Origami::DiscountsController < BaseOrigamiController
order_source = params[:type]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
sale = Sale.find(sale_id)
if sale.bookings[0].dining_facility_id.to_i > 0
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
table_type = table.type
table_type = table.type
else
table_id = nil
table = nil
table_type = nil
end
end
discount_items = []
discount_items = []
#destroy all discount sale item
sale.sale_items.each do |si|
if si.status == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
sale.sale_items.each do |si|
if si.status == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
end
end
end
# sale.total_discount = 0
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
#destroy in sale.sale_items
@@ -215,23 +218,23 @@ class Origami::DiscountsController < BaseOrigamiController
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
else
else
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
end
end
render :json => result.to_json
end
@@ -251,7 +254,7 @@ class Origami::DiscountsController < BaseOrigamiController
end
# Check for Card Payment
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
# if is_card != "true"
account_types = Account.where("discount=?",true)
table_id = sale.bookings[0].dining_facility_id
@@ -267,9 +270,9 @@ class Origami::DiscountsController < BaseOrigamiController
str={type:pc[:name],amount:pc[:price]}
acc_prices.push(str)
end
end
end
end
generic_customer_id = sale.customer.membership_id
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
@@ -282,7 +285,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Check for items for Paypar Cloud
if acc_prices.length > 0
begin
response = HTTParty.post(url,
response = HTTParty.post(url,
:body => { account_no: account_no,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
@@ -307,7 +310,7 @@ class Origami::DiscountsController < BaseOrigamiController
rescue SocketError
response = {"status": false, "message": "Can't open membership server " }
end
else
else
response = {"status": false, "message": "You have no selected discount item" }
end
Rails.logger.debug "-------------- Member Discount Osaka ---------"
@@ -325,7 +328,7 @@ class Origami::DiscountsController < BaseOrigamiController
else
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
end
render :json => result.to_json
# end #end Is Card Payment
@@ -376,5 +379,5 @@ class Origami::DiscountsController < BaseOrigamiController
# redirect_to origami_path(sale_id)
# end
end

View File

@@ -64,15 +64,9 @@ class Origami::PaymentsController < BaseOrigamiController
customer = Customer.find(sale_data.customer_id)
# rounding adjustment
if shop_detail.is_rounding_adj
a = sale_data.grand_total % 25 # Modulus
b = sale_data.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = new_total-sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj)
end
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = new_total - sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
end
#end rounding adjustment
#record for sale audit
@@ -151,15 +145,9 @@ class Origami::PaymentsController < BaseOrigamiController
# rounding adjustment
if !path.include? ("credit_payment")
if shop_detail.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total - saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
end
end
#end rounding adjustment

View File

@@ -72,7 +72,7 @@ class Origami::SaleEditController < BaseOrigamiController
saleitemObj.status = 'foc'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.unit_price = saleitemObj.unit_price * 1
@@ -143,7 +143,7 @@ class Origami::SaleEditController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMEDIT" )
# saleitemObj.remark = 'edit'
unless saleitemObj.product_name.include? 'updated'
unless saleitemObj.product_name.include? 'UPDATED'
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
end