diff --git a/Gemfile b/Gemfile index 22275707..227cfa72 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -# gem 'pg' +gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 7acdb485..0886d04e 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -37,7 +37,7 @@ $(document).ready(function(){ control_button(order_status); var customer_id=$(this).find(".customer-id").text(); - //show_customer_details(customer_id); + show_customer_details(customer_id); $("#re-print").val(unique_id); diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 2670dcc4..3606dadc 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -9,6 +9,8 @@ // min-height: 75rem; // padding-top: 4.5rem; // } +.card-columns { + font-size: 18px !important;} .others-payment{ line-height:100px; @@ -128,6 +130,11 @@ text-align: right; } +.item-attr-edit{ + width: 10%; + text-align: left; +} + .display-none{ display: none; } @@ -186,4 +193,4 @@ tr.discount-item-row:hover { .jconfirm-box-container{ margin-left:-40px !important -} \ No newline at end of file +} diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 2b9f2834..3e7f8074 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -34,12 +34,11 @@ class Api::BillController < Api::ApiController # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) - # Calculate Food and Beverage Total - - food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) + # Calculate Price by accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts) end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 50278d71..d0a8ca9e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base # redirect_to root_path # end + def current_user @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 17012ad1..ca1aafb2 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -63,61 +63,62 @@ class Crm::CustomersController < BaseCrmController def edit end - # POST /crm/customers + # POST /crm/customers # POST /crm/customers.json def create @crm_customers = Customer.new(customer_params) respond_to do |format| - puts @crm_customers.errors.to_json if @crm_customers.save - name = customer_params[:name] - phone = customer_params[:contact_no] - email = customer_params[:email] - dob = customer_params[:date_of_birth] - address = customer_params[:address] - nrc = customer_params[:nrc_no] - member_group_id = params[:member_group_id] - - membership = MembershipSetting.find_by_membership_type("paypar_url") - memberaction = MembershipAction.find_by_membership_type("create_membership_customer") - merchant_uid = memberaction.merchant_account_id.to_s - auth_token = memberaction.auth_token.to_s - url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - - begin - response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - dob: dob,address: address,nrc:nrc, - member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - }, - :timeout => 10 - ) - rescue Net::OpenTimeout - response = { status: false } - end - - if response["status"] == true + name = customer_params[:name] + phone = customer_params[:contact_no] + email = customer_params[:email] + dob = customer_params[:date_of_birth] + address = customer_params[:address] + nrc = customer_params[:nrc_no] + member_group_id = params[:member_group_id] - customer = Customer.find(@crm_customers.customer_id) - status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) - - if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } - else - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} - end - # format.json { render :index, status: :created, location: @crm_customers } - else - - # @crm_customers.destroy - if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + if !member_group_id.nil? + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("create_membership_customer") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + begin + response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc, + member_group_id: member_group_id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }, + :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + end + + if response["status"] == true + + customer = Customer.find(@crm_customers.customer_id) + status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) + + if params[:sale_id] + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } + else + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} + end + # format.json { render :index, status: :created, location: @crm_customers } else - format.html { redirect_to crm_customers_path, notice: response["message"] } + # @crm_customers.destroy + if params[:sale_id] + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + else + format.html { redirect_to crm_customers_path, notice: response["message"] } + end end end else @@ -135,7 +136,6 @@ class Crm::CustomersController < BaseCrmController end end - # PATCH/PUT /crm/customers/1 # PATCH/PUT /crm/customers/1.json def update @@ -152,26 +152,66 @@ end id = @crm_customer.membership_id member_group_id = params[:member_group_id] - membership = MembershipSetting.find_by_membership_type("paypar_url") - memberaction = MembershipAction.find_by_membership_type("update_membership_customer") - merchant_uid = memberaction.merchant_account_id.to_s - auth_token = memberaction.auth_token.to_s - url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - begin - response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - dob: dob,address: address,nrc:nrc, - id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - }, - :timeout => 10 - ) - rescue Net::OpenTimeout - response = { status: false } - end - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } - format.json { render :show, status: :ok, location: @crm_customer } + if id.nil? && !member_group_id.nil? + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("create_membership_customer") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + begin + response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc, + member_group_id: member_group_id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }, + :timeout 10 + ) + rescue Net::OpenTimeout + response = { status: false } + end + + if response["status"] == true + + customer = Customer.find(@crm_customer.customer_id) + status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) + + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'} + else + format.html { redirect_to crm_customers_path, notice: response["message"] } + end + + else + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("update_membership_customer") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + begin + response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc, + id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }, + :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + end + + if response["status"] == true + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } + format.json { render :show, status: :ok, location: @crm_customer } + else + format.html { redirect_to crm_customers_path, notice: response["message"] } + end + + end else diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 734793b3..dbcc4046 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -104,6 +104,6 @@ class Crm::DiningQueuesController < BaseCrmController # Never trust parameters from the scary internet, only allow the white list through. def dining_queue_params - params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status) + params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status,:seater,:remark) end end diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index c05e7cf3..6866ddf1 100644 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -1,12 +1,12 @@ class Crm::HomeController < BaseCrmController def index - @booking = Booking.all - @customer = Customer.all - from = Time.now.beginning_of_day.utc - to = Time.now.end_of_day.utc - @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC') - + # @booking = Booking.all + # @customer = Customer.all + # from = Time.now.beginning_of_day.utc + # to = Time.now.end_of_day.utc + # @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC') + redirect_to crm_customers_path # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 18971247..64fd840d 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -82,7 +82,33 @@ class Oqs::HomeController < BaseOqsController end # Query for OQS with delivery status - def queue_items_query(status) + def queue_items_query(status) + # queue_items = [] + # AssignedOrderItem.all.each do |aoi| + # oqs = OrderQueueStation.find(aoi.order_queue_station_id) + # order = Order.find(aoi.order_id) + # order_items = OrderItem.find_by_order_id(aoi.order_id) + # booking_orders = BookingOrder.find_by_order_id(aoi.order_id) + # booking = Booking.find(booking_orders.booking_id) + # dining = DiningFacility.find(booking.dining_facility_id) + # customer = Customer.find_by_customer_id(order.customer_id) + # queue_item = { + # :assigned_order_item_id => aoi.assigned_order_item_id, + # :station_name => oqs.station_name, + # :is_active => oqs.is_active, + # :zone => dining.name, + # :item_code => aoi.item_code, + # :item_name => order_items.item_name, + # :price => order_items.price, + # :qty => order_items.qty, + # :item_order_by => order_items.item_order_by, + # :options => order_items.options, + # :customer_name => customer.name, + # :created_at => order_items.created_at + # } + # queue_items.push(queue_item) + # end + # return queue_items AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join orders as od ON od.order_id = assigned_order_items.order_id diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 373dc2f5..f15b8545 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -12,8 +12,17 @@ class Origami::CustomersController < BaseOrigamiController def add_customer - @sale_id = params[:sale_id] - filter = params[:filter] + @sale_id = params[:sale_id] + if(@sale_id[0,3] == "SAL") + @booking = Booking.find_by_sale_id(@sale_id) + @dining_facility = DiningFacility.find(@booking.dining_facility_id) + else + @booking_order = BookingOrder.find_by_order_id(@sale_id) + @booking = Booking.find(@booking_order.booking_id) + @dining_facility = DiningFacility.find(@booking.dining_facility_id) + end + + filter = params[:filter] filter = params[:filter] diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 6c0a4c8d..73038556 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -19,6 +19,8 @@ class Origami::DiscountsController < BaseOrigamiController if Sale.exists?(sale_id) sale = Sale.find(sale_id) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type 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; @@ -44,7 +46,10 @@ class Origami::DiscountsController < BaseOrigamiController sale_item.save end end - end + end + + dining = {:table_id => table_id, :table_type => table_type } + render :json => dining.to_json end #discount for selected order diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 13c528ab..4a070788 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -23,13 +23,13 @@ class Origami::HomeController < BaseOrigamiController @order_items = Array.new booking.booking_orders.each do |booking_order| order = Order.find(booking_order.order_id) - if (order.status == "new") + if (order.status == "new") @obj_order = order + @customer = order.customer @date = order.created_at order.order_items.each do |item| @order_items.push(item) end - end end @status_order = 'order' else @@ -43,6 +43,7 @@ class Origami::HomeController < BaseOrigamiController @date = sale.created_at @status_sale = 'sale' @obj_sale = sale + @customer = sale.customer end end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 38225fae..0119953f 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -11,7 +11,7 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(sale_id) sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") - + rebate_amount = nil unique_code = "ReceiptBillPdf" @@ -23,10 +23,10 @@ class Origami::PaymentsController < BaseOrigamiController # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total - food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount) end end @@ -53,7 +53,8 @@ class Origami::PaymentsController < BaseOrigamiController response["data"].each do |res| if res["accountable_type"] == "RebateAccount" @balance = res["balance"] - @accountable_type = res["accountable_type"] + # @accountable_type = res["accountable_type"] + @accountable_type = "Rebate Balance" end end end @@ -94,11 +95,11 @@ class Origami::PaymentsController < BaseOrigamiController # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) - # Calculate Food and Beverage Total - food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount) end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 93453ffc..95f63e58 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -24,19 +24,19 @@ class Origami::RequestBillsController < BaseOrigamiController customer= Customer.find(@sale_data.customer_id) # get member information - member_info = Customer.get_member_account(customer) + member_info = Customer.get_member_account(customer) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # find order id by sale id # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) - # Calculate Food and Beverage Total - food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info) # redirect_to origami_path(@sale_data.sale_id) end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 1ac7f41a..c25e0e1f 100644 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -9,9 +9,11 @@ class Origami::RoomsController < BaseOrigamiController @room.bookings.each do |booking| if booking.sale_id.nil? @order_items = Array.new + booking.booking_orders.each do |booking_order| order = Order.find(booking_order.order_id) @obj = order + @customer = order.customer order.order_items.each do |item| @order_items.push(item) end @@ -23,6 +25,7 @@ class Origami::RoomsController < BaseOrigamiController if sale.sale_status != "completed" @status = 'sale' @obj = sale + @customer = sale.customer end end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb new file mode 100644 index 00000000..93e98d03 --- /dev/null +++ b/app/controllers/origami/sale_edit_controller.rb @@ -0,0 +1,8 @@ +class Origami::SaleEditController < BaseOrigamiController + + def edit + sale_id = params[:sale_id] + @table_id = params[:table_id] + @saleobj = Sale.find(sale_id) + end +end diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 0a069b1b..54432c38 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -53,7 +53,7 @@ class Transactions::SalesController < ApplicationController #get customer amount @customer = Customer.find(@sale.customer_id) - @response = Customer.get_membership_transactions(@customer) + @response = Customer.get_membership_transactions(@customer) #end customer amount respond_to do |format| diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index f8cb639c..0e10307b 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -20,8 +20,6 @@ class DiningFacility < ApplicationRecord def get_booking booking = self.get_current_booking - puts "is bookig?" - puts booking if booking if booking.dining_facility_id.to_i == self.id if booking.booking_status == 'assign' diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 2e85ecde..04619379 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -18,14 +18,15 @@ class OrderQueueStation < ApplicationRecord order_items = order.order_items # get dining - booking = Booking.find_by_dining_facility_id(dining.id) + booking = Booking.find_by_dining_facility_id(dining.id) #Assign OQS id to order Items - oqs_stations.each do |oqs| + oqs_stations.each do |oqs| + is_auto_printed = false #Get List of items - pq_items = JSON.parse(oqs.processing_items) - #Loop through the processing items + #Loop through the processing items pq_items.each do |pq_item| #Processing through the looping items order_items.each do |order_item| @@ -36,11 +37,13 @@ class OrderQueueStation < ApplicationRecord # else AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - # end - - if oqs.auto_print + # end + + # Auto Printing + if oqs.auto_print && is_auto_printed == false print_slip(oqs, order, order_items) - end + is_auto_printed = true + end end end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 969b9d44..4b7287db 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount=nil) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info,rebate_amount) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount) pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index bec8b5c5..8881efea 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -30,9 +30,24 @@ class SaleItem < ApplicationRecord # end end - # Calculate food total and beverage total - def self.calculate_food_beverage(sale_items) + def self.calculate_price_by_accounts(sale_items) + price_accounts = [] + Account.all.each do |a| + account_price = {:name => a.title, :price => 0} + sale_items.each do |si| + if si.account_id == a.id + account_price[:price] = account_price[:price] + si.price + end + end + price_accounts.push(account_price) + end + + return price_accounts + end + + # Calculate rebate_by_account + def self.calculate_rebate_by_account(sale_items) rebateacc = Account.where("rebate=?",true) puts "Account that can rebate" rebateacc.each do |i| @@ -40,7 +55,7 @@ class SaleItem < ApplicationRecord end prices=0 sale_items.each do |si| - price = self.get_price(si.sale_item_id,rebateacc) + price = self.get_rebate_price(si.sale_item_id,rebateacc) prices = prices + price end @@ -48,7 +63,7 @@ class SaleItem < ApplicationRecord end # get food price or beverage price for item - def self.get_price(sale_item_id,rebateacc) + def self.get_rebate_price(sale_item_id,rebateacc) price=0 item=SaleItem.select("sale_items.price , menu_items.account_id") diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index f988b4e3..950334cb 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -265,7 +265,7 @@ class SalePayment < ApplicationRecord end def rebat(sObj) - rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items) + rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items) puts "eeeeeeeeeeeeeeeeeeeeeeee" puts rebate_prices generic_customer_id = sObj.customer.membership_id diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 749a8a16..4b7559b1 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -2,7 +2,7 @@ class OrderItemPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(order_item, print_status, options) self.page_width = 210 - self.page_height = 2500 + self.page_height = 1450 self.margin = 5 self.price_width = 40 # No Need for item self.qty_width = 30 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index b9c1f6fe..176749b8 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -2,7 +2,7 @@ class OrderSummaryPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(order, print_status) self.page_width = 210 - self.page_height = 2500 + self.page_height = 1450 self.margin = 5 self.price_width = 40 # No Need for item self.qty_width = 30 diff --git a/app/pdf/queue_no_pdf.rb b/app/pdf/queue_no_pdf.rb index 704dbfdb..0963f55e 100644 --- a/app/pdf/queue_no_pdf.rb +++ b/app/pdf/queue_no_pdf.rb @@ -2,7 +2,7 @@ class QueueNoPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings, queue) self.page_width = 210 - self.page_height = 2500 + self.page_height = 1450 self.margin = 5 self.price_width = 35 self.qty_width = 20 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index bdeb58a3..96e16cf4 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,6 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount = nil) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil) self.page_width = 210 self.page_height = 2500 self.margin = 5 @@ -29,7 +29,8 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule cashier_info(sale_data, customer_name) - line_items(sale_items, food_total, beverage_total) + line_items(sale_items) + items_account(item_price_by_accounts) all_total(sale_data) @@ -103,26 +104,24 @@ class ReceiptBillPdf < Prawn::Document move_down 5 end - def line_items(sale_items, food_total, beverage_total) + def line_items(sale_items) y_position = cursor pad_top(15) { - # @item_width.to_i + @half_qty.to_i - text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - - } + # @item_width.to_i + @half_qty.to_i + text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } move_down 5 stroke_horizontal_rule - add_line_item_row(sale_items, food_total, beverage_total) - + add_line_item_row(sale_items) end - def add_line_item_row(sale_items, food_total, beverage_total) + def add_line_item_row(sale_items) item_name_width = (self.item_width+self.price_width) y_position = cursor move_down 5 @@ -155,25 +154,26 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ sub_total }" , :size => self.item_font_size,:align => :right - end - - # Food and Beverage - food_beverage_total = food_total.to_s + "/" + beverage_total.to_s - - move_down 5 + end + move_down 5 + end + def items_account(item_price_by_accounts) y_position = cursor - bounding_box([0,y_position], :width => self.item_description_width, :height => self.item_height) do - text "Food/Beverage Total", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width => self.label_width) do - text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right + item_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right + end + move_down 5 end end def all_total(sale_data) item_name_width = self.item_width - move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index 968d2ca9..eb121c14 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -104,6 +104,7 @@
<%= queue.status %>
<%= @i += 1 %> . Queue No + Seater : <%= queue.seater %><%= queue.queue_no %>
diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index e862ea7f..0cd7d85b 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -73,6 +73,8 @@ + + <%= f.error_notification %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %>Date: <%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Date: <%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Date: <%= @order.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Date: <%= @order.created_at.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Date: <%= @obj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Date: <%= @obj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Receipt No: + <%= @saleobj.receipt_no rescue '' %> +
+Date: <%= @saleobj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+| # | +Items | +QTY + | Price + | Action | +
|---|---|---|---|---|
| <%= count %> | +<%= sale_item.product_name %> | ++ | + | + | +
Date: <%= @sale.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+ Employee ID: + <%= @employee.emp_id %> +
diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 04343380..b62289b1 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -110,14 +110,14 @@