diff --git a/README.md b/README.md index a020ba48..d3f2199f 100755 --- a/README.md +++ b/README.md @@ -84,12 +84,12 @@ For ReceiptBillAltName options For Using Star Printer *** Need to change these print settings - 1) settings/print_settings => OrderItemStarPdf - 2) settings/print_settings => ReceiptBillStarPdf - 3) settings/print_settings => SaleItemsStarPdf + 1) settings/print_settings/unique_code => OrderItemStarPdf + 2) settings/print_settings/unique_code => ReceiptBillStarPdf + 3) settings/print_settings/unique_code => SaleItemsStarPdf *** Other print settings aren't need to change. -For Sale Items Summary Include at CloseCashierPrint +For Show Sale Items Summary at CloseCashierPrint 1) settings/print_settings a) Check => Shift Sale Items diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 548c7d41..500fcacb 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,3 +1,4 @@ +//middle edit $(function() { var role = $('#role').val(); var second_display_lookup = $("#display_type").val(); @@ -52,28 +53,16 @@ $(function() { if (type ==-1 && modify_order == -1){ image_path = product[field].image_path.url; } - }else{ - image_path = "/image/logo.png"; - } - row = '
' + + row = '
' +'
' +'
' +'
'+ product[field].name +'
' - +"' + +'
' - +"
" - - // +"
" - // +"" - // +"
" - - +'' + +'
' + +'' + +'
'; + } + else + { + row = '
' + +'
' + +'
' + +"
" + +'
'+ product[field].name +'
' + +'
' + + + +'
' + + +"
" + + +'
' + + +'' + + +'
'; + } $('.menu_items_list').append(row); } } @@ -497,7 +541,6 @@ $(function() { //click item row for add order $(document).on('click', '.menu_item_box', function(event){ - $('.attributes-list').empty(); $('.options-list').empty(); $('#modal_box_img').empty(); @@ -842,8 +885,11 @@ $(function() { e.preventDefault(); $("#oqs_loading_wrapper").show(); var cashier_type = $("#link_type").val(); + localStorage.setItem('cashier_type',cashier_type); quick_service = window.location.href.indexOf("quick_service"); + localStorage.setItem('quick_service',quick_service); food_court = window.location.href.indexOf("food_court"); + localStorage.setItem('food_court',food_court); if (quick_service != -1 || food_court != -1) { type = cashier_type; var table_type = $('#table_type').text(); @@ -1380,6 +1426,7 @@ $(function() { var menu_list = $('.menu_items_list'); menu_list.empty(); for(var field in menu_items) { + console.log(menu_items[field].instances); if (menu_items[field].is_sub_item == false) { instances = menu_items[field].instances ; @@ -1440,52 +1487,109 @@ $(function() { }else{ image_path = menu_items[field].image; } + row = '
' + +'
' + +'
' + +'
'+ menu_items[field].name +'
' - }else{ - if (modify_order) { - image_path = "../../image/logo.png"; - }else{ - image_path = "image/logo.png"; - } - } + +'
' + +"
" + +'
' + +''; ; $('.menu_items_list').append(row); } //end instances in menu-items alest 1 instance diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8e3ede95..bd9018fb 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -35,6 +35,7 @@ //= require BSBMaterial/demo.js //= require custom.js //= require jquery-fileupload/basic +//= require induties/induties.js $(document).ready(function() { $('.count-to').countTo(); diff --git a/app/assets/javascripts/induties/assign_in_duties.coffee b/app/assets/javascripts/induties/assign_in_duties.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/induties/assign_in_duties.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/induties/induties.js b/app/assets/javascripts/induties/induties.js new file mode 100644 index 00000000..e69de29b diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index d60c2f08..f74f1fa9 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -288,6 +288,8 @@ function show_order_detail(url,sr_no){ data: {}, dataType: "json", success: function(data) { + var scrollTo = document.getElementById('div_card_order'); + $("HTML, body").animate({scrollTop: scrollTo.offsetTop - 60 }, 500 ); // console.log(data); $("#order_remark").text(""); $(".tbl_customer").show(); @@ -373,24 +375,49 @@ function show_order_detail(url,sr_no){ item_price = items[i].unit_price; } var total = items[i].qty * item_price; - if(items[i].options!='[]' && items[i].options!="" && items[i].options!=null){ - row = '' - +''+items[i].item_name - +'
' - +' '+items[i].options+'
'+ - ''+items[i].qty+ ' X'+items[i].unit_price+'' - +'' - +''+ total +'' - +''; - }else{ - row = '' - +''+items[i].item_name - +'
'+ - ''+items[i].qty+ ' X'+items[i].unit_price+'' - +'' - +''+ total +'' - +''; + var check_mobile =document.getElementsByName("summary_items_mobile")[0].value; + if (check_mobile == "true"){ + if(items[i].options!='[]' && items[i].options!="" && items[i].options!=null){ + row = + '' + +''+items[i].item_name + +'
' + +' '+items[i].options+''+ + ''+items[i].qty+ '' + +'' + +''+ total +'' + +''; + }else{ + row = '' + +''+items[i].item_name + +' '+ + ''+items[i].qty+ '' + +''+ total +'' + +''; + } } + else{ + if(items[i].options!='[]' && items[i].options!="" && items[i].options!=null){ + row = '' + +''+items[i].item_name + +'
' + +' '+items[i].options+'
'+ + ''+items[i].qty+ ' X'+items[i].unit_price+'' + +'' + +''+ total +'' + +''; + }else{ + row = '' + +''+items[i].item_name + +'
'+ + ''+items[i].qty+ ' X'+items[i].unit_price+'' + +'' + +''+ total +'' + +''; + } + } + + $('.summary-items').append(row); } diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss index 1ffdb8f0..1cda9286 100755 --- a/app/assets/stylesheets/addorder.scss +++ b/app/assets/stylesheets/addorder.scss @@ -3,12 +3,12 @@ section .content{ } .custom-card-head{ height: 40px; - #background-color: #54A5AF; - background-color: #a1aade; + background-color: #79D0F2; + color :#fff; + #background-color: #a1aade; opacity: 0.8; padding:5px; - color :#000000; - + font-weight:400; } .custom-card { border: 2px solid rgba(0, 0, 0, 0.125) !important; @@ -16,6 +16,10 @@ section .content{ } .custom-card-footer{ padding:0.35rem 1.25rem !important; + bottom:0; + position: absolute; + width: 100%; + font-weight:900; } .custom-card-block { @@ -192,7 +196,7 @@ section.content{ } .menu_item_box{ - cursor: pointer; + cursor: pointer; } /*Logout Icon*/ @@ -300,4 +304,33 @@ i.logout_icon{ .ls-closed section.content { margin-left: 15px !important; margin-right: 15px !important; -} \ No newline at end of file +} +.product_box{ + position:relative; + text-align:center; + font-weight:900; + color:#fff; + font-size:1.5em; + margin:auto; +} +.custom-card-no-img-head{ + #background-color: #54A5AF; + opacity: 0.8; + padding:5px; + color :#273040; + min-height:100px; + height: 150px; + background-color:#79D0F2; + +} +.menu_item_no_img_box{ + cursor: pointer; + +} +.custom-card-no-img-footer{ + padding:0.35rem 1.25rem !important; + +} +.custom-flex-footer{ + display:flex; +} diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 5b0c6845..e0308d12 100755 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -11,6 +11,7 @@ @import "BSBMaterial/style"; @import "BSBMaterial/themes/all-themes"; @import "reset"; +@import "induties/assign_in_duties"; /*@import "bootstrap-select/css/bootstrap-select.min";*/ diff --git a/app/assets/stylesheets/induties/assign_in_duties.scss b/app/assets/stylesheets/induties/assign_in_duties.scss new file mode 100644 index 00000000..f51fbcff --- /dev/null +++ b/app/assets/stylesheets/induties/assign_in_duties.scss @@ -0,0 +1,96 @@ +// Place all the styles related to the induties/assign_in_duties controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +.custom-card-head{ + height: 40px; + background-color: grey; + color :#fff; + opacity: 0.8; + padding:5px; + font-weight:400; + align-items: center; +} +.form-group .form-control { + width: 100%; + border: none; + box-shadow: none; + -webkit-border-radius: 0; + -moz-border-radius: 0; + -ms-border-radius: 0; + border-radius: 0; + padding-left: 0; +} +.radio-room{ + margin-right:2rem; +} +.radio-table{ + margin-left:1rem; +} +.bmd-form-group { + position: relative; + padding-top: 0 !important; +} +.btn_create_induty{ + display: inline; + padding: 1.5rem; + margin: 0; +} +.create_induty_card{ + min-height:500px; +} + +#save_induties_by_name{ + -webkit-appearance: none; +} + +.checkboxLabel:before{ + content: '\e40c'; + font-family: "Material Icons"; + font-size: 25px; + vertical-align: middle; + margin-right: 5px; + color: #2196F3; +} + +#save_induties_by_name:checked ~ .checkboxLabel:before{ + content: '\e86c'; +} +.checkboxLabel { + font-size: 18px !important; +} +.add_more{ + content: '\e40c'; + font-family: "Material Icons"; + font-size: 25px; + vertical-align: middle; + margin-right: 5px; + color: #2196F3; +} +.success-msg { + color: #270; + background-color: #DFF2BF; + margin: 10px 0; + padding: 10px; + border-radius: 3px 3px 3px 3px; + display: none; + margin-right: 0.5rem; + margin-left: 0.5rem; +} +.show_all_commissioner_card{ + min-height: 830px; + max-height: 830px; + overflow: scroll; +} +.sweet-alert p { + font-size: 14px !important; + font-weight:bold; +} +.sweet-alert { + top :0; + margin-top: 20px !important; +} +.add_to_charges{ + width:100%; + padding:1rem; +} \ No newline at end of file diff --git a/app/assets/stylesheets/order_reservation.scss b/app/assets/stylesheets/order_reservation.scss index e46ce76d..d6e9a7fb 100644 --- a/app/assets/stylesheets/order_reservation.scss +++ b/app/assets/stylesheets/order_reservation.scss @@ -99,4 +99,10 @@ td.grand-total-padding { font-size: 17px; padding-top: 20px !important; +} +.mobile_tab-col-teal > li { + margin:auto; +} +.mobile_tab-col-teal{ + margin-left:1.5rem; } \ No newline at end of file diff --git a/app/assets/stylesheets/sx_font.css b/app/assets/stylesheets/sx_font.css index b8b08f2a..b08657e5 100755 --- a/app/assets/stylesheets/sx_font.css +++ b/app/assets/stylesheets/sx_font.css @@ -39,4 +39,4 @@ /* Support for IE. */ font-feature-settings: 'liga'; -} \ No newline at end of file +} diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index a5112ffe..caa1efb5 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -21,6 +21,7 @@ class Api::ApiController < ActionController::API def current_login_employee @employee = Employee.find_by_token_session(current_token) + puts @employee.to_json end # def lookup_domain diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index b5cb5573..214e1300 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -43,7 +43,7 @@ class Api::BillController < Api::ApiController if booking if booking.sale_id.nil? @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, cashier, order.source) + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, cashier, order.source,params[:current_checkin_induties_count]) @sale_data = Sale.find_by_sale_id(@sale_id) else @status = true @@ -177,7 +177,7 @@ class Api::BillController < Api::ApiController if @booking.sale_id.nil? @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(@booking.booking_id, current_login_employee, cashier, order.source) + @status, @sale_id = @sale.generate_invoice_from_booking(@booking.booking_id, current_login_employee, cashier, order.source,params[:current_checkin_induties_count]) @sale_data = Sale.find_by_sale_id(@sale_id) else @status = true diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb new file mode 100644 index 00000000..42ab5919 --- /dev/null +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -0,0 +1,60 @@ +class Api::Payment::MobilepaymentController < Api::ApiController + + # skip_before_action :authenticate + + def cash + + cash = params[:cash] + sale_id = params[:sale_id] + cashier_id = params[:cashier_id] + + current_user = Employee.find(cashier_id) + + if(Sale.exists?(sale_id)) + + saleObj = Sale.find(sale_id) + sale_items = SaleItem.get_all_sale_items(sale_id) + shop_detail = Shop.first + + # rounding adjustment + if !path.include? ("credit_payment") + if shop_detail.is_rounding_adj + a = saleObj.grand_total % 25 # Modulus + b = saleObj.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + + end + end + end + # end rounding adjustment + + sale_payment = SalePayment.new + + sale_payment =sale_payment.process_payment(saleObj, current_user, cash, "cash") + if sale_payment[0] + @cash ={"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''} + end + @out = true,@cash + + else + @out =false,"Something wrong!" + sale_payment = SalePayment.new + sale_payment = sale_payment.process_payment(saleObj, current_user, cash, "cash") + if sale_payment[0] + @cash = {"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''} + end + end + + end + + def kbz_pay + + end + +end diff --git a/app/controllers/api/sync_controller.rb b/app/controllers/api/sync_controller.rb index 83acf8f6..52db7245 100644 --- a/app/controllers/api/sync_controller.rb +++ b/app/controllers/api/sync_controller.rb @@ -13,5 +13,8 @@ class Api::SyncController < Api::ApiController ShiftSale.sync_shift_sale_records(params[:shift_sales]) Booking.sync_booking_records(params[:bookings]) AssignedOrderItem.sync_assigned_order_item_records(params[:assigned_order_items]) + SeedGenerator.sync_seed_generator_records(params[:seed_generators]) + + # render :json => { :status => true, :message => "Hello!" } end end \ No newline at end of file diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 50c0da09..aacfa39f 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -8,7 +8,7 @@ class Crm::CustomersController < BaseCrmController filter = params[:filter] filter_card_no = params[:filter_card_no] type = params[:type] - @customer_update_phone_email =false + @customer_update_phone_email_membertype =false if filter_card_no=="" @crm_customers = Customer.all elsif !filter_card_no.nil? @@ -46,13 +46,16 @@ class Crm::CustomersController < BaseCrmController else @crm_customers.each do |customer| if customer.contact_no != response["customer_data"]["phone"] - @customer_update_phone_email =true + @customer_update_phone_email_membertype =true end if customer.email != response["customer_data"]["email"] - @customer_update_phone_email =true + @customer_update_phone_email_membertype =true end if customer.name != response["customer_data"]["name"] - @customer_update_phone_email =true + @customer_update_phone_email_membertype =true + end + if customer.membership_type.to_i != response["customer_data"]["member_group_id"] + @customer_update_phone_email_membertype =true end end end @@ -122,7 +125,6 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) @response = Customer.get_membership_transactions(@customer) - puts @response.to_json Rails.logger.debug "get membership transactions response" Rails.logger.debug @response.to_json @@ -555,13 +557,14 @@ class Crm::CustomersController < BaseCrmController end end - def customer_update_phone_email + def customer_update_phone_email_member_type @customer = Customer.find(params[:id]) response = Customer.search_paypar_account_no(@customer.paypar_account_no) if response["status"] == true @customer.name =response["customer_data"]["name"] @customer.contact_no =response["customer_data"]["phone"] @customer.email =response["customer_data"]["email"] + @customer.membership_type =response["customer_data"]["member_group_id"] @customer.save respond_to do |format| format.html { redirect_to crm_customers_path } diff --git a/app/controllers/induties/assign_in_duties_controller.rb b/app/controllers/induties/assign_in_duties_controller.rb new file mode 100644 index 00000000..528c009f --- /dev/null +++ b/app/controllers/induties/assign_in_duties_controller.rb @@ -0,0 +1,71 @@ +class Induties::AssignInDutiesController < ApplicationController + def index + @commissioners =[] + @commiss=Commissioner.active.all.order(created_at: :desc) + @commiss.each do|commissioner| + check_in_count =InDuty.where('commissioner_ids =? and out_time is null', commissioner.id.to_json).count; + @commissioners.push({ "id"=>commissioner.id, + "name"=>commissioner.name, + "image_path"=>commissioner.image_path.url, + "check_in_count"=>check_in_count + }) + + end + @booking_id = params[:booking_id] + + end + + def get_all_occupied_dining + commissionerIds =params[:id] + @check_in_commissioner =InDuty.select("in_duties.*,dining_facilities.type as dinning_type") + .joins(" LEFT JOIN dining_facilities on dining_facilities.id = in_duties.dinning_id").where('commissioner_ids =? and out_time is null', commissionerIds).order(created_at: :asc); + respond_to do |format| + format.json { render json: @check_in_commissioner.to_json } + end + end + def induties_create + commissioner_ids =params[:commissionerId] + booking_id =params[:booking_id] + dinning_id = params[:dinning_id] + induty = InDuty.new + induty.dinning_id = dinning_id + induty.booking_id = booking_id + induty.commissioner_ids = commissioner_ids + induty.by_name = params[:by_name] + induty.in_time = Time.now.utc + if induty.save + dinning = DiningFacility.find(induty.dinning_id) + @induty= {"id"=>induty.id, + "dinning_id"=>induty.dinning_id, + "in_time"=>induty.in_time, + "out_time"=>induty.out_time, + "dinning_type"=>dinning.type } + respond_to do |format| + format.json { render json: @induty.to_json } + end + end + end + def induties_checkout + induty_id = params[:induty_id] + induty = InDuty.find(induty_id) + induty.out_time = Time.now.utc + induty.save + @induty =induty + respond_to do |format| + format.json { render json: @induty.to_json } + end + end + def induties_remove + induty_id = params[:induty_id] + induty = InDuty.find(induty_id) + induty.destroy + end + def get_current_booking + @current_booking =InDuty.select("in_duties.*,dining_facilities.type as dinning_type") + .joins(" LEFT JOIN dining_facilities on dining_facilities.id = in_duties.dinning_id").where('booking_id =? and out_time is null', params[:booking_id]).order(created_at: :asc); + respond_to do |format| + format.json { render json: @current_booking.to_json } + end + end + +end diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index acdef9f8..c6e130ec 100644 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -38,22 +38,21 @@ class Oqs::EditController < BaseOqsController if ENV["SERVER_MODE"] != "cloud" #&& order.source == 'cashier' #no print in cloud server # print - assigned_item = AssignedOrderItem.find_by_instance_code_and_order_id(order_item.item_instance_code, order_item.order_id) + assigned_item = AssignedOrderItem.find_by_instance_code_and_order_id(order_item.item_instance_code, order_item.order_id) assigned_items = nil if !assigned_item.nil? assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'") - end + end if !assigned_items.nil? assigned_items.each do |assign_item| # order queue stations oqs = assign_item.order_queue_station - printer = PrintSetting.all - - unique_code="OrderItemPdf" + printer = PrintSetting.all + unique_code= "" if !printer.empty? printer.each do |printer_setting| - if printer_setting.unique_code == 'OrderItemPdf' + if printer_setting.unique_code == 'OrderItemPdf' unique_code="OrderItemPdf" elsif printer_setting.unique_code == 'OrderItemSlimPdf' unique_code="OrderItemSlimPdf" @@ -62,12 +61,14 @@ class Oqs::EditController < BaseOqsController elsif printer_setting.unique_code == 'OrderItemCustomisePdf' unique_code="OrderItemCustomisePdf" elsif printer_setting.unique_code == 'OrderSetItemCustomisePdf' - unique_code="OrderSetItemCustomisePdf" + unique_code="OrderSetItemCustomisePdf" elsif printer_setting.unique_code == 'OrderItemSlimCustomisePdf' unique_code="OrderItemSlimCustomisePdf" - end + elsif printer_setting.unique_code == 'OrderItemStarPdf' + unique_code="OrderItemStarPdf" + end end - end + end print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 8b767fa2..2ba8cd3e 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -17,6 +17,7 @@ class Origami::HomeController < BaseOrigamiController # origami table detail def show + @webview = check_mobile @tables = Table.unscoped.all.active.order('status desc') @@ -35,7 +36,7 @@ class Origami::HomeController < BaseOrigamiController @payment_methods = PaymentMethodSetting.all @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") #@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'") - @order_items = Array.new + @order_items = Array.new @dining_booking.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new @@ -144,6 +145,7 @@ class Origami::HomeController < BaseOrigamiController end end end + end def check_emp_access_code diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 794908fa..37d3daa1 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -641,12 +641,25 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(sale_id) # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - unique_code = "ReceiptBillPdf" + # unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) #shop detail #shop_detail = Shop.first + printer = PrintSetting.all + unique_code="ReceiptBillPdf" + if !printer.empty? + printer.each do |printer_setting| + if printer_setting.unique_code == 'ReceiptBillPdf' + unique_code="ReceiptBillPdf" + elsif printer_setting.unique_code == 'ReceiptBillA5Pdf' + unique_code="ReceiptBillA5Pdf" + elsif printer_setting.unique_code == 'ReceiptBillStarPdf' + unique_code="ReceiptBillStarPdf" + end + end + end # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index f13d0dab..8fb6895c 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -30,13 +30,15 @@ class Origami::QuickServiceController < ApplicationController end #checked quick_service only - @quick_service_only = true - lookup_dine_in = Lookup.collection_of('dinein_cashier') + @quick_service_only = false + lookup_dine_in = Lookup.collection_of('quickservice_add_order') + puts 'lookup_dine_in!!!!' + puts lookup_dine_in if !lookup_dine_in.empty? lookup_dine_in.each do |dine_in| - if dine_in[0].downcase == "dineincashier" + if dine_in[0].downcase == "quickserviceaddorder" if dine_in[1] == '1' - @quick_service_only = false + @quick_service_only = true end end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index e1cec136..422e1372 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -28,7 +28,7 @@ class Origami::RequestBillsController < ApplicationController if check_booking.sale_id.nil? # Create Sale if it doesn't exist - @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source) + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source, params[:current_checkin_induties_count]) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) @@ -38,6 +38,7 @@ class Origami::RequestBillsController < ApplicationController in_duties.each do |in_duty| induty = InDuty.find(in_duty.id) induty.sale_id = @sale_id + induty.out_time =Time.now.utc induty.save end end diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index c7311fd6..5d4cf991 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -120,7 +120,7 @@ class Origami::SplitBillController < BaseOrigamiController if booking if booking.sale_id.nil? sale = Sale.new - status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type) + status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type,params[:current_checkin_induties_count]) sale_data = Sale.find_by_sale_id(sale_id) else status = true @@ -333,7 +333,7 @@ class Origami::SplitBillController < BaseOrigamiController end sale = Sale.new - status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type) + status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type ,params[:current_checkin_induties_count]) end Promotion.promo_activate(sale) diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index e2c3250e..75bb7074 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -28,7 +28,7 @@ class Origami::VoidController < BaseOrigamiController shift.save end end - + sale.rounding_adjustment = 0.0 sale.payment_status = 'void' sale.sale_status = 'void' @@ -71,16 +71,16 @@ class Origami::VoidController < BaseOrigamiController table = nil end - # FOr Sale Audit + # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name end - + # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" ) - # For Print + # For Print member_info = nil rebate_amount = nil @@ -88,7 +88,7 @@ class Origami::VoidController < BaseOrigamiController # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") - if bookings.count > 1 + if bookings.count > 1 # for Multiple Booking if bookings[0].dining_facility_id.to_i>0 table = DiningFacility.find(bookings[0].dining_facility_id) @@ -102,12 +102,20 @@ class Origami::VoidController < BaseOrigamiController shift = ShiftSale.find(sale.shift_sale_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) end - + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - unique_code = "ReceiptBillPdf" + # get printer info + # print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf + # + # if !print_settings.nil? + # unique_code = 'ReceiptBillPdf' + # elsif + # unique_code = 'ReceiptBillStarPdf' + # end + customer= Customer.find(sale.customer_id) - + #shop detail shop_details = current_shop # get member information @@ -119,34 +127,48 @@ class Origami::VoidController < BaseOrigamiController current_balance = 0 end + printer = PrintSetting.all + + unique_code="ReceiptBillPdf" + if !printer.empty? + printer.each do |printer_setting| + if printer_setting.unique_code == 'ReceiptBillPdf' + unique_code="ReceiptBillPdf" + elsif printer_setting.unique_code == 'ReceiptBillA5Pdf' + unique_code="ReceiptBillA5Pdf" + elsif printer_setting.unique_code == 'ReceiptBillStarPdf' + unique_code="ReceiptBillStarPdf" + end + end + end # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) - result = { - :filepath => filename, - :printer_model => print_settings.brand_name, - :printer_url => print_settings.api_settings + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings } # Mobile Print render :json => result.to_json # end - + #end print # update complete order items in oqs - SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| + SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| aoi.delivery_status = 1 aoi.save end end end - end - -end \ No newline at end of file + end + +end diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 82c62a7e..92720467 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -18,7 +18,7 @@ class Origami::WasteSpoileController < BaseOrigamiController # sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source) # add to sale item with foc # sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null") - + sale.sale_items.each do|item| # SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price) item.status = remark @@ -53,7 +53,7 @@ class Origami::WasteSpoileController < BaseOrigamiController table = nil end - # FOr Sale Audit + # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name @@ -61,7 +61,7 @@ class Origami::WasteSpoileController < BaseOrigamiController # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark ) - # For Print + # For Print member_info = nil rebate_amount = nil @@ -69,7 +69,7 @@ class Origami::WasteSpoileController < BaseOrigamiController # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") - if bookings.count > 1 + if bookings.count > 1 # for Multiple Booking if bookings[0].dining_facility_id.to_i>0 table = DiningFacility.find(bookings[0].dining_facility_id) @@ -83,12 +83,12 @@ class Origami::WasteSpoileController < BaseOrigamiController shift = ShiftSale.find(sale.shift_sale_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) end - + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - unique_code = "ReceiptBillPdf" + # unique_code = "ReceiptBillPdf" customer= Customer.find(sale.customer_id) - + #shop detail shop_details = current_shop # get member information @@ -100,34 +100,49 @@ class Origami::WasteSpoileController < BaseOrigamiController current_balance = 0 end + printer = PrintSetting.all + + unique_code="ReceiptBillPdf" + if !printer.empty? + printer.each do |printer_setting| + if printer_setting.unique_code == 'ReceiptBillPdf' + unique_code="ReceiptBillPdf" + elsif printer_setting.unique_code == 'ReceiptBillA5Pdf' + unique_code="ReceiptBillA5Pdf" + elsif printer_setting.unique_code == 'ReceiptBillStarPdf' + unique_code="ReceiptBillStarPdf" + end + end + end + # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil) - result = { - :filepath => filename, - :printer_model => print_settings.brand_name, - :printer_url => print_settings.api_settings + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings } # Mobile Print render :json => result.to_json # end - + #end print # update complete order items in oqs - SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| + SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| aoi.delivery_status = 1 aoi.save end end end - end - -end \ No newline at end of file + end + +end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 5c4f3e68..5e2fbc23 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -77,6 +77,7 @@ authorize_resource :class => false # url = "http://192.168.1.176:3000/en/api/sync_data" url = Lookup.sync_url token = Lookup.get_sync_token + @message = '' # token = Lookup.token unless url.nil? and token.nil? @@ -118,11 +119,12 @@ authorize_resource :class => false puts url puts response - end + @message = @result.parsed_response['message'] + end - respond_to do |format| - format.html { redirect_to '/en/reports/receipt_no/', notice: 'Sync Record Completed.'} - end + respond_to do |format| + format.html { redirect_to '/en/reports/receipt_no/', notice: @message} + end end end \ No newline at end of file diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 5beb919e..b581eae8 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -130,6 +130,11 @@ class Reports::SaleitemController < BaseReportController print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf') + # if print_settings.nil? && print_settings_star.nil? + # @print_setting = PrintSetting.new(name: "SaleItemsPdf", unique_code: "SaleItemsPdf", template: "",font: "Zawgyi-One", header_font_size: "10", item_font_size: "8", printer_name: "", api_settings: "", brand_name: nil, printer_type: nil, page_width: "210", page_height: "1450", print_copies: "1", precision: "0", delimiter: "0", heading_space: "5" ) + # @print_setting.save + # end + if print_settings.nil? if !print_settings_star.nil? printer = Printer::CashierStationPrinter.new(print_settings_star) diff --git a/app/controllers/settings/commissioners_controller.rb b/app/controllers/settings/commissioners_controller.rb index fb8c1993..bbaa1ca8 100755 --- a/app/controllers/settings/commissioners_controller.rb +++ b/app/controllers/settings/commissioners_controller.rb @@ -18,6 +18,7 @@ class Settings::CommissionersController < ApplicationController def new @commissioner = Commissioner.new @employee = Employee.all.order('name asc') + end # GET /commissioners/1/edit @@ -35,14 +36,21 @@ class Settings::CommissionersController < ApplicationController unless @commissioner.resigned_date.nil? @commissioner.resigned_date = @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d') end - respond_to do |format| - if @commissioner.save - format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully created.'} - format.json {render :show, status: :created, location: @commissioner} - else - format.html {render :new} - format.json {render json: @commissioner.errors, status: :unprocessable_entity} + # puts params[:from_induty].length + if (params[:from_induty] != "true") + respond_to do |format| + if @commissioner.save + format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully created.'} + format.json {render :show, status: :created, location: @commissioner} + else + format.html {render :new} + format.json {render json: @commissioner.errors, status: :unprocessable_entity} + end end + else + @commissioner.save + flash[:notice] = 'Commissioner was successfully created.' + redirect_to induties_assign_in_duties_path(params[:booking_id]) end end diff --git a/app/helpers/induties/assign_in_duties_helper.rb b/app/helpers/induties/assign_in_duties_helper.rb new file mode 100644 index 00000000..bb55d3b4 --- /dev/null +++ b/app/helpers/induties/assign_in_duties_helper.rb @@ -0,0 +1,2 @@ +module Induties::AssignInDutiesHelper +end diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb index 8f1d0694..1fd1e4a2 100755 --- a/app/models/assigned_order_item.rb +++ b/app/models/assigned_order_item.rb @@ -9,20 +9,22 @@ class AssignedOrderItem < ApplicationRecord def self.sync_assigned_order_item_records(assigned_order_items) if !assigned_order_items.nil? - assigned_order_items.each do |items| - unless AssignedOrderItem.exists?(items['assigned_order_item_id']) + assigned_order_items.each do |item| + order_item = AssignedOrderItem.find_by_assigned_order_item_id(item['assigned_order_item_id']) + # unless AssignedOrderItem.exists?(item['assigned_order_item_id']) + if order_item.nil? order_item = AssignedOrderItem.new - order_item.assigned_order_item_id = item['assigned_order_item_id'] - order_item.item_code = item['item_code'] - order_item.instance_code = item['instance_code'] - order_item.order_queue_station_id = item['order_queue_station_id'] - order_item.order_id = item['order_id'] - order_item.print_status = item['print_status'] - order_item.delivery_status = item['delivery_status'] - order_item.save - puts '....... Assigned Order Item has been created .......' end + order_item.assigned_order_item_id = item['assigned_order_item_id'] + order_item.item_code = item['item_code'] + order_item.instance_code = item['instance_code'] + order_item.order_queue_station_id = item['order_queue_station_id'] + order_item.order_id = item['order_id'] + order_item.print_status = item['print_status'] + order_item.delivery_status = item['delivery_status'] + order_item.save end + puts '....... Assigned Order Item sync completed .......' end end diff --git a/app/models/booking.rb b/app/models/booking.rb index 01684ab2..374dd0cf 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -14,24 +14,26 @@ class Booking < ApplicationRecord def self.sync_booking_records(bookings) if !bookings.nil? bookings.each do |b| - unless TableBooking.exists?(b['booking_id']) + booking = TableBooking.find_by_booking_id(b['booking_id']) + # unless TableBooking.exists?(b['booking_id']) + if booking.nil? booking = TableBooking.new - booking.booking_id = b['booking_id'] - booking.dining_facility_id = b['dining_facility_id'] - booking.type = b['type'] - booking.checkin_at = b['checkin_at'] - booking.checkin_by = b['checkin_by'] - booking.checkout_at = b['checkout_at'] - booking.checkout_by = b['checkout_by'] - booking.reserved_at = b['reserved_at'] - booking.reserved_by = b['reserved_by'] - booking.booking_status = b['booking_status'] - booking.sale_id = b['sale_id'] - booking.customer_id = b['customer_id'] - booking.save - puts '....... Booking has been created ......' end + booking.booking_id = b['booking_id'] + booking.dining_facility_id = b['dining_facility_id'] + # booking.type = b['type'] + booking.checkin_at = b['checkin_at'] + booking.checkin_by = b['checkin_by'] + booking.checkout_at = b['checkout_at'] + booking.checkout_by = b['checkout_by'] + booking.reserved_at = b['reserved_at'] + booking.reserved_by = b['reserved_by'] + booking.booking_status = b['booking_status'] + booking.sale_id = b['sale_id'] + booking.customer_id = b['customer_id'] + booking.save end + puts '....... Booking sync completed ......' end end @@ -97,7 +99,7 @@ class Booking < ApplicationRecord .joins('left join sale_orders on sale_orders.order_id=assigned_order_items.order_id') .where('sale_orders.sale_id=?', sale_id) - @bookings = Booking.where('sale_id=?', sale_id) + @bookings = TableBooking.where('sale_id=?', sale_id) @sales = Sale.where("sale_id=?", sale_id) diff --git a/app/models/cashier_login_log.rb b/app/models/cashier_login_log.rb index 353e9c90..d8af4095 100755 --- a/app/models/cashier_login_log.rb +++ b/app/models/cashier_login_log.rb @@ -8,4 +8,4 @@ class CashierLoginLog < ApplicationRecord def generate_custom_id self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO") end -end +end \ No newline at end of file diff --git a/app/models/commission.rb b/app/models/commission.rb index 32aa8a04..74a830a9 100755 --- a/app/models/commission.rb +++ b/app/models/commission.rb @@ -13,6 +13,6 @@ class Commission < ApplicationRecord scope :active, -> {where(is_active: true)} private def generate_custom_id - self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM') + self.commission_id = SeedGenerator.generate_id(self.class.name, "COM") end end diff --git a/app/models/commissioner.rb b/app/models/commissioner.rb index 68573460..eb32f0bb 100755 --- a/app/models/commissioner.rb +++ b/app/models/commissioner.rb @@ -1,7 +1,7 @@ class Commissioner < ApplicationRecord belongs_to :employee, foreign_key: 'emp_id' belongs_to :commission, foreign_key: 'commission_id' - has_many :in_juties + has_many :in_duties has_many :product_commissions scope :active, -> { where(is_active: true) } diff --git a/app/models/dining_charge.rb b/app/models/dining_charge.rb index 2a351778..6f931bcf 100755 --- a/app/models/dining_charge.rb +++ b/app/models/dining_charge.rb @@ -20,7 +20,7 @@ class DiningCharge < ApplicationRecord block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'day') end end - return block_count, price + return block_count, price else puts "<<<<<<<< NO" end @@ -34,7 +34,6 @@ class DiningCharge < ApplicationRecord charge_block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.strftime('%H:%M')) result = dining_minutes / charge_block - rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.strftime('%H:%M')) if result.to_i < 1 # for dining minute is under charge_block diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 260333e7..0edc3dab 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -32,7 +32,8 @@ class DiningFacility < ApplicationRecord end def get_current_booking - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null + checkin_time_lookup = Lookup.get_checkin_time_limit + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_by is null").limit(1) #and checkout_at is null if booking.count > 0 then return booking[0] @@ -42,7 +43,8 @@ class DiningFacility < ApplicationRecord end def get_moved_booking - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + checkin_time_lookup = Lookup.get_checkin_time_limit + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) if booking.count > 0 then return booking[0] @@ -68,7 +70,8 @@ class DiningFacility < ApplicationRecord end def get_current_checkout_booking - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1) + checkin_time_lookup = Lookup.get_checkin_time_limit + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1) if booking.count > 0 then return booking[0] else @@ -115,7 +118,8 @@ class DiningFacility < ApplicationRecord end def self.get_checkin_booking - bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null") + checkin_time_lookup = Lookup.get_checkin_time_limit + bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null") arr_booking = Array.new if bookings lookup_checkout_time = Lookup.collection_of("checkout_alert_time") diff --git a/app/models/induties.rb b/app/models/induties.rb new file mode 100644 index 00000000..a283db36 --- /dev/null +++ b/app/models/induties.rb @@ -0,0 +1,5 @@ +module Induties + def self.table_name_prefix + 'induties_' + end +end diff --git a/app/models/induties/assign_in_duty.rb b/app/models/induties/assign_in_duty.rb new file mode 100644 index 00000000..3d63dd05 --- /dev/null +++ b/app/models/induties/assign_in_duty.rb @@ -0,0 +1,2 @@ +class Induties::AssignInDuty < ApplicationRecord +end diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb index 1a9dec8f..644f1e4e 100755 --- a/app/models/inventory_definition.rb +++ b/app/models/inventory_definition.rb @@ -4,6 +4,8 @@ class InventoryDefinition < ApplicationRecord def self.calculate_product_count(saleObj=nil,saleobj_after_req_bill=nil) if !saleObj.nil? + Rails.logger.debug "Hello count" + Rails.logger.debug saleObj.sale_items.count saleObj.sale_items.each do |item| found, inventory_definition = find_product_in_inventory(item) if found @@ -35,7 +37,7 @@ class InventoryDefinition < ApplicationRecord end def self.check_balance(item,inventory_definition) # item => saleItemOBj - stock = StockJournal.where('item_code=?', item.item_instance_code).order('created_at desc').take + stock = StockJournal.where('item_code=?', item.item_instance_code).last unless stock.nil? modify_balance(item, stock, inventory_definition) else @@ -77,7 +79,7 @@ class InventoryDefinition < ApplicationRecord def self.get_by_category(filter) least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock' - THEN (SELECT balance FROM stock_journals + THEN (SELECT min(balance) FROM stock_journals WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock' ORDER BY created_at DESC LIMIT 1) ELSE 0 END) FROM stock_journals diff --git a/app/models/kbz_pay.rb b/app/models/kbz_pay.rb new file mode 100644 index 00000000..2fb740f2 --- /dev/null +++ b/app/models/kbz_pay.rb @@ -0,0 +1,54 @@ +class KbzPay + + def self.pay(amount, receipt_no) + + datetime = DateTime.now.strftime("%d%m%Y%H%M") + kbz_app_id = "kp1e78f7efddca190042638341afb88d" + kbz_merch_code = "200004" + kbz_method = 'kbz.payment.precreate' + kbz_trade_type = "PAY_BY_QRCODE" + kbz_api_key = "code2lab123456" + kbz_version = "1.0" + kbz_provider_url = "http://api.kbzpay.com/payment/gateway/uat/precreate" + kbz_currency = "MMK" + kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback" + nounce_str = SecureRandom.base64(32).first(32).upcase + + params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"¬ify_url="+ kbz_callback_url + "×tamp="+datetime+"&total_amount="+amount.to_s+"&trade_type="+kbz_trade_type+"&trans_currency="+ kbz_currency+"&version="+kbz_version+"&key="+kbz_api_key + + Rails.logger.info params + sign = Digest::SHA256.hexdigest(params) + str = {"timestamp": datetime, + "method": kbz_method, + "notify_url": kbz_callback_url, + "nonce_str": nounce_str.to_s, + "sign_type": "SHA256", + "sign": sign, + "version": kbz_version, + "biz_content": { + "merch_order_id": receipt_no, + "merch_code": kbz_merch_code, + "appid": kbz_app_id, + "trade_type": kbz_trade_type, + "total_amount": amount.to_s, + "trans_currency": kbz_currency + } + } + + result = HTTParty.post(kbz_provider_url, + :body => { :Request => str}.to_json, + :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } + ) + Rails.logger.info result + if result['Response']['result'] == "SUCCESS" + #TODO QR return + qr = result['Response']['qrCode'] + return true, qr + else + return false, result['Response'] + puts result['Response'] + end + + end + +end diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 45762f74..2120cfe6 100755 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -21,14 +21,37 @@ class Lookup < ApplicationRecord # Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] } # end + def self.get_checkin_time_limit + time_limit = 5 + + lookup = Lookup.find_by_lookup_type('checkin_time_limit') + if !lookup.nil? + time_limit = lookup.value.to_i + end + + return time_limit + end + def self.sync_url + url = "" + lookup = Lookup.find_by_lookup_type('sync_data') - return lookup.value + if !lookup.nil? + url = lookup.value + end + + return url end def self.get_sync_token + token = "" + lookup = Lookup.find_by_lookup_type('sync_token') - return lookup.value + if !lookup.nil? + token = lookup.value + end + + return token end def self.collection_of(type) diff --git a/app/models/order.rb b/app/models/order.rb index 44dc3668..7ffeb82b 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -550,6 +550,10 @@ class Order < ApplicationRecord return false end + def self.env + return ENV["SERVER_MODE"] + end + private def generate_custom_id @@ -563,22 +567,24 @@ class Order < ApplicationRecord def self.sync_order_records(orders) if !orders.nil? orders.each do |o| - unless Order.exists?(o['order_id']) + order = Order.find_by_order_id(o['order_id']) + # unless Order.exists?(o['order_id']) + if order.nil? order = Order.new - order.order_id = o['order_id'] - order.date = o['date'] - order.source = o['source'] - order.order_type = o['order_type'] - order.customer_id = o['customer_id'] - order.item_count = o['item_count'] - order.quantity_count = o['quantity_count'] - order.status = o['status'] - order.waiters = o['waiters'] - order.guest_info = o['guest_info'] - order.save - puts '...... order has been created .....' end + order.order_id = o['order_id'] + order.date = o['date'] + order.source = o['source'] + order.order_type = o['order_type'] + order.customer_id = o['customer_id'] + order.item_count = o['item_count'] + order.quantity_count = o['quantity_count'] + order.status = o['status'] + order.waiters = o['waiters'] + order.guest_info = o['guest_info'] + order.save end + puts '...... order sync completed .....' end end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index c4c9067a..ec8d00a7 100755 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -68,28 +68,30 @@ class OrderItem < ApplicationRecord def self.sync_order_item_records(order_items) if !order_items.nil? order_items.each do |item| - unless OrderItem.exists?(item['order_items_id']) + order_item = OrderItem.find_by_order_items_id(item['order_items_id']) + # unless OrderItem.exists?(item['order_items_id']) + if order_item.nil? order_item = OrderItem.new - order_item.order_items_id = item['order_items_id'] - order_item.order_id = item['order_id'] - order_item.order_item_status = item['order_item_status'] - order_item.item_order_by = item['item_order_by'] - order_item.item_code = item['item_code'] - order_item.item_instance_code = item['item_instance_code'] - order_item.item_name = item['item_name'] - order_item.alt_name = item['alt_name'] - order_item.account_id = item['account_id'] - order_item.qty = item['qty'] - order_item.price = item['price'] - order_item.remark = item['remark'] - order_item.options = item['options'] - order_item.set_menu_items = item['set_menu_items'] - order_item.taxable = item['taxable'] - order_item.completed_by = item['completed_by'] - order_item.save - puts '...... order item has been created. .....' end + order_item.order_items_id = item['order_items_id'] + order_item.order_id = item['order_id'] + order_item.order_item_status = item['order_item_status'] + order_item.item_order_by = item['item_order_by'] + order_item.item_code = item['item_code'] + order_item.item_instance_code = item['item_instance_code'] + order_item.item_name = item['item_name'] + order_item.alt_name = item['alt_name'] + order_item.account_id = item['account_id'] + order_item.qty = item['qty'] + order_item.price = item['price'] + order_item.remark = item['remark'] + order_item.options = item['options'] + order_item.set_menu_items = item['set_menu_items'] + order_item.taxable = item['taxable'] + order_item.completed_by = item['completed_by'] + order_item.save end + puts '...... order item sync completed. .....' end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index d4122d59..ed14d884 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -11,11 +11,11 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker options = order_item[0].options # filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf" - pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty) + # pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty) print_setting = PrintSetting.all # check for item not to show - + pdf = '' # if order_item[0].price != 0 if !print_setting.empty? print_setting.each do |print_settings| @@ -182,8 +182,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Print for orders in booking def print_booking_summary(print_settings,oqs, booking_id, print_status,before_updated_qty="") - puts 'PrintSetting!!!' - puts print_setting.print_copies # Must be one print if print_settings.print_copies == 0 print_settings.print_copies = 1 diff --git a/app/models/printer/printing_data.rb b/app/models/printer/printing_data.rb new file mode 100644 index 00000000..e69de29b diff --git a/app/models/printer/printservice.rb b/app/models/printer/printservice.rb new file mode 100644 index 00000000..e69de29b diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 83a8e6c6..04951a12 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -9,7 +9,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker if !printer.empty? printer.each do |printer_setting| - if printer_setting.unique_code == 'OrderItemPdf' + if printer_setting.unique_code == 'OrderItemPdf' pdf = OrderItemPdf.new elsif printer_setting.unique_code == 'OrderItemSlimPdf' pdf = OrderItemSlimPdf.new @@ -18,12 +18,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker elsif printer_setting.unique_code == 'OrderItemCustomisePdf' pdf = OrderItemCustomisePdf.new elsif printer_setting.unique_code == 'OrderSetItemCustomisePdf' - pdf = OrderSetItemCustomisePdf.new + pdf = OrderSetItemCustomisePdf.new elsif printer_setting.unique_code == 'OrderItemSlimCustomisePdf' pdf = OrderItemSlimCustomisePdf.new - end + end end - end + end pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf" #no print in cloud server if ENV["SERVER_MODE"] != "cloud" @@ -41,7 +41,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker if !printer.empty? printer.each do |printer_setting| - if printer_setting.unique_code == 'OrderSummaryPdf' + if printer_setting.unique_code == 'OrderSummaryPdf' pdf = OrderSummaryPdf.new elsif printer_setting.unique_code == 'OrderSummarySlimPdf' pdf = OrderSummarySlimPdf.new @@ -50,12 +50,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf' pdf = OrderSummaryCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf' - pdf = OrderSummarySetCustomisePdf.new + pdf = OrderSummarySetCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf' pdf = OrderSummarySlimCustomisePdf.new - end + end end - end + end pdf.render_file filename #no print in cloud server if ENV["SERVER_MODE"] != "cloud" @@ -72,7 +72,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker pdf = OrderSummaryPdf.new if !printer.empty? printer.each do |printer_setting| - if printer_setting.unique_code == 'OrderSummaryPdf' + if printer_setting.unique_code == 'OrderSummaryPdf' pdf = OrderSummaryPdf.new elsif printer_setting.unique_code == 'OrderSummarySlimPdf' pdf = OrderSummarySlimPdf.new @@ -81,12 +81,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf' pdf = OrderSummaryCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf' - pdf = OrderSummarySetCustomisePdf.new + pdf = OrderSummarySetCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf' pdf = OrderSummarySlimCustomisePdf.new - end + end end - end + end pdf.render_file filename #no print in cloud server if ENV["SERVER_MODE"] != "cloud" @@ -103,7 +103,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker pdf = OrderSummaryPdf.new if !printer.empty? printer.each do |printer_setting| - if printer_setting.unique_code == 'OrderSummaryPdf' + if printer_setting.unique_code == 'OrderSummaryPdf' pdf = OrderSummaryPdf.new elsif printer_setting.unique_code == 'OrderSummarySlimPdf' pdf = OrderSummarySlimPdf.new @@ -112,12 +112,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf' pdf = OrderSummaryCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf' - pdf = OrderSummarySetCustomisePdf.new + pdf = OrderSummarySetCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf' pdf = OrderSummarySlimCustomisePdf.new - end + end end - end + end pdf.render_file filename #no print in cloud server if ENV["SERVER_MODE"] != "cloud" @@ -134,7 +134,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker pdf = OrderSummaryPdf.new if !printer.empty? printer.each do |printer_setting| - if printer_setting.unique_code == 'OrderSummaryPdf' + if printer_setting.unique_code == 'OrderSummaryPdf' pdf = OrderSummaryPdf.new elsif printer_setting.unique_code == 'OrderSummarySlimPdf' pdf = OrderSummarySlimPdf.new @@ -143,12 +143,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf' pdf = OrderSummaryCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf' - pdf = OrderSummarySetCustomisePdf.new + pdf = OrderSummarySetCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf' pdf = OrderSummarySlimCustomisePdf.new - end + end end - end + end pdf.render_file filename #no print in cloud server if ENV["SERVER_MODE"] != "cloud" @@ -165,7 +165,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker pdf = OrderSummaryPdf.new if !printer.empty? printer.each do |printer_setting| - if printer_setting.unique_code == 'OrderSummaryPdf' + if printer_setting.unique_code == 'OrderSummaryPdf' pdf = OrderSummaryPdf.new elsif printer_setting.unique_code == 'OrderSummarySlimPdf' pdf = OrderSummarySlimPdf.new @@ -174,12 +174,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf' pdf = OrderSummaryCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf' - pdf = OrderSummarySetCustomisePdf.new + pdf = OrderSummarySetCustomisePdf.new elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf' pdf = OrderSummarySlimCustomisePdf.new - end + end end - end + end pdf.render_file filename #no print in cloud server if ENV["SERVER_MODE"] != "cloud" @@ -191,7 +191,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) #Use CUPS service #Generate PDF - #Print + #Print if !printer_settings.nil? if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder") pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) @@ -205,11 +205,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end end end - + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf if !receipt_bill_a5_pdf.empty? receipt_bill_a5_pdf.each do |receipt_bilA5| - if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) # else @@ -222,7 +222,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker #doemal online order pdf template pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) end - + # print as print copies in printer setting count = printer_settings.print_copies diff --git a/app/models/reservation_item.rb b/app/models/reservation_item.rb index 19e28b82..6329f24e 100644 --- a/app/models/reservation_item.rb +++ b/app/models/reservation_item.rb @@ -7,7 +7,7 @@ class ReservationItem < ApplicationRecord belongs_to :reservation, autosave: true private - def generate_custom_id - self.reservation_items_id = SeedGenerator.generate_id(self.class.name, "RSI") - end + def generate_custom_id + self.reservation_items_id = SeedGenerator.generate_id(self.class.name, "RSI") + end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 3512e827..a00361aa 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -26,43 +26,43 @@ class Sale < ApplicationRecord } SALE_STATUS_OUTSTANDING = "outstanding" SALE_STATUS_COMPLETED = "completed" - def self.sync_sale_records(sales) if !sales.nil? sales.each do |s| - unless Sale.exists?(s['sale_id']) + sale = Sale.find_by_sale_id(s['sale_id']) + # unless Sale.exists?(s['sale_id']) + if sale.nil? sale = Sale.new - sale.sale_id = s['sale_id'] - sale.cashier_id = s['cashier_id'] - sale.cashier_name = s['cashier_name'] - sale.requested_by = s['requested_by'] - sale.requested_at = s['requested_at'] - sale.receipt_no = s['receipt_no'] - sale.receipt_date = s['receipt_date'] - sale.customer_id = s['customer_id'] - sale.payment_status = s['payment_status'] - sale.sale_status = s['sale_status'] - sale.total_amount = s['total_amount'] - sale.discount_type = s['discount_type'] - sale.total_tax = s['total_tax'] - sale.total_discount = s['total_discount'] - sale.tax_type = s['tax_type'] - sale.grand_total = s['grand_total'] - sale.rounding_adjustment = s['rounding_adjustment'] - sale.amount_received = s['amount_received'] - sale.amount_changed = s['amount_changed'] - sale.shift_sale_id = s['shift_sale_id'] - sale.old_grand_total = s['old_grand_total'] - sale.rebate_status = s['rebate_status'] - sale.equal_persons = s['equal_persons'] - sale.save - puts '........ Sale data has been created .......' end + sale.sale_id = s['sale_id'] + sale.cashier_id = s['cashier_id'] + sale.cashier_name = s['cashier_name'] + sale.requested_by = s['requested_by'] + sale.requested_at = s['requested_at'] + sale.receipt_no = s['receipt_no'] + sale.receipt_date = s['receipt_date'] + sale.customer_id = s['customer_id'] + sale.payment_status = s['payment_status'] + sale.sale_status = s['sale_status'] + sale.total_amount = s['total_amount'] + sale.discount_type = s['discount_type'] + sale.total_tax = s['total_tax'] + sale.total_discount = s['total_discount'] + sale.tax_type = s['tax_type'] + sale.grand_total = s['grand_total'] + sale.rounding_adjustment = s['rounding_adjustment'] + sale.amount_received = s['amount_received'] + sale.amount_changed = s['amount_changed'] + sale.shift_sale_id = s['shift_sale_id'] + sale.old_grand_total = s['old_grand_total'] + sale.rebate_status = s['rebate_status'] + sale.equal_persons = s['equal_persons'] + sale.save end + puts '........ Sale data sync completed .......' end end - - def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil) + def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil, current_checkin_induties_count) booking = Booking.find(booking_id) status = false Rails.logger.debug "Booking -> " + booking.id.to_s @@ -91,9 +91,22 @@ class Sale < ApplicationRecord else dining_time = booking.checkin_at.strftime('%B %d, %H:%M %p').to_s + " - " + booking.checkout_at.strftime('%B %d, %H:%M %p').to_s end + later_time = booking.checkout_at + early_time = booking.checkin_at + distance_in_minutes = ((later_time - early_time)/60.0).round + basic_pay_amount =0 + name ="" + if current_checkin_induties_count != "0" + basic_pay = Commission.where('commission_type=?','Basic Pay') + basic_pay.each do |pay| + basic_pay_amount =pay.amount + name =pay.name + end + induties_pay_amount = (current_checkin_induties_count.to_i * (distance_in_minutes / 60.0).to_f * basic_pay_amount).to_i + create_saleitem_indutycharges(charges, current_checkin_induties_count.to_i, induties_pay_amount, booking.dining_facility.name, dining_time, order_source, basic_pay_amount) + end create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source) end - return status, sale_id end end @@ -365,7 +378,25 @@ class Sale < ApplicationRecord sale = Sale.find(self.id) self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source) end - + def create_saleitem_indutycharges(chargeObj, current_checkin_induties_count, induties_pay_amount, dining_name, dining_time, order_source = nil, basic_pay_amount) + sale_item = SaleItem.new + sale_item.menu_category_code = "IndutyCharge" + sale_item.menu_category_name = "Induty Charge" + sale_item.product_code = "" + sale_item.product_name ='Vocalist' + " ( " + dining_time.to_s + " )" + sale_item.account_id = 0 + sale_item.product_alt_name = "-" + sale_item.qty = current_checkin_induties_count + sale_item.unit_price = basic_pay_amount + sale_item.taxable_price = induties_pay_amount + sale_item.is_taxable = chargeObj.taxable + sale_item.sale_id = self.id + sale_item.price = induties_pay_amount + sale_item.save + # Re-calc + sale = Sale.find(self.id) + self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source) + end def update_item (item) #save sale_audit diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index ef31085e..471873e7 100755 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -9,20 +9,22 @@ class SaleAudit < ApplicationRecord def self.sync_sale_audit_records(sale_audits) if !sale_audits.nil? sale_audits.each do |sa| - unless SaleAudit.exists?(sa['sale_audit_id']) + sale_audit = SaleAudit.find_by_sale_audit_id(sa['sale_audit_id']) + # unless SaleAudit.exists?(sa['sale_audit_id']) + if sale_audit.nil? sale_audit = SaleAudit.new - sale_audit.sale_audit_id = sa['sale_audit_id'] - sale_audit.sale_id = sa['sale_id'] - sale_audit.action = sa['action'] - sale_audit.action_at = sa['action_at'] - sale_audit.action_by = sa['action_by'] - sale_audit.approved_by = sa['approved_by'] - sale_audit.approved_at = sa['approved_at'] - sale_audit.remark = sa['remark'] - sale_audit.save - puts '....... Sale Audit has been created .......' end + sale_audit.sale_audit_id = sa['sale_audit_id'] + sale_audit.sale_id = sa['sale_id'] + sale_audit.action = sa['action'] + sale_audit.action_at = sa['action_at'] + sale_audit.action_by = sa['action_by'] + sale_audit.approved_by = sa['approved_by'] + sale_audit.approved_at = sa['approved_at'] + sale_audit.remark = sa['remark'] + sale_audit.save end + puts '....... Sale Audit sync completed .......' end end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 5cb3f4e6..86e9cabc 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -29,28 +29,30 @@ class SaleItem < ApplicationRecord def self.sync_sale_item_records(sale_items) if !sale_items.nil? sale_items.each do |si| - unless SaleItem.exists?(si['sale_item_id']) + sale_item = SaleItem.find_by_sale_item_id(si['sale_item_id']) + # unless SaleItem.exists?(si['sale_item_id']) + if sale_item.nil? sale_item = SaleItem.new - sale_item.sale_item_id = si['sale_item_id'] - sale_item.sale_id = si['sale_id'] - sale_item.menu_category_code = si['menu_category_code'] - sale_item.menu_category_name = si['menu_category_name'] - sale_item.product_code = si['product_code'] - sale_item.product_name = si['product_name'] - sale_item.product_alt_name = si['product_alt_name'] - sale_item.item_instance_code = si['item_instance_code'] - sale_item.account_id = si['account_id'] - sale_item.status = si['status'] - sale_item['remark'] = si['remark'] - sale_item['qty'] = si['qty'] - sale_item['unit_price'] = si['unit_price'] - sale_item['taxable_price'] = si['taxable_price'] - sale_item['price'] = si['price'] - sale_item['is_taxable'] = si['is_taxable'] - sale_item.save - puts '....... Sale Item has been created ......' end - end + sale_item.sale_item_id = si['sale_item_id'] + sale_item.sale_id = si['sale_id'] + sale_item.menu_category_code = si['menu_category_code'] + sale_item.menu_category_name = si['menu_category_name'] + sale_item.product_code = si['product_code'] + sale_item.product_name = si['product_name'] + sale_item.product_alt_name = si['product_alt_name'] + sale_item.item_instance_code = si['item_instance_code'] + sale_item.account_id = si['account_id'] + sale_item.status = si['status'] + sale_item['remark'] = si['remark'] + sale_item['qty'] = si['qty'] + sale_item['unit_price'] = si['unit_price'] + sale_item['taxable_price'] = si['taxable_price'] + sale_item['price'] = si['price'] + sale_item['is_taxable'] = si['is_taxable'] + sale_item.save + end + puts '....... Sale Item sync completed ......' end end diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index 03a2926a..fd2b9239 100755 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -17,22 +17,29 @@ class SaleOrder < ApplicationRecord def self.sync_sale_order_records(sale_orders) if !sale_orders.nil? sale_orders.each do |so| - unless SaleOrder.exists?(so['sale_order_id']) + sale_order = SaleOrder.find_by_sale_order_id(so['sale_order_id']) + # unless SaleOrder.exists?(so['sale_order_id']) + if sale_order.nil? sale_order = SaleOrder.new - sale_order.sale_order_id = so['sale_order_id'] - sale_order.sale_id = so['sale_id'] - sale_order.order_id = so['order_id'] - sale_order.save - puts '......... Sale Order has been created ........' end + sale_order.sale_order_id = so['sale_order_id'] + sale_order.sale_id = so['sale_id'] + sale_order.order_id = so['order_id'] + sale_order.save end + puts '......... Sale Order sync completed ........' end end private def generate_sale_order_id + prefix = "SOI" + if ENV["SERVER_MODE"] == 'cloud' + prefix = "CSOI" + end + self.class.name - saleOrderId = SeedGenerator.generate_id(self.class.name, "SOI") + saleOrderId = SeedGenerator.generate_id(self.class.name, prefix) self.sale_order_id = saleOrderId end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index e3ba3379..1cfb53f3 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -11,19 +11,21 @@ class SalePayment < ApplicationRecord def self.sync_sale_payment_records(sale_payments) if !sale_payments.nil? sale_payments.each do |sp| - unless SalePayment.exists?(sp['sale_payment_id']) + payment = SalePayment.find_by_sale_payment_id(sp['sale_payment_id']) + # unless SalePayment.exists?(sp['sale_payment_id']) + if payment.nil? payment = SalePayment.new - payment.sale_payment_id = sp['sale_payment_id'] - payment.sale_id = sp['sale_id'] - payment.payment_method = sp['payment_method'] - payment.payment_amount = sp['payment_amount'] - payment.outstanding_amount = sp['outstanding_amount'] - payment.payment_reference = sp['payment_reference'] - payment.payment_status = sp['payment_status'] - payment.save - puts '....... Sale Payment has been created ......' end + payment.sale_payment_id = sp['sale_payment_id'] + payment.sale_id = sp['sale_id'] + payment.payment_method = sp['payment_method'] + payment.payment_amount = sp['payment_amount'] + payment.outstanding_amount = sp['outstanding_amount'] + payment.payment_reference = sp['payment_reference'] + payment.payment_status = sp['payment_status'] + payment.save end + puts '....... Sale Payment sync completed ......' end end @@ -42,7 +44,7 @@ class SalePayment < ApplicationRecord invoice_sale_payments = invoice.sale_payments amount_due = invoice.grand_total end - + invoice_sale_payments.each do |payment| if (payment.payment_status == "paid" ) amount_due = amount_due - payment.payment_amount @@ -55,7 +57,7 @@ class SalePayment < ApplicationRecord #route to payment type case payment_method when "cash" - payment_status = cash_payment(payment_for) + payment_status ,outstanding_amount ,balance_amount = cash_payment(payment_for) when "creditnote" if !self.sale.customer_id.nil? payment_status = creditnote_payment(self.customer_id) @@ -88,6 +90,8 @@ class SalePayment < ApplicationRecord payment_status,membership_data = dinga_payment when "GiftVoucher" payment_status = giftvoucher_payment + when "KbzPay" + payment_status = giftvoucher_payment else puts "it was something else" end @@ -103,7 +107,7 @@ class SalePayment < ApplicationRecord shift = ShiftSale.current_shift shift_sale_id = shift.id end - + remark = "#{self.sale_payment_id}||#{shift_sale_id} -> #{remark}" sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by.name) @@ -125,7 +129,7 @@ class SalePayment < ApplicationRecord # end end - return true, self.save,membership_data + return true, self.save,membership_data, outstanding_amount ,balance_amount else #record an payment in sale-audit remark = "Payment failed - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]" @@ -330,7 +334,7 @@ class SalePayment < ApplicationRecord if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay" return true; end - end + end end private @@ -340,7 +344,7 @@ class SalePayment < ApplicationRecord if sale_payments_data.nil? status = true end - + payment_status = false self.payment_method = "cash" self.payment_amount = self.received_amount @@ -355,7 +359,16 @@ class SalePayment < ApplicationRecord if !payment_for sale_update_payment_status(self.received_amount,status) end - return payment_status + balance_amount =0.0 + outstanding_amount =0.0 + if self.sale.grand_total.to_f > self.received_amount.to_f + balance_amount = self.sale.grand_total.to_f - self.received_amount.to_f + outstanding_amount = 0.0 + else + balance_amount = 0.0 + outstanding_amount = self.received_amount.to_f - self.sale.grand_total.to_f + end + return payment_status , outstanding_amount.to_i, balance_amount.to_i end def foc_payment @@ -363,7 +376,7 @@ class SalePayment < ApplicationRecord # add to sale item with foc sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'") - + sale_items.each do|item| SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price) end @@ -374,11 +387,11 @@ class SalePayment < ApplicationRecord self.outstanding_amount = 0.00 self.payment_status = "paid" payment_status = self.save! - # sale_update_payment_status(self.received_amount) - sale_update_payment_status(0) + # sale_update_payment_status(self.received_amount) + sale_update_payment_status(0) return payment_status end - + def creditnote_payment(customer_id) payment_status = false @@ -393,7 +406,7 @@ class SalePayment < ApplicationRecord return payment_status end - def external_terminal_card_payment(method, payment_for=false) + def external_terminal_card_payment(method, payment_for=false) payment_status = false self.payment_method = method self.payment_amount = self.received_amount @@ -571,7 +584,16 @@ class SalePayment < ApplicationRecord return payment_status end - def sale_update_payment_status(paid_amount,check_foc = false) + def kbz_payment + payment_status = false + status, response = KbzPay.pay(amount, receipt_no) + if status + payment_status = true + return + end + end + + def sale_update_payment_status(paid_amount,check_foc = false) #update amount_outstanding self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f self.sale.save! @@ -606,12 +628,12 @@ class SalePayment < ApplicationRecord else self.sale.payment_status = "foc" end - + self.sale.sale_status = "completed" if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0 response = rebat(sObj) - + #record an payment in sale-audit remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " sale_audit = SaleAudit.record_paymal(sObj.sale_id, remark, 1) @@ -634,7 +656,7 @@ class SalePayment < ApplicationRecord end self.sale.save! - + if check_foc table_update_status(sObj) update_shift @@ -650,13 +672,13 @@ class SalePayment < ApplicationRecord # update for cashier shift def update_shift - + shift = ShiftSale.current_open_shift(self.action_by.id) if shift.nil? shift = ShiftSale.current_open_shift(self.sale.cashier_id) end - + if !shift.nil? shift.update(self.sale) self.sale.shift_sale_id = shift.id @@ -684,7 +706,7 @@ class SalePayment < ApplicationRecord else # extra_changed_amount = self.received_amount.to_f + credit_payment_left shift.cash_sales = shift.cash_sales.to_f + (self.received_amount.to_f + credit_payment_left) - + self.sale.amount_received = self.sale.amount_received.to_f - credit_payment_left self.sale.amount_changed = self.sale.amount_changed.to_f - credit_payment_left self.sale.save! @@ -696,7 +718,7 @@ class SalePayment < ApplicationRecord shift.credit_sales = shift.credit_sales.to_f - self.received_amount.to_f else shift.credit_sales = shift.credit_sales.to_f - (self.received_amount.to_f + credit_payment_left) - end + end shift.save end end @@ -712,7 +734,7 @@ class SalePayment < ApplicationRecord bookings.each do |tablebooking| if tablebooking.booking_status != 'moved' if tablebooking.sale_id - if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste' + if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste' status = false sale_count += 1 else @@ -736,7 +758,7 @@ class SalePayment < ApplicationRecord #if ENV["SERVER_MODE"] != 'cloud' # if ENV["SERVER_MODE"] == 'cloud' # from = request.subdomain + "." + request.domain - # else + # else # from = "" # end # ActionCable.server.broadcast "order_channel",table: table,type:type,from:from @@ -765,7 +787,7 @@ class SalePayment < ApplicationRecord end # overall_dis = SaleItem.get_overall_discount(sObj.id) overall_dis = sObj.total_discount - + if credit != 1 membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("get_member_campaign") @@ -776,8 +798,8 @@ class SalePayment < ApplicationRecord # Control for Paypar Cloud begin - response = HTTParty.get(url, - :body => { + response = HTTParty.get(url, + :body => { member_group_id:sObj.customer.membership_type, merchant_uid:merchant_uid, campaign_type_id: campaign_type_id, @@ -791,7 +813,7 @@ class SalePayment < ApplicationRecord response = { "status": false , "message": " Connection timeout" } rescue OpenURI::HTTPError response = { "status": false, "message": "Can't connect server"} - + rescue SocketError response = { "status": false, "message": "Can't connect server"} end @@ -811,7 +833,7 @@ class SalePayment < ApplicationRecord if cm[:amount] > 0 data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i} total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i - + type_arr.push(data) end end @@ -823,7 +845,7 @@ class SalePayment < ApplicationRecord Rails.logger.debug type_arr.to_json rebate_arr =[] - + campaign_method.each do |a| data = {:type => a[:type], :amount => a[:amount]} type_arr.each do |si| @@ -835,14 +857,14 @@ class SalePayment < ApplicationRecord actual = a[:amount].to_f - amount.to_f data[:amount] = actual end - + end end rebate_arr.push(data) end Rails.logger.debug "---------------Rebate Response----------------" Rails.logger.debug rebate_arr.to_json - + total_amount = rebate_prices - payparcost - overall_dis Rails.logger.debug total_amount @@ -861,8 +883,8 @@ class SalePayment < ApplicationRecord # Control for Paypar Cloud begin - response = HTTParty.post(url, - :body => { + response = HTTParty.post(url, + :body => { generic_customer_id:generic_customer_id , total_sale_transaction_amount: sObj.grand_total, merchant_uid:merchant_uid, @@ -880,7 +902,7 @@ class SalePayment < ApplicationRecord response = { "status": false , "message": "Connect To" } rescue OpenURI::HTTPError response = { "status": false, "message": "Can't connect server"} - + rescue SocketError response = { "status": false, "message": "Can't connect server"} end @@ -890,7 +912,7 @@ class SalePayment < ApplicationRecord end end else - response = { "status": "no_member", "message": "Not membership"} + response = { "status": "no_member", "message": "Not membership"} end end @@ -909,18 +931,18 @@ class SalePayment < ApplicationRecord order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=s.sale_id GROUP BY so.sale_id)" - query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id, - sale_payments.payment_method, + query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id, + sale_payments.payment_method, SUM(sale_payments.payment_amount) as payment_amount, s.receipt_date as sale_date, s.sale_id, s.cashier_name as cashier_name, c.name as customer_name") .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .joins("INNER JOIN customers c ON c.customer_id = s.customer_id") - + if params[:type].nil? query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") - elsif params[:type] == "cashier" + elsif params[:type] == "cashier" query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND #{order_source_query}='#{params[:type]}' OR #{order_source_query}='emenu' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") else query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND #{order_source_query}='#{params[:type]}' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") @@ -931,8 +953,8 @@ class SalePayment < ApplicationRecord end def self.get_credit_amount_due_left(sale_id) - query = SalePayment.select("(SUM(sale_payments.payment_amount) - - (CASE WHEN SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id + query = SalePayment.select("(SUM(sale_payments.payment_amount) - + (CASE WHEN SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id THEN SUM(sale_payments.payment_amount) ELSE 0 END)) as payment_amount") .joins(" LEFT JOIN sale_audits sa on SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id") .where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{sale_id}'") @@ -940,7 +962,7 @@ class SalePayment < ApplicationRecord end def self.get_credit_total_left(sale_id) - query = SalePayment.select("(SUM(sale_payments.payment_amount) - + query = SalePayment.select("(SUM(sale_payments.payment_amount) - (SELECT (CASE WHEN SUM(sale_payments.payment_amount) > 0 THEN SUM(sale_payments.payment_amount) ELSE 0 END) AS payment_amount FROM sale_payments INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id @@ -952,7 +974,7 @@ class SalePayment < ApplicationRecord def self.get_sale_payment_for_credit(sale_data) query = sale_data.sale_payments .joins(" JOIN sale_audits sa on SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id") - .where("sa.action='SALEPAYMENT' AND sa.remark IS NOT NULL + .where("sa.action='SALEPAYMENT' AND sa.remark IS NOT NULL AND DATE_FORMAT(sale_payments.created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(sale_payments.created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") #AND sale_payments.payment_method!='cash' .group("sale_payments.sale_payment_id") diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index 37159364..44622c24 100755 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -8,18 +8,20 @@ class SaleTax < ApplicationRecord def self.sync_sale_tax_records(sale_taxes) if !sale_taxes.nil? sale_taxes.each do |t| - unless SaleTax.exists?(t['sale_tax_id']) + tax = SaleTax.find_by_sale_tax_id(t['sale_tax_id']) + # unless SaleTax.exists?(t['sale_tax_id']) + if tax.nil? tax = SaleTax.new - tax.sale_tax_id = t['sale_tax_id'] - tax.sale_id = t['sale_id'] - tax.tax_name = t['tax_name'] - tax.tax_rate = t['tax_rate'] - tax.tax_payable_amount = t['tax_payable_amount'] - tax.inclusive = t['inclusive'] - tax.save - puts '...... Sale Tax has been created .....' end + tax.sale_tax_id = t['sale_tax_id'] + tax.sale_id = t['sale_id'] + tax.tax_name = t['tax_name'] + tax.tax_rate = t['tax_rate'] + tax.tax_payable_amount = t['tax_payable_amount'] + tax.inclusive = t['inclusive'] + tax.save end + puts '...... Sale Tax sync completed .....' end end diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 44160834..94b7217e 100755 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -1,15 +1,38 @@ class SeedGenerator < ApplicationRecord # Generate ID for Tables def self.generate_id(model, prefix) - cur_val, next_val = self.update_seed(model) + model_name = self.get_model_name(model) + + if ENV["SERVER_MODE"] == 'cloud' + prefix = "C#{prefix}" + end + + cur_val, next_val = self.update_seed(model_name) if (cur_val == 0) - cur_val, next_val = self.execute_query(model) - end + cur_val, next_val = self.execute_query(model_name) + end padding_len = 15 - prefix.length saleOrderId = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0') - return saleOrderId + return saleOrderId + end + + def self.sync_seed_generator_records(seed_generators) + if !seed_generators.nil? + seed_generators.each do |sg| + seed = SeedGenerator.find_by_model(sg['model']) + if seed.nil? + seed = SeedGenerator.new + end + seed.model = sg['model'] + seed.increase_by = sg['increase_by'] + seed.current = sg['current'] + seed.next = sg['next'] + seed.save + end + puts '....... Seed Generator sync completed! .......' + end end # Generate Receipt No for number order (1,2,3) Don't touch @@ -66,6 +89,17 @@ class SeedGenerator < ApplicationRecord # return next_code # end + def self.get_model_name(model) + model_name = "" + if ENV["SERVER_MODE"] == 'cloud' + model_name = "Cloud#{model}" + else + model_name = model + end + + return model_name + end + def self.execute_query(model) current = 0 nex = 0 diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 29f2f525..59294700 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -35,19 +35,18 @@ class ShiftSale < ApplicationRecord def self.sync_shift_sale_records(shift_sales) if !shift_sales.nil? shift_sales.each do |ss| - status = nil + # status = nil shift_sale = nil - if ShiftSale.exists?(ss['id']) - shift_sale = ShiftSale.find(ss['id']) - status = 'updated' - else + # if ShiftSale.exists?(ss['id']) + shift_sale = ShiftSale.find(ss['id']) + # status = 'updated' + if shift_sale.nil? shift_sale = ShiftSale.new - shift_sale.id = ss['id'] - - status = 'created' + # status = 'created' end + shift_sale.id = ss['id'] shift_sale.cashier_terminal_id = ss['cashier_terminal_id'] shift_sale.shift_started_at = ss['shift_started_at'] shift_sale.shift_closed_at = ss['shift_closed_at'] @@ -73,8 +72,8 @@ class ShiftSale < ApplicationRecord shift_sale.total_void = ss['total_void'] shift_sale.save - puts "....... Shift Sale has been #{status} ......" end + puts "....... Shift Sale sync completed ......" end end diff --git a/app/pdf/move_table_pdf.rb b/app/pdf/move_table_pdf.rb index 48bead98..5d44b393 100644 --- a/app/pdf/move_table_pdf.rb +++ b/app/pdf/move_table_pdf.rb @@ -1,21 +1,22 @@ class MoveTablePdf < Prawn::Document include ActionView::Helpers::NumberHelper - 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 + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i self.item_font_size = printer_settings.item_font_size.to_i self.margin = 0 + self.margin_top = 7 self.price_width = 40 # No Need for item self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 - super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => [self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # db font setup if printer_settings.font != "" @@ -85,7 +86,7 @@ class MoveTablePdf < Prawn::Document move_down 5 order_items.each do|odi| - # check for item not to show + # check for item not to show # if odi.price != 0 y_position = cursor @@ -103,15 +104,15 @@ class MoveTablePdf < Prawn::Document bounding_box([0,y_position], :width => self.item_width) do text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left end - + if !(odi.alt_name).empty? move_down 4 # font("public/fonts/NotoSansCJKtc-Regular.ttf") do text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true # end end - - end + + end end end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index f872d608..946a0adf 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -1,22 +1,23 @@ class OrderItemPdf < Prawn::Document include ActionView::Helpers::NumberHelper - 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 - + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height self.header_font_size = print_settings.header_font_size.to_i self.item_font_size = print_settings.item_font_size.to_i self.margin = 0 + self.margin_top = 7 self.price_width = 40 # No Need for item self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 - super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) # db font setup @@ -29,17 +30,17 @@ class OrderItemPdf < Prawn::Document }) font "#{print_settings.font}" - fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - #font "public/fonts/Chinese.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" if !order_item.dining.nil? text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 3 @@ -51,31 +52,31 @@ class OrderItemPdf < Prawn::Document end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -87,7 +88,7 @@ class OrderItemPdf < Prawn::Document def order_items(order_item, options, alt_name, precision, before_updated_qty) y_position = cursor - #Add Order Item + #Add Order Item add_order_items(order_item, options, alt_name, precision) dash(1, :space => 1, :phase => 1) @@ -155,7 +156,7 @@ class OrderItemPdf < Prawn::Document booking = Order.joins(" JOIN booking_orders bo ON bo.order_id = orders.order_id") .joins(" JOIN bookings b ON b.booking_id=bo.booking_id") .where("orders.order_id='#{order_no}'") - .first() + .first() return booking.booking_id end diff --git a/app/pdf/order_item_star_pdf.rb b/app/pdf/order_item_star_pdf.rb index 2aaf01ac..711fb81e 100644 --- a/app/pdf/order_item_star_pdf.rb +++ b/app/pdf/order_item_star_pdf.rb @@ -1,22 +1,23 @@ class OrderItemStarPdf < Prawn::Document include ActionView::Helpers::NumberHelper - 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 - + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height self.header_font_size = print_settings.header_font_size.to_i self.item_font_size = print_settings.item_font_size.to_i self.margin = 0 + self.margin_top = 7 self.price_width = 40 # No Need for item self.qty_width = 38 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 - super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => [self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) # db font setup @@ -29,17 +30,17 @@ class OrderItemStarPdf < Prawn::Document }) font "#{print_settings.font}" - fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - #font "public/fonts/Chinese.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" if !order_item.dining.nil? text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 3 @@ -51,31 +52,31 @@ class OrderItemStarPdf < Prawn::Document end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -87,7 +88,7 @@ class OrderItemStarPdf < Prawn::Document def order_items(order_item, options, alt_name, precision, before_updated_qty) y_position = cursor - #Add Order Item + #Add Order Item add_order_items(order_item, options, alt_name, precision) dash(1, :space => 1, :phase => 1) @@ -155,7 +156,7 @@ class OrderItemStarPdf < Prawn::Document booking = Order.joins(" JOIN booking_orders bo ON bo.order_id = orders.order_id") .joins(" JOIN bookings b ON b.booking_id=bo.booking_id") .where("orders.order_id='#{order_no}'") - .first() + .first() return booking.booking_id end diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb index c11603eb..447e0a2e 100644 --- a/app/pdf/receipt_bill_star_pdf.rb +++ b/app/pdf/receipt_bill_star_pdf.rb @@ -1,7 +1,7 @@ class ReceiptBillStarPdf < Prawn::Document include ActionView::Helpers::NumberHelper - 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, :description_width, :price_num_width, :line_move + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) self.page_width = printer_settings.page_width @@ -9,6 +9,7 @@ class ReceiptBillStarPdf < Prawn::Document self.header_font_size = printer_settings.header_font_size.to_i self.item_font_size = printer_settings.item_font_size.to_i self.margin = 0 + self.margin_top = 10 self.price_width = 60 self.qty_width = 20 self.total_width = 40 @@ -25,7 +26,7 @@ class ReceiptBillStarPdf < Prawn::Document # @double = @qty_width * 1.3 # @half_qty = @qty_width / 2 #setting page margin and width - super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => [self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) #precision checked if printer_settings.precision.to_i > 2 diff --git a/app/views/api/payment/mobilepayment/cash.json.jbuilder b/app/views/api/payment/mobilepayment/cash.json.jbuilder new file mode 100644 index 00000000..f0b9060b --- /dev/null +++ b/app/views/api/payment/mobilepayment/cash.json.jbuilder @@ -0,0 +1,10 @@ +# json.set! :status, @out[0] +# json.set! :data, @out[1] +# + +if @cash + json.status true +else + json.status false + json.data @cash +end diff --git a/app/views/api/sync/sync_data.json.jbuilder b/app/views/api/sync/sync_data.json.jbuilder index 736432ed..70973240 100644 --- a/app/views/api/sync/sync_data.json.jbuilder +++ b/app/views/api/sync/sync_data.json.jbuilder @@ -1,2 +1,2 @@ -json.status = true -json.message = 'Data successfully Sync' \ No newline at end of file +json.status true +json.message "Sync Record Completed." \ No newline at end of file diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 3948d86f..55295c9e 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -126,8 +126,8 @@ <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.nil? && !crm_customer.membership_type =="" && !crm_customer.paypar_account_no =="" && !crm_customer.paypar_account_no.nil? %> <%= link_to t("views.btn.sync"), crm_customer_sync_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> <% end %> - <% if @customer_update_phone_email %> - <%= link_to t("views.btn.update"), crm_customer_update_phone_email_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> + <% if @customer_update_phone_email_membertype %> + <%= link_to t("views.btn.update"), crm_customer_update_phone_email_member_type_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> <% end %> <%= link_to t("views.btn.show"), crm_customer_path(crm_customer), :class => "btn btn-md bg-blue waves-effect" %> diff --git a/app/views/induties/assign_in_duties/_form.html.erb b/app/views/induties/assign_in_duties/_form.html.erb new file mode 100644 index 00000000..513d93a4 --- /dev/null +++ b/app/views/induties/assign_in_duties/_form.html.erb @@ -0,0 +1,10 @@ +<%= simple_form_for(@induties_assign_in_duty) do |f| %> + <%= f.error_notification %> + +
+
+ +
+ <%= f.button :submit %> +
+<% end %> diff --git a/app/views/induties/assign_in_duties/_induties_assign_in_duty.json.jbuilder b/app/views/induties/assign_in_duties/_induties_assign_in_duty.json.jbuilder new file mode 100644 index 00000000..4ad02170 --- /dev/null +++ b/app/views/induties/assign_in_duties/_induties_assign_in_duty.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! induties_assign_in_duty, :id, :created_at, :updated_at +json.url induties_assign_in_duty_url(induties_assign_in_duty, format: :json) diff --git a/app/views/induties/assign_in_duties/edit.html.erb b/app/views/induties/assign_in_duties/edit.html.erb new file mode 100644 index 00000000..63e24a52 --- /dev/null +++ b/app/views/induties/assign_in_duties/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Induties Assign In Duty

+ +<%= render 'form', induties_assign_in_duty: @induties_assign_in_duty %> + +<%= link_to 'Show', @induties_assign_in_duty %> | +<%= link_to 'Back', induties_assign_in_duties_path %> diff --git a/app/views/induties/assign_in_duties/index.html.erb b/app/views/induties/assign_in_duties/index.html.erb new file mode 100644 index 00000000..fc30fed5 --- /dev/null +++ b/app/views/induties/assign_in_duties/index.html.erb @@ -0,0 +1,345 @@ + +
+
+
+
+ <% @commissioners.each do |com| %> +
+
);background-repeat: no-repeat; background-size: cover;"> +
+
<%=com["name"] %>
+ <% if com["check_in_count"] >0%> +
A :<%=com["check_in_count"] %>
+ <% end %> + +
+
+ +
+
+
+ <% end %> +
+
+
+ add +
+
+
+
+
+
+
+
+ +
+
+
+
+ + +
+ + + + + + + + + + +
DiningCheck In AtAction
+
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ <%= simple_form_for 'zone', :method => :get do |f| %> + <%= f.collection_select :dinning_id, Room.all, :id, :name, {prompt: 'Select Room'},:class=>'form-control',:required => true %> + <%end %> +
+
+
+
+ <%= simple_form_for 'zone_t', :method => :get do |f| %> + <%= f.collection_select :dinning_id, Table.all, :id, :name, {prompt: 'Select Table'},:class=>'form-control',:required => true %> + <%end %> +
+
+
+
+
+
+ <%= simple_form_for 'save_induties', :url => induties_induties_create_path, :method => :post do |f| %> + <%= f.check_box :by_name,:class=>'form-control'%> + + <% end %> +
+
+ +
+
+ +
+ + diff --git a/app/views/induties/assign_in_duties/index.json.jbuilder b/app/views/induties/assign_in_duties/index.json.jbuilder new file mode 100644 index 00000000..057eb2db --- /dev/null +++ b/app/views/induties/assign_in_duties/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @induties_assign_in_duties, partial: 'induties_assign_in_duties/induties_assign_in_duty', as: :induties_assign_in_duty diff --git a/app/views/induties/assign_in_duties/new.html.erb b/app/views/induties/assign_in_duties/new.html.erb new file mode 100644 index 00000000..512f3038 --- /dev/null +++ b/app/views/induties/assign_in_duties/new.html.erb @@ -0,0 +1,5 @@ +

New Induties Assign In Duty

+ +<%= render 'form', induties_assign_in_duty: @induties_assign_in_duty %> + +<%= link_to 'Back', induties_assign_in_duties_path %> diff --git a/app/views/induties/assign_in_duties/show.html.erb b/app/views/induties/assign_in_duties/show.html.erb new file mode 100644 index 00000000..82a22e22 --- /dev/null +++ b/app/views/induties/assign_in_duties/show.html.erb @@ -0,0 +1,4 @@ +

<%= notice %>

+ +<%= link_to 'Edit', edit_induties_assign_in_duty_path(@induties_assign_in_duty) %> | +<%= link_to 'Back', induties_assign_in_duties_path %> diff --git a/app/views/induties/assign_in_duties/show.json.jbuilder b/app/views/induties/assign_in_duties/show.json.jbuilder new file mode 100644 index 00000000..0367be23 --- /dev/null +++ b/app/views/induties/assign_in_duties/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "induties_assign_in_duties/induties_assign_in_duty", induties_assign_in_duty: @induties_assign_in_duty diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 951f69c7..e7abb58b 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -4,7 +4,6 @@ <% type = request.path_info.include?('quick_service') || request.path_info.include?('food_court')%> <% modify_order = request.path_info.include?('modify_order')%> -