change receipt no report ui and add sale taxes for dining charges

This commit is contained in:
phyusin
2018-05-23 16:57:41 +06:30
parent ec50fbdac2
commit 85b997ddbe
5 changed files with 59 additions and 19 deletions

View File

@@ -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 = []

View File

@@ -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

View File

@@ -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|

View File

@@ -47,7 +47,7 @@
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></th>
<th><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> </th>
<% @tax_profiles.each do |tax| %>
<th><%= tax.name %></th>
<th><%= tax.name %></th>
<% end %>
<!-- <th>Other Amount</th> -->
<th><%= t("views.right_panel.detail.grand_total") %></th>
@@ -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 %>
<tr>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
<%if result.customer.customer_type == "Takeaway"%>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
<%end%>
<% result.sale_taxes.each do |tax| %>
<td><%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %>
</td>
<!-- <%if result.customer.customer_type == "Takeaway"%>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
<%end%> -->
<% if !result.sale_taxes.empty? %>
<% num = 1
if tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<td><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>

View File

@@ -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 %>
<tr>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<%if result.customer.customer_type == "Takeaway"%>
<!-- <%if result.customer.customer_type == "Takeaway"%>
<td>0.0</td>
<%end%>
<% result.sale_taxes.each do |tax| %>
<td><%= tax.tax_payable_amount rescue '-' %></td>
<%end%> -->
<% if !result.sale_taxes.empty? %>
<% num = 1
if tax_count > 0 %>
<% while num <= tax_count %>
<td>0</td>
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= tax.tax_payable_amount rescue '-' %>
</td>
<%end%>
<% else %>
<% @tax_profiles.each do |tax| %>
<td>0</td>
<% end %>
<%end%>
<td><%= result.grand_total %></td>