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

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