check menu is_available, survey id and check status with sale items SUM in receipBill

This commit is contained in:
phyusin
2018-05-16 17:08:00 +06:30
parent 486694a5e4
commit fa4c5d075e
8 changed files with 49 additions and 13 deletions

View File

@@ -265,6 +265,7 @@ function show_order_detail(url,sr_no){
dataType: "json",
success: function(data) {
// console.log(data);
$("#order_remark").text("");
$(".tbl_customer").show();
if(data.status != "delivered"){
$('#accepted').show();

View File

@@ -18,7 +18,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
end
if status
check_customer = Customer.find_by_email_and_membership_id(params[:email],params[:membership_id])
check_customer = Customer.find_by_email_and_membership_id_and_customer_type(params[:email],params[:membership_id],'Doemal')
if !check_customer.nil?
customer_id = check_customer.customer_id
else

View File

@@ -18,8 +18,8 @@ class Api::SurveyController < Api::ApiController
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
if params[:survey_id]
survey = Survey.find(params[:survey_id])
if params[:id]
survey = Survey.find(params[:id])
else
survey = Survey.new
end

View File

@@ -6,7 +6,7 @@ class Origami::PaymentsController < BaseOrigamiController
def first_bill
sale_id = params[:sale_id] # sale_id
sale_data = Sale.find_by_sale_id(sale_id)
sale_items = SaleItem.unscoped.select("sale_id,product_code,item_instance_code,product_name,product_alt_name,account_id,status,remark,SUM(qty) as qty,SUM(unit_price) as unit_price,SUM(taxable_price) as taxable_price,SUM(price) as price,is_taxable").where("sale_id=?",sale_id).group("item_instance_code,unit_price")
sale_items = SaleItem.get_all_sale_items(sale_id)
member_info = nil
# For Cashier by Zone
@@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_items = SaleItem.unscoped.select("sale_id,product_code,item_instance_code,product_name,product_alt_name,account_id,status,remark,SUM(qty) as qty,SUM(unit_price) as unit_price,SUM(taxable_price) as taxable_price,SUM(price) as price,is_taxable").where("sale_id=?",sale_id).group("item_instance_code,unit_price")
sale_items = SaleItem.get_all_sale_items(sale_id)
shop_details = Shop.first
# rounding adjustment
if shop_details.is_rounding_adj

View File

@@ -30,10 +30,19 @@ class OrderReservation < ApplicationRecord
customer.address = params[:address] ? params[:address] : ''
customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : ''
customer.membership_id = params[:membership_id]
customer.customer_type = "Takeaway"
customer.customer_type = "Doemal"
customer.tax_profiles = ["2"]
customer.save
# unless customer.valid?
# render json: {
# status: 422,
# message: "Validation error",
# errors: customer.errors
# }.to_json
# return
# end
return customer
end

View File

@@ -161,6 +161,20 @@ class SaleItem < ApplicationRecord
# return price
# end
def self.get_all_sale_items(sale_id)
sale_items = SaleItem.select("sale_id,product_code,item_instance_code,
product_name,product_alt_name,account_id,status,remark,
(CASE WHEN qty > 0 AND remark IS NULL THEN SUM(qty) ELSE qty END) as qty,
unit_price,
taxable_price,
(CASE WHEN price > 0 AND remark IS NULL THEN SUM(price) ELSE price END) as price,
is_taxable")
.where("sale_id = ?",sale_id)
.order("product_name asc")
.group("status,product_name,item_instance_code,unit_price")
return sale_items
end
private
def generate_custom_id
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")

View File

@@ -29,7 +29,9 @@ if (menu.menu_categories)
if category.menu_items
json.items category.menu_items do |item|
json.partial! 'origami/addorders/menu_item', item: item
if item.is_available
json.partial! 'origami/addorders/menu_item', item: item
end
end
end
end

View File

@@ -151,14 +151,24 @@
<td style='text-align:right;'><%= number_with_precision(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<% total_tax = 0 %>
<% total_tax = 0
tax_amount = 0
tax_name = ''
tax_arr = [] %>
<% net = 0 %>
<% unless @tax.empty? %>
<% @tax.each do |tax| %>
<% total_tax += tax.tax_amount.to_f %>
<% if tax.tax_name.downcase == tax_name.downcase
tax_amount += tax.tax_amount
else
tax_amount = tax.tax_amount
end
tax_name = tax.tax_name
total_tax += tax.tax_amount.to_f
%>
<tr style="font-weight:600;">
<td colspan="17" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td colspan="17" style='text-align:right;'><%= tax_name rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
<% end %>
@@ -170,8 +180,8 @@
<td colspan="2">&nbsp;</td>
</tr>
<% net = grand_total%>
<% net = grand_total- discount%>
<% net = grand_total %>
<% net = grand_total + discount%>
<% net = net - rounding_adj%>
<% net = net - total_tax %>
<tr style="font-weight:600;">