diff --git a/app/controllers/api/restaurant/menu_controller.rb b/app/controllers/api/restaurant/menu_controller.rb index f6a43514..47a3703c 100755 --- a/app/controllers/api/restaurant/menu_controller.rb +++ b/app/controllers/api/restaurant/menu_controller.rb @@ -9,7 +9,7 @@ class Api::Restaurant::MenuController < Api::ApiController all_menu = Menu.all @request_url = '' if ENV["SERVER_MODE"] == "cloud" - @request_url = request.subdomain + "." + request.domain #local_url => 'http://0.0.0.0:3000' + @request_url = request.base_url end # to hash menu_array = [] diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 2e43da0b..19d5720a 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -27,7 +27,8 @@ authorize_resource :class => false payment_type = params[:payment_type] @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type) @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) - @tax_profiles = TaxProfile.where('group_type = "cashier"').order('order_by asc').limit(2) + @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) + @from = from @to = to # get printer info diff --git a/app/models/sale.rb b/app/models/sale.rb index 7ceecebd..24d3f81c 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -51,7 +51,7 @@ class Sale < ApplicationRecord if !charges.nil? block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at) dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s - create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time) + create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source) end return status, sale_id @@ -131,6 +131,7 @@ class Sale < ApplicationRecord if order_source.nil? order_source = order.source end + puts "compute source" compute(order_source) #Update the order items that is billed @@ -275,7 +276,7 @@ class Sale < ApplicationRecord end end - def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time) + def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time, order_source = nil) sale_item = SaleItem.new sale_item.product_code = chargeObj.item_code sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )" @@ -291,7 +292,7 @@ class Sale < ApplicationRecord # Re-calc sale = Sale.find(self.id) - self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount) + self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source) end def update_item (item) @@ -506,6 +507,7 @@ class Sale < ApplicationRecord if order_source.to_s == "emenu" order_source = "cashier" end + #Create new tax records tax_profiles.each do |tax| # customer.tax_profiles.each do |cus_tax| diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index bd06be3f..30a610d0 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -47,7 +47,7 @@ <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> <%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> <% @tax_profiles.each do |tax| %> - <%= tax.name %> + <%= tax.name %> <% end %> <%= t("views.right_panel.detail.grand_total") %> @@ -89,20 +89,39 @@ <% total_sum += result.total_amount.to_f %> <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> - - - + + <% tax_profile_count = @tax_profiles.length %> + <% sale_tax_count = result.sale_taxes.length %> + <% tax_count = tax_profile_count - sale_tax_count %> <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %> <%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %> - <%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) %> - <%if result.customer.customer_type == "Takeaway"%> - <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> - <%end%> - <% result.sale_taxes.each do |tax| %> - <%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %> + + + <% if !result.sale_taxes.empty? %> + <% num = 1 + if tax_count > 0 %> + <% while num <= tax_count %> + + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + + <% num += 1 + end %> + <% end %> + <% result.sale_taxes.each do |tax| %> + + <%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + + <%end%> + <% else %> + <% @tax_profiles.each do |tax| %> + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <% end %> <%end%> <%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %> diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index ff74ef5a..ac955e73 100755 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -59,17 +59,35 @@ <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> + <% tax_profile_count = @tax_profiles.length %> + <% sale_tax_count = result.sale_taxes.length %> + <% tax_count = tax_profile_count - sale_tax_count %> <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %> <%= result.total_amount rescue '-' %> <%= result.total_discount rescue '-' %> - <%if result.customer.customer_type == "Takeaway"%> + + <% if !result.sale_taxes.empty? %> + <% num = 1 + if tax_count > 0 %> + <% while num <= tax_count %> + 0 + <% num += 1 + end %> + <% end %> + <% result.sale_taxes.each do |tax| %> + + <%= tax.tax_payable_amount rescue '-' %> + + <%end%> + <% else %> + <% @tax_profiles.each do |tax| %> + 0 + <% end %> <%end%> <%= result.grand_total %>