From ce644e304cc1ee203722d4d5449f11d30ac78c4a Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Thu, 22 Feb 2018 16:43:53 +0630 Subject: [PATCH 01/18] Validate required for reference no: in other payment amount --- app/views/origami/jcb/index.html.erb | 92 +++++++++++---------- app/views/origami/master/index.html.erb | 92 +++++++++++---------- app/views/origami/mpu/index.html.erb | 99 ++++++++++++----------- app/views/origami/unionpay/index.html.erb | 96 ++++++++++++---------- app/views/origami/visa/index.html.erb | 96 ++++++++++++---------- 5 files changed, 257 insertions(+), 218 deletions(-) diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index 837c9f43..1fe49080 100755 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -51,7 +51,8 @@
- + +

@@ -194,53 +195,60 @@ $(document).on('click', '.cashier_number', function(event){ $('#jcb_pay').on('click',function(){ var amount = $('#amount').text(); + var reference_no = $('#reference_no').val(); var sale_id = "<%= @sale_id %>"; var receipt_no = "<%= @receipt_no %>"; var bank_integration = "<%= @bank_integration %>"; - if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ - $(this).off("click"); - //start member discount 5% by pay card - // var sub_total = $('#sub-total').text(); - // var member_id = $('#membership_id').text(); - // var member_discount = $('#member_discount').text(); - // if (member_id && member_discount) { - // $.ajax({ - // type: "POST", - // url: "/origami/" + sale_id + "/member_discount", - // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, - // success:function(result){ - // } - // }); - // } - //end member discount - if(bank_integration == '1'){ - pay_withBank("SALE", "jcb", amount, sale_id, receipt_no); + $("#reference_no_Err").html(""); + if(reference_no.length > 0){ + if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ + $(this).off("click"); + //start member discount 5% by pay card + // var sub_total = $('#sub-total').text(); + // var member_id = $('#membership_id').text(); + // var member_discount = $('#member_discount').text(); + // if (member_id && member_discount) { + // $.ajax({ + // type: "POST", + // url: "/origami/" + sale_id + "/member_discount", + // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, + // success:function(result){ + // } + // }); + // } + //end member discount + if(bank_integration == '1'){ + $("#reference_no").val(""); + pay_withBank("SALE", "jcb", amount, sale_id, receipt_no); + }else{ + $.ajax({type: "POST", + url: "<%= origami_payment_jcb_path %>", + data: "amount="+ amount + "&sale_id="+ sale_id, + success:function(result){ + if(result){ + swal({ + title: "Information!", + text: "Payment Successfully", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; + }); + } + } + }); + } }else{ - $.ajax({type: "POST", - url: "<%= origami_payment_jcb_path %>", - data: "amount="+ amount + "&sale_id="+ sale_id, - success:function(result){ - if(result){ - swal({ - title: "Information!", - text: "Payment Successfully", - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; - }); - } - } - }); + if (amount>0) { + swal ( "Oops" , "Paid Amount is over!" , "error" ); + }else{ + swal ( "Oops" , "Enter Amount!" , "error" ); + } } }else{ - if (amount>0) { - swal ( "Oops" , "Paid Amount is over!" , "error" ); - }else{ - swal ( "Oops" , "Enter Amount!" , "error" ); - } + $("#reference_no_Err").html("can't be blank"); } }) diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb index f5c8f06b..2e663b7a 100755 --- a/app/views/origami/master/index.html.erb +++ b/app/views/origami/master/index.html.erb @@ -52,7 +52,8 @@
- + +

@@ -192,53 +193,60 @@ }); $('#master_pay').on('click',function(){ var amount = $('#amount').text(); + var reference_no = $('#reference_no').val(); var sale_id = "<%= @sale_id %>"; var receipt_no = "<%= @receipt_no %>"; var bank_integration = "<%= @bank_integration %>"; - if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ - $(this).off("click"); - //start member discount 5% by pay card - // var sub_total = $('#sub-total').text(); - // var member_id = $('#membership_id').text(); - // var member_discount = $('#member_discount').text(); - // if (member_id && member_discount) { - // $.ajax({ - // type: "POST", - // url: "/origami/" + sale_id + "/member_discount", - // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, - // // success:function(result){ - // // } - // }); - // } - //end member discount - if(bank_integration == '1'){ - pay_withBank("SALE", "master", amount, sale_id, receipt_no); - }else{ - $.ajax({type: "POST", - url: "<%= origami_payment_master_path %>", - data: "amount="+ amount + "&sale_id="+ sale_id, - success:function(result){ - if(result){ - swal({ - title: "Information!", - text: "Payment Successfully", - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; - }); + $("#reference_no_Err").html(""); + if(reference_no.length > 0){ + if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ + $(this).off("click"); + //start member discount 5% by pay card + // var sub_total = $('#sub-total').text(); + // var member_id = $('#membership_id').text(); + // var member_discount = $('#member_discount').text(); + // if (member_id && member_discount) { + // $.ajax({ + // type: "POST", + // url: "/origami/" + sale_id + "/member_discount", + // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, + // // success:function(result){ + // // } + // }); + // } + //end member discount + if(bank_integration == '1'){ + $("#reference_no").val(""); + pay_withBank("SALE", "master", amount, sale_id, receipt_no); + }else{ + $.ajax({type: "POST", + url: "<%= origami_payment_master_path %>", + data: "amount="+ amount + "&sale_id="+ sale_id, + success:function(result){ + if(result){ + swal({ + title: "Information!", + text: "Payment Successfully", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; + }); + } } - } - }); + }); + } + }else{ + if (amount>0) { + swal ( "Oops" , "Paid Amount is over!" , "error" ); + }else{ + swal ( "Oops" , "Enter Amount!" , "error" ); + } } }else{ - if (amount>0) { - swal ( "Oops" , "Paid Amount is over!" , "error" ); - }else{ - swal ( "Oops" , "Enter Amount!" , "error" ); - } + $("#reference_no_Err").html("can't be blank"); } }) diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index f40ce252..f95b3773 100755 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -52,7 +52,8 @@
- + +

@@ -196,56 +197,62 @@ $('#mpu_pay').on('click',function(){ var amount = $('#amount').text(); + var reference_no = $('#reference_no').val(); var sale_id = "<%= @sale_id %>"; var receipt_no = "<%= @receipt_no %>"; var bank_integration = "<%= @bank_integration %>"; var cashier_type = "<%= @cashier_type %>"; - if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ - $(this).off("click"); - //start member discount 5% by pay card - // var sub_total = $('#sub-total').text(); - // var member_id = $('#membership_id').text(); - // var member_discount = $('#member_discount').text(); - // if (member_id && member_discount) { - // $.ajax({ - // type: "POST", - // url: "/origami/" + sale_id + "/member_discount", - // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, - // success:function(result){ - // } - // }); - // } - //end member discount - if(bank_integration == '1'){ - pay_withBank("SALE", "mpu", amount, sale_id, receipt_no); - }else{ - $.ajax({type: "POST", - url: "<%= origami_payment_mpu_path %>", - data: "amount="+ amount + "&sale_id="+ sale_id, - success:function(result){ - if(result){ - swal({ - title: "Information!", - text: "Payment Successfully", - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment"; - }); - } - } - }); - } - - }else{ - if (amount>0) { - swal ( "Oops" , "Paid Amount is over!" , "error" ); + $("#reference_no_Err").html(""); + if(reference_no.length > 0){ + if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ + $(this).off("click"); + //start member discount 5% by pay card + // var sub_total = $('#sub-total').text(); + // var member_id = $('#membership_id').text(); + // var member_discount = $('#member_discount').text(); + // if (member_id && member_discount) { + // $.ajax({ + // type: "POST", + // url: "/origami/" + sale_id + "/member_discount", + // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, + // success:function(result){ + // } + // }); + // } + //end member discount + if(bank_integration == '1'){ + $("#reference_no").val(""); + pay_withBank("SALE", "mpu", amount, sale_id, receipt_no); + }else{ + $.ajax({type: "POST", + url: "<%= origami_payment_mpu_path %>", + data: "amount="+ amount + "&sale_id="+ sale_id, + success:function(result){ + if(result){ + swal({ + title: "Information!", + text: "Payment Successfully", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment"; + }); + } + } + }); + } }else{ - swal ( "Oops" , "Enter Amount!" , "error" ); + if (amount>0) { + swal ( "Oops" , "Paid Amount is over!" , "error" ); + }else{ + swal ( "Oops" , "Enter Amount!" , "error" ); + } } - } - }) + }else{ + $("#reference_no_Err").html("can't be blank"); + } + }) diff --git a/app/views/origami/unionpay/index.html.erb b/app/views/origami/unionpay/index.html.erb index 5dee20f1..8658f23c 100755 --- a/app/views/origami/unionpay/index.html.erb +++ b/app/views/origami/unionpay/index.html.erb @@ -52,7 +52,8 @@
- + +

@@ -196,54 +197,61 @@ }); $('#unionpay_pay').on('click',function(){ var amount = $('#amount').text(); + var reference_no = $('#reference_no').val(); var sale_id = "<%= @sale_id %>"; var receipt_no = "<%= @receipt_no %>"; - if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ - $(this).off("click"); - //start member discount 5% by pay card - // var sub_total = $('#sub-total').text(); - // var member_id = $('#membership_id').text(); - // var member_discount = $('#member_discount').text(); - // if (member_id && member_discount) { - // $.ajax({ - // type: "POST", - // url: "/origami/" + sale_id + "/member_discount", - // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, - // success:function(result){ - // } - // }); - // } - //end member discount - var bank_integration = "<%= @bank_integration %>"; - if(bank_integration == '1'){ - pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no); - } - else{ - $.ajax({type: "POST", - url: "<%= origami_payment_unionpay_path %>", - data: "amount="+ amount + "&sale_id="+ sale_id, - success:function(result){ - if(result){ - swal({ - title: "Information!", - text: "Payment Successfully", - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; - }); + $("#reference_no_Err").html(""); + if(reference_no.length > 0){ + if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ + $(this).off("click"); + //start member discount 5% by pay card + // var sub_total = $('#sub-total').text(); + // var member_id = $('#membership_id').text(); + // var member_discount = $('#member_discount').text(); + // if (member_id && member_discount) { + // $.ajax({ + // type: "POST", + // url: "/origami/" + sale_id + "/member_discount", + // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, + // success:function(result){ + // } + // }); + // } + //end member discount + var bank_integration = "<%= @bank_integration %>"; + if(bank_integration == '1'){ + $("#reference_no").val(""); + pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no); + } + else{ + $.ajax({type: "POST", + url: "<%= origami_payment_unionpay_path %>", + data: "amount="+ amount + "&sale_id="+ sale_id, + success:function(result){ + if(result){ + swal({ + title: "Information!", + text: "Payment Successfully", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; + }); + } } - } - }); + }); + } + }else{ + if (amount>0) { + swal ( "Oops" , "Paid Amount is over!" , "error" ); + }else{ + swal ( "Oops" , "Enter Amount!" , "error" ); + } } }else{ - if (amount>0) { - swal ( "Oops" , "Paid Amount is over!" , "error" ); - }else{ - swal ( "Oops" , "Enter Amount!" , "error" ); - } + $("#reference_no_Err").html("can't be blank"); } }) diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index 2970ba44..60f62caa 100755 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -52,7 +52,8 @@
- + +

@@ -195,56 +196,63 @@ }); $('#visa_pay').on('click',function(){ var amount = $('#amount').text(); + var reference_no = $('#reference_no').val(); var sale_id = "<%= @sale_id %>"; var receipt_no = "<%= @receipt_no %>"; console.log(amount); console.log($("#validamount").attr("value")); - if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ - $(this).off("click"); - //start member discount 5% by pay card - // var sub_total = $('#sub-total').text(); - // var member_id = $('#membership_id').text(); - // var member_discount = $('#member_discount').text(); - // if (member_id && member_discount) { - // $.ajax({ - // type: "POST", - // url: "/origami/" + sale_id + "/member_discount", - // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, - // success:function(result){ - // } - // }); - // } - //end member discount - var bank_integration = "<%= @bank_integration %>"; - if(bank_integration == '1'){ - pay_withBank("SALE", "visa", amount, sale_id, receipt_no); - } - else{ - $.ajax({type: "POST", - url: "<%= origami_payment_visa_path %>", - data: "amount="+ amount + "&sale_id="+ sale_id, - success:function(result){ - if(result){ - swal({ - title: "Information!", - text: "Payment Successfully", - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; - }); + $("#reference_no_Err").html(""); + if(reference_no.length > 0){ + if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ + $(this).off("click"); + //start member discount 5% by pay card + // var sub_total = $('#sub-total').text(); + // var member_id = $('#membership_id').text(); + // var member_discount = $('#member_discount').text(); + // if (member_id && member_discount) { + // $.ajax({ + // type: "POST", + // url: "/origami/" + sale_id + "/member_discount", + // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, + // success:function(result){ + // } + // }); + // } + //end member discount + var bank_integration = "<%= @bank_integration %>"; + if(bank_integration == '1'){ + $("#reference_no").val(""); + pay_withBank("SALE", "visa", amount, sale_id, receipt_no); + } + else{ + $.ajax({type: "POST", + url: "<%= origami_payment_visa_path %>", + data: "amount="+ amount + "&sale_id="+ sale_id, + success:function(result){ + if(result){ + swal({ + title: "Information!", + text: "Payment Successfully", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; + }); + } } - } - }); + }); + } + }else{ + if (amount>0) { + swal ( "Oops" , "Paid Amount is over!" , "error" ); + }else{ + swal ( "Oops" , "Enter Amount!" , "error" ); + } } }else{ - if (amount>0) { - swal ( "Oops" , "Paid Amount is over!" , "error" ); - }else{ - swal ( "Oops" , "Enter Amount!" , "error" ); - } + $("#reference_no_Err").html("can't be blank"); } }) From fb35d83bbefd488642d63ed22e52349fc311c3ac Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Thu, 22 Feb 2018 17:21:07 +0630 Subject: [PATCH 02/18] change text 'Total Sale => Sale Revenue', 'Grand Total => Total Sale', 'Total Card => Other Payment' for dashboard 'Sale' box --- app/views/origami/dashboard/index.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb index 8f432e1e..cd9bd050 100644 --- a/app/views/origami/dashboard/index.html.erb +++ b/app/views/origami/dashboard/index.html.erb @@ -98,7 +98,7 @@ <%= @summ_sale.total_receipt %> - <%= t("views.right_panel.detail.total") %> <%= t :sale %> : + <%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : <%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) %> @@ -110,7 +110,7 @@ <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%> - <%= t("views.right_panel.detail.grand_total") %> : + <%= t("views.right_panel.detail.total") %> <%= t :sale %> : <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> @@ -135,7 +135,7 @@ <% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %> <% if !total_card.nil? %> - <%= t("views.right_panel.detail.card_sale") %> : + <%= t("views.right_panel.detail.other_payment") %> : <%= total_card["card"].to_f %> From 36511c258f23ad55270b9b905c147c55f557a1f9 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Fri, 23 Feb 2018 17:07:25 +0630 Subject: [PATCH 03/18] Add Key Pad in login_dashboard.html.erb --- app/views/layouts/login_dashboard.html.erb | 70 +++++++++++++++++++++- app/views/origami/dashboard/index.html.erb | 4 ++ 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/login_dashboard.html.erb b/app/views/layouts/login_dashboard.html.erb index e238953f..24b0f2e5 100755 --- a/app/views/layouts/login_dashboard.html.erb +++ b/app/views/layouts/login_dashboard.html.erb @@ -65,8 +65,46 @@

-
-
+
+
+
+ +
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+ +
BACK
+
0
+
CLR
+
+
+
+
+ + +
+
@@ -177,7 +215,9 @@ - \ No newline at end of file diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index 1fe49080..f7f43812 100755 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -12,7 +12,6 @@
--> -
JCB Payment
diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb index 2e663b7a..03d90a07 100755 --- a/app/views/origami/master/index.html.erb +++ b/app/views/origami/master/index.html.erb @@ -12,7 +12,6 @@
--> -
Master Payment
diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index f95b3773..caa0c9e9 100755 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -12,7 +12,6 @@
--> -
MPU Payment
diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 1d29e563..169eb026 100755 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -9,7 +9,6 @@
--> -
Reedem Payment
diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index 60f62caa..3cdca7df 100755 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -12,7 +12,6 @@
--> -
VISA Payment
diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 8f310dab..3f69a55e 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -18,13 +18,13 @@ class ActionController::Base # redirect_to root_url(:host => request.domain) + "store_error" render :json => [{ status: false, message: 'Invalid Access!'}] end - else - # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # else + # # check for license file + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end From 5cc369114b249205c02e05f157cbe10d2b097534 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 6 Mar 2018 18:31:09 +0630 Subject: [PATCH 12/18] Remove config --- config/initializers/action_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 3f69a55e..8f310dab 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -18,13 +18,13 @@ class ActionController::Base # redirect_to root_url(:host => request.domain) + "store_error" render :json => [{ status: false, message: 'Invalid Access!'}] end - # else - # # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + else + # check for license file + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end From 9f29bbef5a03360ed5fb1cb7890445813a27ca3b Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 7 Mar 2018 12:41:49 +0630 Subject: [PATCH 13/18] To add image field in shop --- app/controllers/settings/shops_controller.rb | 2 +- app/models/shop.rb | 3 + app/uploaders/shop_image_uploader.rb | 59 ++++++++ app/views/settings/products/_form.html.erb | 2 +- app/views/settings/shops/_form.html.erb | 144 +++++++++++-------- app/views/settings/shops/show.html.erb | 6 +- 6 files changed, 149 insertions(+), 67 deletions(-) create mode 100644 app/uploaders/shop_image_uploader.rb diff --git a/app/controllers/settings/shops_controller.rb b/app/controllers/settings/shops_controller.rb index a48bcb9a..f69aaac6 100644 --- a/app/controllers/settings/shops_controller.rb +++ b/app/controllers/settings/shops_controller.rb @@ -71,6 +71,6 @@ class Settings::ShopsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def shop_params - params.require(:shop).permit(:name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info) + params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info) end end diff --git a/app/models/shop.rb b/app/models/shop.rb index c722adc2..0fd9ed0e 100755 --- a/app/models/shop.rb +++ b/app/models/shop.rb @@ -1,3 +1,6 @@ class Shop < ApplicationRecord ShopDetail = Shop.find_by_id(1) + + # Shop Image Uploader + mount_uploader :logo, ShopImageUploader end diff --git a/app/uploaders/shop_image_uploader.rb b/app/uploaders/shop_image_uploader.rb new file mode 100644 index 00000000..63a01c21 --- /dev/null +++ b/app/uploaders/shop_image_uploader.rb @@ -0,0 +1,59 @@ +class ShopImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + def root + Rails.root.join 'public/' + end + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "image/shop_images" + # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # def cache_dir + # '/tmp/images' + # end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url(*args) + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process scale: [200, 300] + process :resize_to_fit => [200, 150] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process resize_to_fit: [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_whitelist + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end \ No newline at end of file diff --git a/app/views/settings/products/_form.html.erb b/app/views/settings/products/_form.html.erb index f9ad882b..bea0f004 100755 --- a/app/views/settings/products/_form.html.erb +++ b/app/views/settings/products/_form.html.erb @@ -12,7 +12,7 @@ <%= f.input :unit_price %> <%= f.input :description %> <%= f.input :information %> - <%= f.input:taxable %> + <%= f.input :taxable %>
diff --git a/app/views/settings/shops/_form.html.erb b/app/views/settings/shops/_form.html.erb index 5a353b9b..b615d189 100755 --- a/app/views/settings/shops/_form.html.erb +++ b/app/views/settings/shops/_form.html.erb @@ -1,68 +1,86 @@
- <%= simple_form_for([:settings,@settings_shop]) do |f| %> - <%= f.error_notification %> -
- <%= f.input :name ,:input_html=>{:class=>"col-md-10"},:required=>true%> - - <%= f.input :address %> - <%= f.input :city %> - <%= f.input :township %> - <%= f.input :state %> - <%= f.input :phone_no %> - <%= f.input :reservation_no %> - <%= f.input :license %> - <%= f.input :license_data %> - <%= f.input :base_currency %> - <%= f.input :cloud_token %> - <%= f.input :cloud_url %> - <%= f.input :owner_token %> - <%= f.input :id_prefix %> - <%= f.input :is_rounding_adj %> - <%= f.input :quick_sale_summary %> - <%= f.input :calc_tax_order %> - <%= f.input :show_account_info %> +
+
+ <%= simple_form_for([:settings,@settings_shop]) do |f| %> + <%= f.error_notification %> +
+ <%= f.input :name ,:input_html=>{:class=>"col-md-10"},:required=>true%> + <%= f.input :address %> + <%= f.input :city %> + <%= f.input :township %> + <%= f.input :state %> + <%= f.input :phone_no %> + <%= f.input :reservation_no %> + <%= f.input :license %> + <%= f.input :license_data %> + <%= f.input :base_currency %> + <%= f.input :cloud_token %> + <%= f.input :cloud_url %> + <%= f.input :owner_token %> + <%= f.input :id_prefix %> + <%= f.input :is_rounding_adj %> + <%= f.input :quick_sale_summary %> + <%= f.input :calc_tax_order %> + <%= f.input :show_account_info %> +
- -
-
- <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> -
- <% end %> -
-
-
-
-
view_headline <%= t("views.right_panel.header.page_detail") %>
-

- 1) address - to write shop's address
- 2) city - to write city
- 3) township - to write township
- 4) state - to write state
- 5) phone_no - to write shop's phone_no
- 6) reservation_no - to write shop's reservation_no
- 7) license - to write license
- 8) license_data - to write license data
- 9) base_currency - to write base currency
- 10)cloud_token - to write cloud token
- 11)cloud_url - to write cloud url
- 12)owner_token - to write shop's owner token
- 13)id_prefix - to write id prefix
- 14)is_rounding_adj - to check for calculate rounding adj of shop
- 15)quick_sale_summary - to check for view Quick Sale Summary
- 16)calc_tax_order - to check for tax calculation of shop
- -

-
list <%= t("views.right_panel.header.button_lists") %>
-

- 1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.shop_txt") %>
-

-
list <%= t("views.right_panel.header.link_lists") %>
-

- 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
- 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.shop_txt") %>
-

+ +
+
+ + <%= f.file_field :logo, :class => "img-thumbnail" %> +
+
+ +
+ <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> +
+ <% end %> +
-
-
+
+ +
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+

+ 1) address - to write shop's address
+ 2) city - to write city
+ 3) township - to write township
+ 4) state - to write state
+ 5) phone_no - to write shop's phone_no
+ 6) reservation_no - to write shop's reservation_no
+ 7) license - to write license
+ 8) license_data - to write license data
+ 9) base_currency - to write base currency
+ 10)cloud_token - to write cloud token
+ 11)cloud_url - to write cloud url
+ 12)owner_token - to write shop's owner token
+ 13)id_prefix - to write id prefix
+ 14)is_rounding_adj - to check for calculate rounding adj of shop
+ 15)quick_sale_summary - to check for view Quick Sale Summary
+ 16)calc_tax_order - to check for tax calculation of shop
+ +

+
list <%= t("views.right_panel.header.button_lists") %>
+

+ 1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.shop_txt") %>
+

+
list <%= t("views.right_panel.header.link_lists") %>
+

+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.shop_txt") %>
+

+
+
+
diff --git a/app/views/settings/shops/show.html.erb b/app/views/settings/shops/show.html.erb index 8fd9c5f0..bea0ab38 100755 --- a/app/views/settings/shops/show.html.erb +++ b/app/views/settings/shops/show.html.erb @@ -96,8 +96,10 @@ <%= @settings_shop.calc_tax_order %> - - + Shop Image + <%= image_tag @settings_shop.logo, :size => '200x200'%> + + <%= link_to t("views.btn.edit"), edit_settings_shop_path(@settings_shop),:class => 'btn btn-primary btn-sm waves-effect' %> From 9ec8c4d18c894622fb729b19e3dff3af63571420 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 7 Mar 2018 17:50:23 +0630 Subject: [PATCH 14/18] Photo Field in Customer,Employee and Commissionor --- app/assets/javascripts/CRM.js | 23 ++++++- app/assets/javascripts/application.js | 60 +++++++++++++++++++ app/assets/javascripts/origami.js | 25 ++++++++ app/assets/stylesheets/CRM.scss | 1 + app/controllers/crm/customers_controller.rb | 2 +- .../settings/commissioners_controller.rb | 2 +- .../settings/employees_controller.rb | 2 +- app/models/commissioner.rb | 3 + app/models/customer.rb | 3 + app/models/employee.rb | 3 + app/uploaders/commissioner_image_uploader.rb | 59 ++++++++++++++++++ app/uploaders/customer_image_uploader.rb | 59 ++++++++++++++++++ app/uploaders/employee_image_uploader.rb | 59 ++++++++++++++++++ app/views/crm/customers/_new_form.html.erb | 16 +++++ app/views/layouts/_header.html.erb | 6 +- .../settings/commissioners/_form.html.erb | 22 ++++++- .../settings/commissioners/show.html.erb | 4 ++ app/views/settings/employees/_form.html.erb | 16 +++++ app/views/settings/employees/show.html.erb | 4 ++ 19 files changed, 360 insertions(+), 9 deletions(-) create mode 100644 app/uploaders/commissioner_image_uploader.rb create mode 100644 app/uploaders/customer_image_uploader.rb create mode 100644 app/uploaders/employee_image_uploader.rb diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js index 03450eb1..b616453c 100755 --- a/app/assets/javascripts/CRM.js +++ b/app/assets/javascripts/CRM.js @@ -23,6 +23,7 @@ //= require bootstrap-notify/bootstrap-notify.js //= require node-waves/waves.js //= require sweetalert/sweetalert.min.js +//= require fileinput.min //= require BSBMaterial/turbolink_admin.js //= require BSBMaterial/demo.js //= require custom.js @@ -34,4 +35,24 @@ $(document).on('turbolinks:load', function() { weekStart: 1, time: false }); -}); \ No newline at end of file + + $("#customer_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); +}); diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 76341958..590657ef 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -104,6 +104,66 @@ $(document).ready(function() { } }); + $("#shop_logo").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); + + $("#commissioner_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); + + $("#employee_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); + // first input focus for all form $('form:first *input[data-behaviour!=datepicker]:input[type!=hidden]:first').focus(); diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index d7afc4db..0f5380a7 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -9,12 +9,37 @@ //= require bootstrap-notify/bootstrap-notify.js //= require node-waves/waves.js //= require sweetalert/sweetalert.min.js +//= require fileinput.min //= require cable //= require turbolinks //= require BSBMaterial/turbolink_admin.js //= require BSBMaterial/demo.js //= require custom.js + +$(document).on('turbolinks:load', function() { + + $("#customer_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); +}); + $(document).on('turbolinks:load', function() { $('.datetimepicker').bootstrapMaterialDatePicker({ format: 'DD-MM-YYYY - HH:mm', diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss index 8b652eac..5bfab409 100755 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -13,6 +13,7 @@ @import "BSBMaterial/style"; @import "BSBMaterial/themes/all-themes"; @import "reset"; +@import "fileinput.min"; .sx-margin-0 { margin: 0 !important; diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 0168e326..42ea4b2f 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -396,7 +396,7 @@ end def customer_params params.require(:customer).permit(:id, :name, :company, :contact_no, :email, - :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type) + :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path) end end diff --git a/app/controllers/settings/commissioners_controller.rb b/app/controllers/settings/commissioners_controller.rb index 4f195f43..f8314bcb 100755 --- a/app/controllers/settings/commissioners_controller.rb +++ b/app/controllers/settings/commissioners_controller.rb @@ -91,6 +91,6 @@ class Settings::CommissionersController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def commissioner_params - params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active) + params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active, :image_path) end end diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 2bc81c51..cefb7b9c 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -68,6 +68,6 @@ class Settings::EmployeesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def employee_params - params.require(:employee).permit(:name, :role, :emp_id, :password) + params.require(:employee).permit(:name, :role, :emp_id, :password, :image_path) end end diff --git a/app/models/commissioner.rb b/app/models/commissioner.rb index 2b262afc..68573460 100755 --- a/app/models/commissioner.rb +++ b/app/models/commissioner.rb @@ -7,4 +7,7 @@ class Commissioner < ApplicationRecord # validations validates_presence_of :name + + # Commissioner Image Uploader + mount_uploader :image_path, CommissionerImageUploader end diff --git a/app/models/customer.rb b/app/models/customer.rb index fcdd7f31..7f5a7a63 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -2,6 +2,9 @@ class Customer < ApplicationRecord #self.primary_key = :customer_id + # Customer Image Uploader + mount_uploader :image_path, CustomerImageUploader + before_create :generate_custom_id has_many :orders has_many :sales diff --git a/app/models/employee.rb b/app/models/employee.rb index a12521cb..c1f985ea 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -8,6 +8,9 @@ class Employee < ApplicationRecord validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true validates :password, numericality: true, length: {in: 3..9}, allow_blank: true + # Employee Image Uploader + mount_uploader :image_path, EmployeeImageUploader + def self.all_emp_except_waiter Employee.where('role!=?','waiter') end diff --git a/app/uploaders/commissioner_image_uploader.rb b/app/uploaders/commissioner_image_uploader.rb new file mode 100644 index 00000000..639ce7d7 --- /dev/null +++ b/app/uploaders/commissioner_image_uploader.rb @@ -0,0 +1,59 @@ +class CommissionerImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + def root + Rails.root.join 'public/' + end + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "image/commissioner_images" + # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # def cache_dir + # '/tmp/images' + # end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url(*args) + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process scale: [200, 300] + process :resize_to_fit => [200, 150] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process resize_to_fit: [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_whitelist + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end \ No newline at end of file diff --git a/app/uploaders/customer_image_uploader.rb b/app/uploaders/customer_image_uploader.rb new file mode 100644 index 00000000..1de0f3ad --- /dev/null +++ b/app/uploaders/customer_image_uploader.rb @@ -0,0 +1,59 @@ +class CustomerImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + def root + Rails.root.join 'public/' + end + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "image/customer_images" + # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # def cache_dir + # '/tmp/images' + # end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url(*args) + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process scale: [200, 300] + process :resize_to_fit => [200, 150] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process resize_to_fit: [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_whitelist + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end \ No newline at end of file diff --git a/app/uploaders/employee_image_uploader.rb b/app/uploaders/employee_image_uploader.rb new file mode 100644 index 00000000..fd64db42 --- /dev/null +++ b/app/uploaders/employee_image_uploader.rb @@ -0,0 +1,59 @@ +class EmployeeImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + def root + Rails.root.join 'public/' + end + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "image/employee_images" + # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # def cache_dir + # '/tmp/images' + # end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url(*args) + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process scale: [200, 300] + process :resize_to_fit => [200, 150] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process resize_to_fit: [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_whitelist + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end \ No newline at end of file diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index 2359ad57..3a953e81 100755 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -90,6 +90,21 @@ <%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%>
+ +
+ +
+ + <%= f.file_field :image_path, :class => "img-thumbnail" %> +
+
@@ -164,6 +179,7 @@
\ No newline at end of file diff --git a/app/views/settings/commissioners/_form.html.erb b/app/views/settings/commissioners/_form.html.erb index a337e47b..1d0823a5 100755 --- a/app/views/settings/commissioners/_form.html.erb +++ b/app/views/settings/commissioners/_form.html.erb @@ -1,11 +1,27 @@
-
+
<%= simple_form_for([:settings, @commissioner]) do |f| %> <%= f.error_notification %> -
+
<%= f.input :name %> + + +
+
+ + <%= f.file_field :image_path, :class => "img-thumbnail" %> +
+
+ <%= f.label :emp_id, 'Employee' %> <%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %> @@ -29,7 +45,7 @@
-
+
view_headline <%= t("views.right_panel.header.page_detail") %>
diff --git a/app/views/settings/commissioners/show.html.erb b/app/views/settings/commissioners/show.html.erb index 49c7f2de..b9df0967 100755 --- a/app/views/settings/commissioners/show.html.erb +++ b/app/views/settings/commissioners/show.html.erb @@ -33,6 +33,10 @@ <%= t("views.right_panel.detail.name") %> <%= @commissioner.name %> + + <%= t("views.right_panel.detail.commissioner_photo") %> + <%= image_tag @commissioner.image_path, :size => '200x200'%> + <%= t("views.right_panel.detail.employee") %> <%= t("views.right_panel.detail.name") %> <%= @commissioner.employee.name rescue '-' %> diff --git a/app/views/settings/employees/_form.html.erb b/app/views/settings/employees/_form.html.erb index 5d5fcb04..0b973416 100755 --- a/app/views/settings/employees/_form.html.erb +++ b/app/views/settings/employees/_form.html.erb @@ -12,6 +12,22 @@ <%= f.input :password %>
+
+ +
+
+ + <%= f.file_field :image_path, :class => "img-thumbnail" %> +
+
+
<%= f.submit t('views.btn.submit'),:class => 'btn btn-primary btn-lg waves-effect' %> diff --git a/app/views/settings/employees/show.html.erb b/app/views/settings/employees/show.html.erb index 0b26b1bf..0e57b032 100755 --- a/app/views/settings/employees/show.html.erb +++ b/app/views/settings/employees/show.html.erb @@ -44,6 +44,10 @@ <%= t("views.right_panel.detail.updated_at") %> <%= @employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> + + <%= t("views.right_panel.detail.employee_photo") %> + <%= image_tag @employee.image_path, :size => '200x200'%> + From f7de959c78548a6ff61bee17f4b248629ad7306b Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 9 Mar 2018 14:23:48 +0630 Subject: [PATCH 15/18] add receipt in .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8489e37c..b404db53 100755 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ capybara-*.html /public/assets/* /public/uploads/* /public/swf/* +/public/receipts /coverage/ /spec/tmp/* *.orig From 694feb9c06420107806cc6d7c8b042fc3f7d8604 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 13 Mar 2018 14:46:07 +0630 Subject: [PATCH 16/18] For pull --- app/assets/javascripts/application.js | 20 +++++++ .../settings/display_images_controller.rb | 11 ++++ app/controllers/settings/shops_controller.rb | 16 ++++- app/models/display_image.rb | 5 ++ app/models/shop.rb | 3 + app/uploaders/display_image_uploader.rb | 59 +++++++++++++++++++ app/views/settings/shops/_form.html.erb | 29 ++++++++- app/views/settings/shops/show.html.erb | 8 +++ config/routes.rb | 5 +- 9 files changed, 151 insertions(+), 5 deletions(-) create mode 100644 app/controllers/settings/display_images_controller.rb create mode 100644 app/models/display_image.rb create mode 100644 app/uploaders/display_image_uploader.rb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 590657ef..e486c152 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -164,6 +164,26 @@ $(document).ready(function() { } }); + $("#shop_image").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); + // first input focus for all form $('form:first *input[data-behaviour!=datepicker]:input[type!=hidden]:first').focus(); diff --git a/app/controllers/settings/display_images_controller.rb b/app/controllers/settings/display_images_controller.rb new file mode 100644 index 00000000..48406f48 --- /dev/null +++ b/app/controllers/settings/display_images_controller.rb @@ -0,0 +1,11 @@ +class Settings::DisplayImagesController < ApplicationController + def destroy + #byebug + @item_photo = DisplayImage.find(params[:shop_id]) + item = @item_photo.id + @item_photo.destroy + respond_to do |format| + format.html {redirect_to settings_shops_url+'/1/edit', notice: 'Image was successfully destroyed.'} + end + end +end diff --git a/app/controllers/settings/shops_controller.rb b/app/controllers/settings/shops_controller.rb index f69aaac6..365be7e2 100644 --- a/app/controllers/settings/shops_controller.rb +++ b/app/controllers/settings/shops_controller.rb @@ -1,6 +1,6 @@ class Settings::ShopsController < ApplicationController load_and_authorize_resource except: [:create] - before_action :set_shop, only: [:show, :edit, :update] + before_action :set_shop, only: [:show, :edit, :update, :destroy] # GET /settings/shops # GET /settings/shops.json @@ -11,11 +11,13 @@ class Settings::ShopsController < ApplicationController # GET /settings/shops/1 # GET /settings/shops/1.json def show + @display_images = @settings_shop.display_images.all end # GET /settings/shops/new def new @settings_shop = Shop.new + @display_image = @settings_shop.display_images.build end # GET /settings/shops/1/edit @@ -28,6 +30,11 @@ class Settings::ShopsController < ApplicationController @settings_shop = Shop.new(shop_params) respond_to do |format| if @settings_shop.save + if params[:display_images].present? + params[:display_images]['image'].each do |a| + @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a) + end + end format.html { redirect_to settings_shops_url, notice: 'Shop was successfully created.' } format.json { render :index, status: :created, location: @settings_shop } else @@ -42,6 +49,11 @@ class Settings::ShopsController < ApplicationController def update respond_to do |format| if @settings_shop.update(shop_params) + if params[:display_images].present? + params[:display_images]['image'].each do |a| + @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a) + end + end format.html { redirect_to settings_shops_url, notice: 'Shop was successfully updated.' } format.json { render :index, status: :ok, location: @settings_shop } else @@ -71,6 +83,6 @@ class Settings::ShopsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def shop_params - params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info) + params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info, display_images_attributes: [:id, :shop_id, :image]) end end diff --git a/app/models/display_image.rb b/app/models/display_image.rb new file mode 100644 index 00000000..63405b26 --- /dev/null +++ b/app/models/display_image.rb @@ -0,0 +1,5 @@ +class DisplayImage < ApplicationRecord + mount_uploader :image, DisplayImageUploader + belongs_to :shop + +end diff --git a/app/models/shop.rb b/app/models/shop.rb index 0fd9ed0e..b0e84912 100755 --- a/app/models/shop.rb +++ b/app/models/shop.rb @@ -3,4 +3,7 @@ class Shop < ApplicationRecord # Shop Image Uploader mount_uploader :logo, ShopImageUploader + + has_many :display_images + accepts_nested_attributes_for :display_images end diff --git a/app/uploaders/display_image_uploader.rb b/app/uploaders/display_image_uploader.rb new file mode 100644 index 00000000..33e28997 --- /dev/null +++ b/app/uploaders/display_image_uploader.rb @@ -0,0 +1,59 @@ +class DisplayImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + # def root + # Rails.root.join 'public/' + # end + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + #"image/image" + "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # def cache_dir + # '/tmp/images' + # end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url(*args) + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process scale: [200, 300] + process :resize_to_fit => [200, 150] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process resize_to_fit: [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_whitelist + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end \ No newline at end of file diff --git a/app/views/settings/shops/_form.html.erb b/app/views/settings/shops/_form.html.erb index b615d189..0be7b052 100755 --- a/app/views/settings/shops/_form.html.erb +++ b/app/views/settings/shops/_form.html.erb @@ -2,7 +2,7 @@
- <%= simple_form_for([:settings,@settings_shop]) do |f| %> + <%= simple_form_for([:settings,@settings_shop], :html => { :multipart => true }) do |f| %> <%= f.error_notification %>
<%= f.input :name ,:input_html=>{:class=>"col-md-10"},:required=>true%> @@ -25,7 +25,7 @@ <%= f.input :show_account_info %>
- +
+ +
+
+ +
+
+ + +
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
diff --git a/app/views/settings/shops/show.html.erb b/app/views/settings/shops/show.html.erb index bea0ab38..d30ca274 100755 --- a/app/views/settings/shops/show.html.erb +++ b/app/views/settings/shops/show.html.erb @@ -99,6 +99,14 @@ Shop Image <%= image_tag @settings_shop.logo, :size => '200x200'%> + + Shop Images + + <% @display_images.each do |p| %> + <%= image_tag p.image , :size => '200x200'%>
+ <% end %> + + <%= link_to t("views.btn.edit"), edit_settings_shop_path(@settings_shop),:class => 'btn btn-primary btn-sm waves-effect' %> diff --git a/config/routes.rb b/config/routes.rb index 340dc914..6a4c403d 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -285,7 +285,10 @@ scope "(:locale)", locale: /en|mm/ do #--------- System Settings ------------# namespace :settings do - resources :shops + resources :shops do + resources :display_images + end + #employees resources :employees #menu From 9228168ebcdba53813c712b354839c2e725a1d5b Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 13 Mar 2018 14:51:07 +0630 Subject: [PATCH 17/18] route changes --- .gitignore | 1 + app/assets/javascripts/OQS.js | 76 ++- app/assets/javascripts/addorder.js | 17 +- .../channels/order_queue_station.js | 3 +- app/assets/javascripts/custom.js | 54 +- app/assets/javascripts/origami.js | 18 +- app/controllers/crm/customers_controller.rb | 10 +- app/controllers/home_controller.rb | 26 +- app/controllers/oqs/home_controller.rb | 20 +- .../origami/addorders_controller.rb | 7 +- .../origami/customers_controller.rb | 7 +- app/controllers/origami/home_controller.rb | 54 +- .../origami/payments_controller.rb | 59 +- app/controllers/origami/rooms_controller.rb | 54 +- app/models/ability.rb | 33 +- app/models/order.rb | 54 +- app/models/printer/receipt_printer.rb | 38 +- app/models/receipt.rb | 2 + app/models/receipt_detail.rb | 2 + app/models/sale.rb | 115 +++- app/models/sale_payment.rb | 4 +- app/pdf/receipt_bill_a5_pdf.rb | 11 +- app/pdf/receipt_bill_pdf.rb | 11 +- app/views/crm/customers/index.html.erb | 9 +- app/views/home/dashboard.html.erb | 11 +- app/views/layouts/_header.html.erb | 40 +- app/views/oqs/home/index.html.erb | 204 +++--- .../oqs/home/index_quechange_backup.html.erb | 196 ++++++ app/views/origami/customers/index.html.erb | 100 ++- app/views/origami/home/show.html.erb | 32 +- app/views/origami/master/index.html.erb | 38 +- .../origami/moveroom/move_dining.html.erb | 14 +- .../origami/movetable/move_dining.html.erb | 22 +- app/views/origami/mpu/index.html.erb | 55 +- app/views/origami/payments/show.html.erb | 613 ++++++++++++------ app/views/origami/pending_order/show.html.erb | 65 ++ app/views/origami/rooms/show.html.erb | 49 +- app/views/origami/unionpay/index.html.erb | 42 +- app/views/origami/visa/index.html.erb | 83 ++- config/routes.rb | 5 +- db/migrate/20170530072247_create_shops.rb | 3 + .../20170628103624_create_print_settings.rb | 4 +- db/migrate/20180306044939_create_receipts.rb | 42 ++ .../20180306045018_create_receipt_details.rb | 43 ++ db/sym_master.sql | 18 +- lib/tasks/clear_data.rake | 1 + lib/tasks/receipt.rake | 238 +++++++ spec/models/receipt_detail_spec.rb | 5 + spec/models/receipt_spec.rb | 5 + 49 files changed, 1906 insertions(+), 707 deletions(-) create mode 100644 app/models/receipt.rb create mode 100644 app/models/receipt_detail.rb mode change 100755 => 100644 app/views/oqs/home/index.html.erb create mode 100755 app/views/oqs/home/index_quechange_backup.html.erb create mode 100644 db/migrate/20180306044939_create_receipts.rb create mode 100644 db/migrate/20180306045018_create_receipt_details.rb create mode 100644 lib/tasks/receipt.rake create mode 100644 spec/models/receipt_detail_spec.rb create mode 100644 spec/models/receipt_spec.rb diff --git a/.gitignore b/.gitignore index 8489e37c..b404db53 100755 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ capybara-*.html /public/assets/* /public/uploads/* /public/swf/* +/public/receipts /coverage/ /spec/tmp/* *.orig diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index ec3db11f..2bbf07bb 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -31,30 +31,75 @@ $(document).on('turbolinks:load', function() { $(".oqs_append").addClass('hide') }); + $(".tables").on("click", function(){ + + var table_id = $(this).val(); + $('#table_id').val(table_id); + oqs_id = $("#oqs_id").val(); + if (table_id){ + var table = table_id + }else{ + var table = null + } + + if (oqs_id > 0) { + $(".oqs_click").removeClass('oqs_active'); + $(".queue_station").removeClass('queue_station_box'); + $("#completed").addClass('hide'); + $(".oqs_append").removeClass('hide'); + $("#oqs_active").addClass('oqs_active'); + $(".queue_station").addClass('queue_station_box'); + // oqs_id = $(this).find(".oqs-id").text(); + $("#oqs_active").attr('data-id',oqs_id); + var url = 'oqs/get_items/'+oqs_id; + + show_details(url,table); + }else{ + $("#completed").removeClass('hide') + $(".oqs_append").addClass('hide') + } + }); + $(".oqs_click").on("click", function(){ - $(".oqs_click").removeClass('oqs_active'); - $(".queue_station").removeClass('queue_station_box'); - $("#completed").addClass('hide'); - $(".oqs_append").removeClass('hide'); - $(this).addClass('oqs_active'); - $(".queue_station").addClass('queue_station_box'); - oqs_id = $(this).find(".oqs-id").text(); - console.log(oqs_id); - var url = 'oqs/get_items/'+oqs_id; - - show_details(url); + oqs_id = $(this).val(); + var table_id = $('#table_id').val(); + if (table_id){ + var table = table_id + }else{ + var table = null + } + + if (oqs_id > 0) { + $(".oqs_click").removeClass('oqs_active'); + $(".queue_station").removeClass('queue_station_box'); + $("#completed").addClass('hide'); + $(".oqs_append").removeClass('hide'); + $("#oqs_active").addClass('oqs_active'); + $(".queue_station").addClass('queue_station_box'); + // oqs_id = $(this).find(".oqs-id").text(); + $("#oqs_active").attr('data-id',oqs_id); + var url = 'oqs/get_items/'+oqs_id; + + show_details(url,table); + }else{ + $("#completed").removeClass('hide') + $(".oqs_append").addClass('hide') + } + }); //End Click - function show_details(url){ + function show_details(url,table_id){ var oqs_append = $('.oqs_append'); oqs_append.empty(); var filter = $('.filter').text(); + + console.log(table_id) //Start Ajax $.ajax({ type: "GET", url: url, - data: {'filter':filter}, + data: {'filter':filter,'table_id':table_id}, dataType: "json", success: function(data) { for(var field in data) { @@ -67,7 +112,8 @@ $(document).on('turbolinks:load', function() { } var date = new Date(data[field]["created_at"]); - var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); + // var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); + var show_date =date.getHours()+ ':' + date.getMinutes() +' '+(date.getHours() >= 12 ? 'PM' : 'AM'); var set_menu_items = data[field]["set_menu_items"]; var set_instance_items = ""; if(set_menu_items!=null){ @@ -100,7 +146,7 @@ $(document).on('turbolinks:load', function() { +set_instance_items +'

' - +'

'+ options +'

' + +'

'+ options +'

' +'' +'Order at - ' diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 69ac19d4..b0c51031 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -46,8 +46,8 @@ $(function() { + product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '" + JSON.stringify(item_attributes) +"' data-options = '" + options +"' data-image='"+image_path+"'>" - +"" - +'add' + +"" + +'view_list' +'
' +'
' @@ -146,7 +146,7 @@ $(function() { promotion_price = menu_items[field].promotion_price; }else{ fa_plus = 'material-icons'; - add = 'add' + add = 'view_list' menu_item_box = 'menu_item_box'; data_target = 'sx_item_detailModal'; data_modal = '' @@ -760,7 +760,6 @@ $(function() { $("#oqs_loading_wrapper").show(); type = window.location.href.indexOf("quick_service"); - if (type != -1) { type = 'quick_service' var table_type = $('#table_type').text(); @@ -985,19 +984,19 @@ $(function() { $("#back").on("click", function(){ var table_id = $('#table_id').text(); var table_type = $('#table_type').text(); - type = window.location.href.indexOf("quick_service"); - if (type == 'true') { + type = window.location.href.includes("quick_service"); + if (type == true) { var table_type = $('#table_id').find("option:selected").data('type'); var table_id = $('#table_id').val(); - window.location.href = "/origami/dashboard" + window.location.href = "/origami/dashboard"; }else{ var table_type = $('#table_type').text(); var table_id = $('#table_id').text(); if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id + window.location.href = "/origami/table/" + table_id; }else { - window.location.href = "/origami/room/" + table_id + window.location.href = "/origami/room/" + table_id; } } }); diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index d2b502d4..c8b59231 100755 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -5,8 +5,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann disconnected: function() {}, - received: function(data) { - // console.log(data.order); + received: function(data) { var oqs_id = $('.oqs_active').attr('data-id'); items = data.order; for(var field in items) { diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index f33f6d11..a2011022 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -20,33 +20,33 @@ $(document).ready(function() { borderRadius: '0', railBorderRadius: '0' }); - - $('.delete').click(function(){ - var method = $(this).attr('data-method'); - var url = $(this).attr('data-ref'); - var html_text = $(this).siblings( "#delete_text" ).html(); - //var page = url.substring(url.lastIndexOf('/') + 1); - swal({ - title: "Confirmation", - text: html_text, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - html: true - }, function (isConfirm) { - if (isConfirm) { - $.ajax({ - type: method, - url: url , - success: function(data) { - location.href = data.url; - } - }); - } else { - swal("Cancelled", "Your imaginary file is safe :)", "error"); - } - }); - }); + + // $('.delete').click(function(){ + // var method = $(this).attr('data-method'); + // var url = $(this).attr('data-ref'); + // var html_text = $(this).siblings( "#delete_text" ).html(); + // //var page = url.substring(url.lastIndexOf('/') + 1); + // swal({ + // title: "Confirmation", + // text: html_text, + // type: "warning", + // showCancelButton: true, + // confirmButtonColor: "#DD6B55", + // html: true + // }, function (isConfirm) { + // if (isConfirm) { + // $.ajax({ + // type: method, + // url: url , + // success: function(data) { + // location.href = data.url; + // } + // }); + // } else { + // swal("Cancelled", "Your imaginary file is safe :)", "error"); + // } + // }); + // }); // for Notificaiotn message var placementFrom = $("#notify_message").attr('data-placement-from'); diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 0f5380a7..418b6ebe 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -255,14 +255,14 @@ function setCommPorts(comPortLists) { } /** pay with CB bank **/ -function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no) { +function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) { $("#loading_wrapper").show(); var com_port = $("#com_port_name").val(); - reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port); + reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type); } //add req data to card_sale_trans table -function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port) { +function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type) { var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port}; $.ajax({ type: "POST", @@ -272,14 +272,14 @@ function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, rece success: function(data) { if (data.status == "success"){ card_sale_trans_id = data.card_sale_trans_id; - resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port); + resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type); } } }); } //add res data to card_sale_trans table -function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port) { +function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type) { var resMsg = ""; var card_payment_type=""; @@ -306,7 +306,7 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo dataType: "json", success: function(data) { if(data.status == "success"){ - resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port); + resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type); } } }); @@ -317,7 +317,7 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo } -function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port) { +function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type) { $("#loading_wrapper").hide(); var jobj = $.parseJSON(resMsg); if(jobj.STATUS == "Approved"){ @@ -334,7 +334,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun closeOnCancel: false, allowOutsideClick: false }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment"; }); } } @@ -352,7 +352,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun closeOnCancel: false, allowOutsideClick: false }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment/"+payment_type; + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/"+payment_type; }); } } diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 42ea4b2f..eb9dc653 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -167,7 +167,7 @@ class Crm::CustomersController < BaseCrmController status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' } else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} end @@ -186,21 +186,21 @@ class Crm::CustomersController < BaseCrmController if response["message"] == "Account has not exist." customer.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer cannot created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]} else format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] } end end if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]} else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response["message"] } end end else if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. noted'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created. noted'} else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } end @@ -209,7 +209,7 @@ class Crm::CustomersController < BaseCrmController if params[:sale_id] flash[:errors] = @crm_customers.errors - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page]} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } else flash[:errors] = @crm_customers.errors diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d59a5af3..147b2ee4 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -92,13 +92,15 @@ class HomeController < ApplicationController @sale_data = Array.new @total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to) - @total_payment_methods.each do |payment| - if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" - pay = Sale.payment_sale('card', today, current_user,@from,@to) - @sale_data.push({'card' => pay.payment_amount}) - else - pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to) - @sale_data.push({payment.payment_method => pay.payment_amount}) + if !@total_payment_methods.nil? + @total_payment_methods.each do |payment| + if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" + pay = Sale.payment_sale('card', today, current_user,@from,@to) + @sale_data.push({'card' => pay.payment_amount}) + else + pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to) + @sale_data.push({payment.payment_method => pay.payment_amount}) + end end end @summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to) @@ -111,10 +113,12 @@ class HomeController < ApplicationController @total_order = Sale.total_order(today,current_user,@from,@to) @total_accounts = Sale.total_account(today,current_user,@from,@to) @account_data = Array.new - @total_accounts.each do |account| - acc = Sale.account_data(account.account_id, today,current_user,@from,@to) - if !acc.nil? - @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) + if !@total_accounts.nil? + @total_accounts.each do |account| + acc = Sale.account_data(account.account_id, today,current_user,@from,@to) + if !acc.nil? + @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) + end end end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 58b2910b..19d4c17f 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -7,7 +7,8 @@ class Oqs::HomeController < BaseOqsController # @queue_items_details = queue_items_query(false) # Query for OQS with delivery status true - + @tables = DiningFacility.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') @filter = params[:filter] @@ -113,7 +114,11 @@ class Oqs::HomeController < BaseOqsController def get_items_by_oqs oqs_id = params[:id] filter = params[:filter] - items = queue_items_query(false,oqs_id,filter) + table_id = params[:table_id] + puts params + puts table_id + puts "sssssssssssss" + items = queue_items_query(false,oqs_id,filter,table_id) if !items.empty? items.each do |item| if !item.set_menu_items.nil? @@ -151,13 +156,20 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with delivery status - def queue_items_query(status,oqs_id=nil,filter) + def queue_items_query(status,oqs_id=nil,filter,table_id) if oqs_id == nil oqs = '' else oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' " end + if table_id.to_i>0 + table = "and df.id = '#{table_id}' " + + else + table = '' + end + query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, @@ -173,7 +185,7 @@ class Oqs::HomeController < BaseOqsController left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") - .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ") + .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table}") query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) .order("assigned_order_items.assigned_order_item_id desc") .group("odt.order_items_id") diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index c3e6766e..3b05856f 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -103,10 +103,15 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController } # begin + if params[:order_source] == "quick_service" + customer_id = "CUS-000000000002" # for no customer id from mobile + else + customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + end @order = Order.new @order.source = params[:order_source] @order.order_type = params[:order_type] - @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + @order.customer_id = customer_id @order.items = items_arr @order.guest = params[:guest_info] @order.table_id = params[:table_id] # this is dining facilities's id diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index d93e5040..234a1dc5 100755 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -50,6 +50,7 @@ class Origami::CustomersController < BaseOrigamiController @sale_id = params[:sale_id] @cashier_type = params[:type] + @page = params[:page] if(@sale_id[0,3] == "SAL") @booking = Booking.find_by_sale_id(@sale_id) @@ -62,7 +63,11 @@ class Origami::CustomersController < BaseOrigamiController else @booking_order = BookingOrder.find_by_order_id(@sale_id) @booking = Booking.find(@booking_order.booking_id) - @dining_facility = DiningFacility.find(@booking.dining_facility_id) + if @booking.dining_facility_id.to_i > 0 + @dining_facility = DiningFacility.find(@booking.dining_facility_id) + else + @dining_facility = nil + end end filter = params[:filter] diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 14a2a93b..184daca4 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -30,33 +30,33 @@ class Origami::HomeController < BaseOrigamiController bookings = Booking.all if !bookings.today.nil? @order_items_count = Hash.new - bookings.each do |booking| - if booking.sale_id.nil? && booking.booking_status != 'moved' - if !booking.booking_orders.empty? - booking.booking_orders.each do |booking_order| - order = Order.find(booking_order.order_id) - if !order.order_items.empty? - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, order.order_items.count) - else - @order_items_count[booking.dining_facility_id] += order.order_items.count - end - end - end - end - else - if !booking.sale_id.nil? - sale = Sale.find(booking.sale_id) - if sale.sale_status !='completed' - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) - else - @order_items_count[booking.dining_facility_id] = sale.sale_items.count - end - end - end - end - end + # bookings.each do |booking| + # if booking.sale_id.nil? && booking.booking_status != 'moved' + # if !booking.booking_orders.empty? + # booking.booking_orders.each do |booking_order| + # order = Order.find(booking_order.order_id) + # if !order.order_items.empty? + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, order.order_items.count) + # else + # @order_items_count[booking.dining_facility_id] += order.order_items.count + # end + # end + # end + # end + # else + # if !booking.sale_id.nil? + # sale = Sale.find(booking.sale_id) + # if sale.sale_status !='completed' + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + # else + # @order_items_count[booking.dining_facility_id] = sale.sale_items.count + # end + # end + # end + # end + # end end @dining.bookings.active.each do |booking| diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 64b0bde5..6a726199 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -28,8 +28,21 @@ class Origami::PaymentsController < BaseOrigamiController end if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf # Print for First Bill to Customer unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + #shop detail shop_details = Shop::ShopDetail # customer= Customer.where('customer_id=' +.customer_id) @@ -95,7 +108,6 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") - render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "}) rebate_amount = nil # For Cashier by Zone @@ -118,7 +130,20 @@ class Origami::PaymentsController < BaseOrigamiController # For Print if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + customer= Customer.find(saleObj.customer_id) # get member information @@ -151,7 +176,9 @@ class Origami::PaymentsController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data) + + render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) if params[:type] == "quick_service" booking = Booking.find_by_sale_id(sale_id) @@ -437,5 +464,31 @@ class Origami::PaymentsController < BaseOrigamiController end end end - + + #print function for receipt + def print + filename = params[:filename] + receipt_no = params[:receipt_no] + printer_name = params[:printer_name] + + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) + + render :json => {status: true} + end end \ No newline at end of file diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index f3b11556..3aa98282 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -26,33 +26,33 @@ class Origami::RoomsController < BaseOrigamiController bookings = Booking.all if !bookings.today.nil? @order_items_count = Hash.new - bookings.each do |booking| - if booking.sale_id.nil? && booking.booking_status != 'moved' - if !booking.booking_orders.empty? - booking.booking_orders.each do |booking_order| - order = Order.find(booking_order.order_id) - if !order.order_items.empty? - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, order.order_items.count) - else - @order_items_count[booking.dining_facility_id] += order.order_items.count - end - end - end - end - else - if !booking.sale_id.nil? - sale = Sale.find(booking.sale_id) - if sale.sale_status !='completed' - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) - else - @order_items_count[booking.dining_facility_id] = sale.sale_items.count - end - end - end - end - end + # bookings.each do |booking| + # if booking.sale_id.nil? && booking.booking_status != 'moved' + # if !booking.booking_orders.empty? + # booking.booking_orders.each do |booking_order| + # order = Order.find(booking_order.order_id) + # if !order.order_items.empty? + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, order.order_items.count) + # else + # @order_items_count[booking.dining_facility_id] += order.order_items.count + # end + # end + # end + # end + # else + # if !booking.sale_id.nil? + # sale = Sale.find(booking.sale_id) + # if sale.sale_status !='completed' + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + # else + # @order_items_count[booking.dining_facility_id] = sale.sale_items.count + # end + # end + # end + # end + # end end @room.bookings.active.each do |booking| diff --git a/app/models/ability.rb b/app/models/ability.rb index 33372ac9..95c6005f 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -65,7 +65,8 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment - can :foc, :payment + can :foc, :payment + can :print, :payment can :move_dining, :movetable can :moving, :movetable @@ -111,10 +112,10 @@ class Ability can :index, :other_charge can :create, :other_charge - # can :index, :discount - # can :create, :discount - # can :remove_discount_items, :discount - # can :remove_all_discount, :discount + can :index, :discount + can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount can :member_discount, :discount can :first_bill, :payment @@ -122,6 +123,7 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment + can :print, :payment can :move_dining, :movetable can :moving, :movetable @@ -180,6 +182,7 @@ class Ability can :show, :payment can :reprint, :payment can :rounding_adj, :payment + can :print, :payment can :manage, Commission can :manage, Commissioner @@ -191,6 +194,26 @@ class Ability elsif user.role == "waiter" can :index, :home can :show, :home + + can :manage, Customer + can :get_customer, Customer + can :add_customer, Customer + can :update_sale_by_customer, Customer + + can :index, :other_charge + can :create, :other_charge + can :index, :discount + can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount + can :member_discount, :discount + + #ability for move table + can :move_dining, :movetable + can :moving, :movetable + + can :move_dining, :moveroom + #ability for split_bill can :index, :split_bill can :create, :split_bill diff --git a/app/models/order.rb b/app/models/order.rb index 15ce56c3..739de71a 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -286,23 +286,51 @@ class Order < ApplicationRecord #Process order items and send to order queue def process_order_queue #Send to background job for processing - - cup_status = `#{"sudo service cups status"}` + order = Order.find(self.id) + cup_status = `#{"sudo service cups status"}` print_status = check_cup_status(cup_status) - + sidekiq = Lookup.find_by_lookup_type("sidekiq") + if print_status - OrderQueueProcessorJob.perform_later(self.id, self.table_id) + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(self.id, self.table_id) + else + if order + oqs = OrderQueueStation.new + oqs.process_order(order, self.table_id) + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end else cup_start = `#{"sudo service cups start"}` cup_status = `#{"sudo service cups status"}` print_status = check_cup_status(cup_status) if print_status - OrderQueueProcessorJob.perform_later(self.id, self.table_id) + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(self.id, self.table_id) + else + if order + oqs = OrderQueueStation.new + oqs.process_order(order, self.table_id) + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end else msg = ' Print Error ! Please contact to service' ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error' - OrderQueueProcessorJob.perform_later(self.id, self.table_id) + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(self.id, self.table_id) + else + if order + oqs = OrderQueueStation.new + oqs.process_order(order, self.table_id) + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end end end @@ -310,8 +338,18 @@ class Order < ApplicationRecord #Process order items and send to order queue def self.pay_process_order_queue(id,table_id) - #Send to background job for processing - OrderQueueProcessorJob.perform_later(id, table_id) + sidekiq = Lookup.find_by_lookup_type("sidekiq") + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(id, table_id) + else + order = Order.find(id) + if order + oqs = OrderQueueStation.new + oqs.process_order(order, table_id) + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end end def check_cup_status(status) diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 0cf6526f..d544c908 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -197,17 +197,28 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker print_settings.print_copies = 1 print_settings.save! + directory_name = 'public/receipts' + Dir.mkdir(directory_name) unless File.exists?(directory_name) + begin if count == 1 - pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf" - self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name) + filename = "/receipts/receipt_bill_#{sale_data.receipt_no}.pdf" + pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf" + if printed_status != 'Paid' + self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name) + end else - pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" - self.print("tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name) + filename = "/receipts/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" + pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" + if printed_status != 'Paid' + self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name) + end end count -= 1 end until count == 0 + + return filename, sale_data.receipt_no, cashier_terminal.printer_name end # stock check @@ -247,4 +258,23 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print("tmp/print_call_waiter.pdf") end + #print receipt pdf from js + def print_receipt_pdf(filename,receipt_no,print_copies,printer_name) + count = print_copies.to_i + # if count == 0 + # self.print("public"+filename, printer_name) + # else + begin + if count == 1 + self.print("public"+filename, printer_name) + else + filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf" + self.print(filename, printer_name) + end + + count -= 1 + end until count == 0 + # end + end + end diff --git a/app/models/receipt.rb b/app/models/receipt.rb new file mode 100644 index 00000000..40ad3176 --- /dev/null +++ b/app/models/receipt.rb @@ -0,0 +1,2 @@ +class Receipt < ApplicationRecord +end diff --git a/app/models/receipt_detail.rb b/app/models/receipt_detail.rb new file mode 100644 index 00000000..c96e3d4e --- /dev/null +++ b/app/models/receipt_detail.rb @@ -0,0 +1,2 @@ +class ReceiptDetail < ApplicationRecord +end diff --git a/app/models/sale.rb b/app/models/sale.rb index 54c60eb3..29e32c14 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -548,11 +548,22 @@ class Sale < ApplicationRecord #Generate new Receipt No when it is not assigned def generate_receipt_no + #shop_code and client_code + shop_details = Shop::ShopDetail + #Date-Shift- if self.receipt_no.nil? prefix = DateTime.now().utc #self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s - self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + if !shop_details.nil? + if !shop_details.shop_code.nil? + self.receipt_no = shop_details.shop_code + "-" + prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + else + self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + end + else + self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + end self.receipt_date = prefix Rails.logger.debug "Receipt No #{self.receipt_no} | Date #{ self.receipt_date.to_s}" @@ -1170,7 +1181,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total") else shift = ShiftSale.current_open_shift(current_user.id) @@ -1184,7 +1195,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") else shift = ShiftSale.current_open_shift(current_user.id) @@ -1202,7 +1213,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count else shift = ShiftSale.current_open_shift(current_user.id) @@ -1215,7 +1226,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count else shift = ShiftSale.current_open_shift(current_user.id) @@ -1234,7 +1245,7 @@ end .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") @@ -1253,7 +1264,7 @@ end .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") @@ -1276,7 +1287,7 @@ end .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and s.receipt_date between ? and ?',from,to) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") @@ -1295,7 +1306,7 @@ end .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") @@ -1318,7 +1329,7 @@ end .where('sale_status = "completed" and receipt_date between ? and ?',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') .where('sale_status = "completed" and receipt_date between ? and ?',from,to) .first() @@ -1337,7 +1348,7 @@ end .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .first() @@ -1360,7 +1371,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct sp.payment_method") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") @@ -1379,7 +1390,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct sp.payment_method") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") @@ -1406,7 +1417,7 @@ end end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") if payment_method == 'card' query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) @@ -1437,7 +1448,7 @@ end end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") if payment_method == 'card' query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today) @@ -1482,7 +1493,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to) @@ -1504,7 +1515,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) @@ -1530,7 +1541,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to) @@ -1552,7 +1563,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) @@ -1578,7 +1589,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to) @@ -1600,7 +1611,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) @@ -1626,7 +1637,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to) @@ -1648,7 +1659,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) @@ -1675,7 +1686,7 @@ end .where('b.status = "billed" and sales.receipt_date between ? and ?',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") @@ -1700,7 +1711,7 @@ end .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") @@ -1728,7 +1739,7 @@ end .joins("JOIN accounts as b ON b.id = a.account_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") @@ -1750,7 +1761,7 @@ end .joins("JOIN accounts as b ON b.id = a.account_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") @@ -1776,7 +1787,7 @@ end .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to) @@ -1798,7 +1809,7 @@ end .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) @@ -1826,7 +1837,7 @@ end .order("SUM(a.qty) DESC") .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between ? and ?",from,to) @@ -1854,7 +1865,7 @@ end .order("SUM(a.qty) DESC") .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) @@ -1883,7 +1894,7 @@ end .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to) .sum("a.qty") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to) .sum("a.qty") @@ -1902,7 +1913,7 @@ end .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .sum("a.qty") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .sum("a.qty") @@ -2011,6 +2022,44 @@ end .group("bookings.booking_id") end + def self.all_receipts + query = Sale.select("sales.*, sale_payments.created_at as receipt_close_time, + case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark, + case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges, + SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, + SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount, + SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount, + SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, + SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount, + SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount, + SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount, + SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc, + SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount, + SUM(sale_items.qty) as qty, + sales.cashier_name as cashier_name, + surveys.child as child, + surveys.adult as adult") + .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") + .joins("join sale_taxes on sale_taxes.sale_id = sales.sale_id") + .joins("join sale_items on sale_items.sale_id = sales.sale_id") + .joins("join sale_audits on sale_audits.sale_id = sales.sale_id") + .joins("left join surveys on surveys.receipt_no = sales.receipt_no") + + query = query.where("sale_status != 'new' && sale_payments.payment_amount > 0") + .group("sale_id") + return query +end + +def self.all_receipt_details + query = SaleItem.select("sale_items.*, sale_payments.created_at as receipt_close_time, + sales.requested_at as requested_at, sales.receipt_no as receipt_no,sales.sale_id as s_id") + .joins("join sale_payments on sale_payments.sale_id = sale_items.sale_id") + .joins("join sales on sales.sale_id = sale_items.sale_id") + .group("sale_items.sale_item_id") + query = query.where("qty > 0 and sales.sale_status !='new'") + return query +end + private def generate_custom_id diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index bb74c2f2..1866a630 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -356,10 +356,10 @@ class SalePayment < ApplicationRecord self.sale.save! table_update_status(sObj) - + if check_foc update_shift - elsif paid_amount != "0.0" + elsif paid_amount.to_f > 0 #|| paid_amount != "0.0" update_shift end end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index ee9a1bda..206c7a0a 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -112,6 +112,7 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left end + if sale_data.bookings[0].dining_facility_id.to_i > 0 bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right @@ -121,10 +122,16 @@ class ReceiptBillA5Pdf < Prawn::Document move_down line_move y_position = cursor - bounding_box([0, y_position], :width =>self.item_description_width, :height => self.item_height) do + if sale_data.bookings[0].dining_facility_id.to_i > 0 + bounding_box([0, y_position], :width => self.item_description_width, :height => self.item_height) do + text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :left + end + end + + bounding_box([self.item_description_width, y_position], :width =>self.item_description_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left end - bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do + bounding_box([self.item_description_width - 2,y_position], :width =>self.item_description_width, :height => self.item_height) do text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right end move_down line_move diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 0f02d506..efc85c7f 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -108,9 +108,10 @@ class ReceiptBillPdf < Prawn::Document move_down line_move # move_down 2 y_position = cursor - bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left end + if sale_data.bookings[0].dining_facility_id.to_i > 0 bounding_box([self.description_width - 2,y_position], :width => self.price_num_width, :height => self.item_height) do text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right @@ -120,7 +121,13 @@ class ReceiptBillPdf < Prawn::Document move_down line_move y_position = cursor - bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do + if sale_data.bookings[0].dining_facility_id.to_i > 0 + bounding_box([0,y_position], :width => self.label_width, :height => self.item_height) do + text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :left + end + end + + bounding_box([self.label_width, y_position], :width =>self.label_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index d05af387..372c05e9 100755 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -23,10 +23,10 @@
- + - - + +
<% end %>
@@ -145,7 +145,8 @@ $(function() { $("#qr_code").on('click', function(e){ var code = ""; setTimeout(function(){ - var hi=getQRCode(); + code=getQRCode(); + setQRCode(code); },100); }); diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 50673b5f..aee947c7 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -228,16 +228,15 @@ <% else %>
<% end %> + <% if !@total_customer.nil? && @total_customer.to_i > 0 %>
<%= t :customer %>
- <% if !@total_customer.nil? %> - <% end %> <% if !@total_dinein.nil? %> @@ -265,6 +264,7 @@
<%= t("views.right_panel.detail.total") %> <%= t :customer %> : <%= @total_customer %>
<%= t("views.right_panel.detail.dine_in") %> :
+ <% end %>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
@@ -316,9 +316,10 @@
-
-
-
+
+ <% if current_user.role == 'administrator' || current_user.role == 'manager' %> +
+ <% end %> <% end %>
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 15dfdfbe..e3e7adda 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -16,7 +16,11 @@ <%if current_login_employee.role !="waiter" %> - + <% if current_login_employee.role != "cashier" %> + + <% else %> + + <% end %> <% else %> <%end%> @@ -56,13 +60,11 @@ <% end %>
  • - - -

    +

    exit_to_app Logout

    @@ -79,9 +81,39 @@
  • + \ No newline at end of file diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb old mode 100755 new mode 100644 index 33ee74b7..585f9968 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -1,137 +1,115 @@ -
    -
    +
    +
    - <%= form_tag oqs_root_path, :method => :get do %>
    - - + +
    -
    - +
    + +
    - +
    - <% end %>
    - - -
    - - - -
    - - + + +
    +
    +
    -
    +
    <% @queue_completed_item.each do |qid| %>
    -
    - <%if qid.type.present?%> - <%= qid.type %>-<%= qid.zone %> - <%else%> - - <%end%> - - - <%= qid.order_id %> -
    -

    - - <%= qid.item_name %> - [x - - <%= qid.qty %> - ] - <% if !qid.set_menu_items.nil? %> - <% qid.set_menu_items.each do |item_instance|%> -
    - <%= item_instance %> - - <% end %> - <% end %> -

    - -

    <%= qid.options == "[]"? "" : qid.options %>

    +
    + <%if qid.type.present?%> + <%= qid.type %>-<%= qid.zone %> + <%else%> + + <%end%> - - Order at - - - <%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> -
    - Order By - - <%= qid.item_order_by %> - + + <%= qid.order_id %> +
    +

    + + <%= qid.item_name %> + [x + + <%= qid.qty %> + ] + <% if !qid.set_menu_items.nil? %> + <% qid.set_menu_items.each do |item_instance|%> +
    + <%= item_instance %> + + <% end %> + <% end %> +

    + +

    <%= qid.options == "[]"? "" : qid.options %>

    + + + Order at - + + <%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> +
    + Order By - + <%= qid.item_order_by %> + +
    - - +
    -
    - <% - end - %> +
    + <% end %>
    -
    +
    - - -
    -
    +
    +
    +
    -
    + - - - + --> + +
    - + -->
    +
    reply Back <% if ENV["SERVER_MODE"] != "cloud" %> +
    + +
    + <% end %> +
    + + + + + + +
    + + +
    +
    + <% + @queue_completed_item.each do |qid| + %> +
    +
    +
    + <%if qid.type.present?%> + <%= qid.type %>-<%= qid.zone %> + <%else%> + + <%end%> + + + <%= qid.order_id %> +
    +

    + + <%= qid.item_name %> + [x + + <%= qid.qty %> + ] + <% if !qid.set_menu_items.nil? %> + <% qid.set_menu_items.each do |item_instance|%> +
    + <%= item_instance %> + + <% end %> + <% end %> +

    + +

    <%= qid.options == "[]"? "" : qid.options %>

    + + + Order at - + + <%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> +
    + Order By - + <%= qid.item_order_by %> + +
    +
    + + + + +
    +
    + <% + end + %> +
    +
    + + + + +
    +
    + +
    +
    + + +
    +
    +
    +
    ORDER DETAILS
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + +
    Order ByOrder At
    +
    +
    + + + + + + + + + + +
    ItemsQTY
    +
    +
    +
    +
    + + +
    + + reply Back + <% if ENV["SERVER_MODE"] != "cloud" %> + + <%end%> +
    + + + diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index eebaabbf..87ff1144 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -34,12 +34,14 @@ -
    - -
    + + + + + <% end %> @@ -114,6 +116,8 @@ + + <%if !@dining_facility.nil?%> @@ -262,7 +266,8 @@ \ No newline at end of file diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb index d94a81d5..fade7ccb 100644 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -153,6 +153,14 @@ <% if current_user.role != "waiter" || @status != "sale"%> <%end%> + <% if current_user.role != "waiter" && @status != "order"%> <%end%> @@ -163,6 +171,7 @@ diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 4cd6a846..1edb07cf 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -50,11 +50,11 @@ <% end %>
    <%= table.name %> - <% if !@order_items_count.nil? %> + billed
    @@ -66,11 +66,11 @@ <% end %>
    <%= table.name %> - <% if !@order_items_count.nil? %> + new
    @@ -97,11 +97,11 @@
    <%= room.name %> - <% if !@order_items_count.nil? %> + billed
    @@ -110,11 +110,11 @@
    <%= room.name %> - <% if !@order_items_count.nil? %> + new
    @@ -193,12 +193,15 @@
    <% if @status_sale == 'sale' %> -
    +
      Receipt No: <%= @obj_sale.receipt_no rescue '' %>
    +
    + Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
    <% else %>
      Order No: @@ -206,17 +209,10 @@ <%= @obj_order.order_id rescue '' %>
    - <% end %> - <% if @status_sale == 'sale' %> -
    - Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> -
    - <% else %> -
    +
    Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y") rescue '-'%>
    <% end %> -
    @@ -396,10 +392,7 @@ - <% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %> - <% end %> - <% if current_login_employee.role != "waiter" %> <% if @room.bookings.length >= 1 %> <% if @status_order == 'order' && @status_sale != 'sale' %> @@ -423,14 +416,14 @@ <% if current_login_employee.role != "waiter" %> + + @@ -485,11 +478,11 @@ <% end %> <% end %> - <% end %>
    diff --git a/config/routes.rb b/config/routes.rb index 6a4c403d..17b3bb0c 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -165,6 +165,7 @@ scope "(:locale)", locale: /en|mm/ do post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj', :as => "calculate_rouding_adjs" get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => {:format => 'json'} get 'sale/:sale_id/:type/payment' => 'payments#show' + post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt post 'payment/foc' => 'payments#foc', :defaults => {:format => 'json'} post 'payment/cash' => 'payments#create' @@ -198,9 +199,9 @@ scope "(:locale)", locale: /en|mm/ do #---------Add Customer --------------# #resources :customers - get '/:sale_id/:type/customers', to: "customers#add_customer" + get '/:sale_id/:type/customers/:page', to: "customers#add_customer" get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details" - post '/:sale_id/:type/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table + post '/:sale_id/:type/customers/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table post '/:sale_id/get_customer' => "customers#get_customer" diff --git a/db/migrate/20170530072247_create_shops.rb b/db/migrate/20170530072247_create_shops.rb index bd25c970..1c87b505 100755 --- a/db/migrate/20170530072247_create_shops.rb +++ b/db/migrate/20170530072247_create_shops.rb @@ -3,6 +3,9 @@ class CreateShops < ActiveRecord::Migration[5.1] create_table :shops do |t| t.string :logo t.string :name, :null => false + t.string :shop_code, :null => false + t.string :client_name, :null => false + t.string :client_code, :null => false t.string :address, :null => false t.string :township, :null => false t.string :city, :null => false diff --git a/db/migrate/20170628103624_create_print_settings.rb b/db/migrate/20170628103624_create_print_settings.rb index 329d3a7c..672953fc 100755 --- a/db/migrate/20170628103624_create_print_settings.rb +++ b/db/migrate/20170628103624_create_print_settings.rb @@ -6,7 +6,9 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1] t.string :template t.string :font, :default => "" t.string :printer_name, :null => false - t.string :api_settings + t.string :api_settings, + t.string :brand_name + t.string :type t.decimal :page_width, :null => false, :default => 210 t.decimal :page_height, :null => false, :default => 1450 t.integer :print_copies, :null => false, :default => 1 diff --git a/db/migrate/20180306044939_create_receipts.rb b/db/migrate/20180306044939_create_receipts.rb new file mode 100644 index 00000000..22f3b0fa --- /dev/null +++ b/db/migrate/20180306044939_create_receipts.rb @@ -0,0 +1,42 @@ +class CreateReceipts < ActiveRecord::Migration[5.1] + def change + create_table :receipts do |t| + t.string :client_code, :limit => 16, :null => false + t.string :client_name, :null => false + t.string :shop_code, :limit => 16, :null => false + t.string :shop_name, :null => false + t.integer :receipt_no, :limit => 8, :null => false + t.datetime :transaction_time, :null => false + t.datetime :receipt_open_time, :null => false + t.datetime :receipt_close_time, :null => false + t.decimal :gross_sales, :null => false, :default => 0 + t.decimal :discount_amount, :null => false, :default => 0 + t.decimal :sales, :null => false, :default => 0 + t.decimal :tax_amount, :null => false, :default => 0 + t.decimal :service_charges, :null => false, :default => 0 + t.decimal :net_sales, :null => false, :default => 0 + t.decimal :credit_card_sales, :null => false, :default => 0 + t.decimal :voucher_sales, :null => false, :default => 0 + t.decimal :foc_amount, :null => false, :default => 0 + t.decimal :staff_meal_amount, :null => false, :default => 0 + t.decimal :rounding_amount, :null => false, :default => 0 + t.decimal :raw_wastage_amount, :null => false, :default => 0 + t.decimal :semi_wastage_amount, :null => false, :default => 0 + t.decimal :wastage_amount, :null => false, :default => 0 + t.decimal :spoilage_amount, :null => false, :default => 0 + t.decimal :sampling_amount, :null => false, :default => 0 + t.integer :qty, :null => false, :default => 0 + t.integer :no_of_pax, :null => false, :default => 0 + t.integer :no_of_adult, :null => false, :default => 0 + t.integer :no_of_child, :null => false, :default => 0 + t.string :terminal_id, :null => false + t.string :employee_code, :limit => 4, :null => false + t.string :employee_name, :null => false + t.boolean :is_valid, :null => false, :default => false + t.boolean :overing, :null => false, :default => false + t.boolean :cancle, :null => false, :default => false + t.text :remarks + t.timestamps + end + end +end diff --git a/db/migrate/20180306045018_create_receipt_details.rb b/db/migrate/20180306045018_create_receipt_details.rb new file mode 100644 index 00000000..5fd38160 --- /dev/null +++ b/db/migrate/20180306045018_create_receipt_details.rb @@ -0,0 +1,43 @@ +class CreateReceiptDetails < ActiveRecord::Migration[5.1] + def change + create_table :receipt_details do |t| + t.string :client_code, :null => false + t.string :client_name, :null => false + t.string :shop_code, :null => false + t.string :shop_name, :null => false + t.string :receipt_no, :null => false + t.datetime :receipt_date, :null => false + t.datetime :transaction_date, :null => false + t.integer :item_sequence, :null => false + t.string :category_code, :null => false + t.string :category_name, :null => false + t.string :sub_category_code, :null => false + t.string :sub_category_name, :null => false + t.string :report_group_code, :null => false + t.string :report_group_name, :null => false + t.string :item_code, :null => false + t.string :item_name, :null => false + t.integer :qty, :null => false, :default => 0 + t.string :transaction_type, :null => false + t.decimal :gross_sales, :null => false, :default => 0 + t.string :discount_code, :null => false + t.decimal :discount_amount, :null => false, :default => 0 + t.decimal :sales, :null => false, :default => 0 + t.decimal :tax_amount, :null => false, :default => 0 + t.decimal :service_charges, :null => false, :default => 0 + t.decimal :net_sales, :null => false, :default => 0 + t.boolean :is_foc, :null => false, :default => false + t.boolean :is_set_item, :null => false, :default => false + t.boolean :is_staff_meal, :null => false, :default => false + t.boolean :is_raw_wastage, :null => false, :default => false + t.boolean :is_semi_wastage, :null => false, :default => false + t.boolean :is_wastage, :null => false, :default => false + t.boolean :is_spoilage, :null => false, :default => false + t.boolean :is_sampling, :null => false, :default => false + t.boolean :tax_able, :null => false, :default => false + t.boolean :is_void, :null => false, :default => false + t.text :remarks + t.timestamps + end + end +end \ No newline at end of file diff --git a/db/sym_master.sql b/db/sym_master.sql index 89abaf5b..3677fc2f 100755 --- a/db/sym_master.sql +++ b/db/sym_master.sql @@ -88,6 +88,10 @@ delete from sym_node; insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('cloud', 'sx', 'P'); # Create Trigger for Setting Channel + + insert into sym_trigger + (trigger_id,source_table_name,channel_id,last_update_time,create_time) + values('seed_generators','seed_generators','setting',current_timestamp,current_timestamp); insert into sym_trigger (trigger_id,source_table_name,channel_id,last_update_time,create_time) @@ -119,11 +123,11 @@ delete from sym_node; insert into sym_trigger (trigger_id,source_table_name,channel_id,last_update_time,create_time) - values('tax_profiles','customers','setting',current_timestamp,current_timestamp); + values('tax_profiles','tax_profiles','setting',current_timestamp,current_timestamp); insert into sym_trigger (trigger_id,source_table_name,channel_id,last_update_time,create_time) - values('display_images','customers','setting',current_timestamp,current_timestamp); + values('display_images','display_images','setting',current_timestamp,current_timestamp); # Create Trigger for Dining Channel @@ -339,6 +343,11 @@ delete from sym_node; # Add triggers for tables with router # Setting Channel # From cloud to Master + + insert into sym_trigger_router + (trigger_id,router_id,initial_load_order,last_update_time,create_time) + values('seed_generators','cloud_2_sx', 100, current_timestamp, current_timestamp); + insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) values('lookups','cloud_2_sx', 100, current_timestamp, current_timestamp); @@ -376,6 +385,11 @@ delete from sym_node; values('display_images','cloud_2_sx', 100, current_timestamp, current_timestamp); # Setting Channel # From Master to cloud + + insert into sym_trigger_router + (trigger_id,router_id,initial_load_order,last_update_time,create_time) + values('seed_generators','sx_2_cloud', 100, current_timestamp, current_timestamp); + insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) values('lookups','sx_2_cloud', 100, current_timestamp, current_timestamp); diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake index 17dcde74..43ba291e 100755 --- a/lib/tasks/clear_data.rake +++ b/lib/tasks/clear_data.rake @@ -17,6 +17,7 @@ namespace :clear do Survey.delete_all DiningFacility.update_all(status:'available') CashierTerminal.update_all(is_currently_login: 0) + SeedGenerator.where("id > 1").update(:current => 0, :next => 1) puts "Clear Data Done." end end diff --git a/lib/tasks/receipt.rake b/lib/tasks/receipt.rake new file mode 100644 index 00000000..fa24f481 --- /dev/null +++ b/lib/tasks/receipt.rake @@ -0,0 +1,238 @@ +namespace :consolidate do + desc "Receipt" + task :receipt => :environment do + Receipt.delete_all + sales = Sale.all_receipts + + shop = Shop.find(1) + sales.each do |sale| + receipt = Receipt.new + receipt.client_code = shop.id + receipt.client_name = shop.id + receipt.shop_code = shop.id + receipt.shop_name = shop.id + receipt.receipt_no = sale.receipt_no + receipt.transaction_time = sale.requested_at #requet-at + receipt.receipt_open_time = sale.requested_at #before disco/after tax /after/ser_char + receipt.receipt_close_time = sale.receipt_close_time + receipt.gross_sales = sale.total_amount + sale.total_tax #before disco/after tax /after/ser_char + receipt.discount_amount = sale.total_discount + sale.item_discount + receipt.sales = sale.grand_total #after disco/after tax /after/ser_char /no roundingadn + receipt.tax_amount = sale.total_tax + receipt.service_charges = sale.service_charges + receipt.net_sales = sale.total_amount + sale.total_discount #after disco/before tax / no rounding + receipt.credit_card_sales = sale.mpu_amount + sale.master_amount + sale.visa_amount + sale.jcb_amount + sale.unionpay_amount + sale.credit_amount # + receipt.voucher_sales = 0 + receipt.foc_amount = sale.foc_amount + sale.item_foc + receipt.staff_meal_amount = 0 + receipt.rounding_amount = sale.rounding_adjustment + receipt.raw_wastage_amount = 0 + receipt.semi_wastage_amount = 0 + receipt.wastage_amount = 0 + receipt.spoilage_amount = 0 + receipt.sampling_amount = 0 + receipt.qty = sale.qty + receipt.no_of_pax = 0 + receipt.no_of_adult = (sale.adult) ? sale.adult : 0 + receipt.no_of_child = (sale.child) ? sale.child : 0 + receipt.terminal_id = ShiftSale.find(sale.shift_sale_id).cashier_terminal_id + receipt.employee_code = Employee.find(sale.cashier_id).emp_id + receipt.employee_name = sale.cashier_name + receipt.is_valid = (sale.payment_status=="void") ? false : true #void is false + receipt.overing =false + receipt.cancle = (sale.payment_status=="void") ? false : true # void is cancel + receipt.remarks = sale.remark + receipt.save + end + end + + desc "Receipt Detail" + task :receipt_detail => :environment do + ReceiptDetail.delete_all + sales = Sale.all_receipt_details + + shop = Shop.find(1) + + sale_id = '' + count = 0 + @total_qty = 0 + @total_gross_sales = 0 + @total_sales = 0 + @total_net_sales = 0 +@z =1 + @item_sequence = 1 + sale_count = sales.to_a.count + sales.each do |sale| + + if sale.qty > 0 + + if sale.item_instance_code !=nil + menu_category = MenuCategory.find(MenuItem.find_by_item_code(sale.product_code).menu_category_id) + name = menu_category.name + code = menu_category.code + menu_item = MenuItem.find_by_item_code(sale.product_code) + menu_name = menu_item.name + menu_code = menu_item.item_code + menu_type = menu_item.type + end + if sale.product_code == "Other Charges" && sale.status == "Other Charges" + code = sale.product_code + name = sale.product_code + menu_name = sale.product_code + menu_code = sale.product_code + menu_type = sale.product_code + end + + @receipt_no = sale.receipt_no + @requested_at = sale.requested_at + + if sale_id == sale.sale_id || count == 0 || @z ==0 + @total_qty += sale.qty + @total_gross_sales += sale.price + @total_sales += sale.price + @total_net_sales += sale.taxable_price + end + + if sale_id != sale.sale_id && count !=0 + + receipt = ReceiptDetail.new + receipt.client_code = shop.id + receipt.client_name = shop.id + receipt.shop_code = shop.id + receipt.shop_name = shop.id + receipt.receipt_no = @receipt_no + receipt.receipt_date = @requested_at #requet-at + receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char + receipt.item_sequence = @item_sequence + receipt.category_code = '' + receipt.category_name = '' + receipt.sub_category_code = 0 + receipt.sub_category_name = 0 + receipt.report_group_code = 0 + receipt.report_group_name = 0 + receipt.item_code = '' + receipt.item_name = '' + receipt.qty = @total_qty + receipt.transaction_type = "Tender" + receipt.gross_sales = @total_gross_sales + receipt.discount_code = '' + receipt.discount_amount = 0 + receipt.sales = @total_sales + receipt.tax_amount = 0 + receipt.service_charges = 0 + receipt.net_sales = @total_net_sales + receipt.is_set_item = false + receipt.is_foc = false + receipt.is_staff_meal = false + receipt.is_raw_wastage = false + receipt.is_semi_wastage = false + receipt.is_wastage = false + receipt.is_spoilage = false + receipt.is_sampling = false + receipt.tax_able = false + receipt.is_void = false + receipt.remarks = "" + receipt.save + @type = "Tender" + @item_sequence = 1 + @total_qty = 0 + @total_gross_sales = 0 + @total_sales = 0 + @total_net_sales = 0 + @z = 0 + end + + + discount_amount = (sale.status=="Discount") ? sale.price : 0 + receipt = ReceiptDetail.new + receipt.client_code = shop.id + receipt.client_name = shop.id + receipt.shop_code = shop.id + receipt.shop_name = shop.id + receipt.receipt_no = sale.receipt_no + receipt.receipt_date = sale.requested_at #requet-at + receipt.transaction_date = sale.requested_at #before disco/after tax /after/ser_char + receipt.item_sequence = @item_sequence + receipt.category_code = name + receipt.category_name = code + receipt.sub_category_code = 0 + receipt.sub_category_name = 0 + receipt.report_group_code = 0 + receipt.report_group_name = 0 + receipt.item_code = menu_name + receipt.item_name = menu_code + receipt.qty = sale.qty + receipt.transaction_type = (sale.status==nil) ? "Sales" : sale.status + receipt.gross_sales = sale.price + receipt.discount_code = sale.sale_item_id + receipt.discount_amount = discount_amount + receipt.sales = sale.price + receipt.tax_amount = 0 + receipt.service_charges = 0 + receipt.net_sales = sale.taxable_price + receipt.is_set_item = (menu_type=="SetMenuItem")? true : false + receipt.is_foc = (sale.status=="foc") ? true : false + receipt.is_staff_meal = false + receipt.is_raw_wastage = false + receipt.is_semi_wastage = false + receipt.is_wastage = false + receipt.is_spoilage = false + receipt.is_sampling = false + receipt.tax_able = sale.is_taxable + receipt.is_void = (sale.status=="void")? true : false + receipt.remarks = sale.remark + receipt.save + + end + + @z += 1 + + + count += 1 + @item_sequence += 1 + sale_id = sale.sale_id + end + + if count == sale_count + receipt = ReceiptDetail.new + receipt.client_code = shop.id + receipt.client_name = shop.id + receipt.shop_code = shop.id + receipt.shop_name = shop.id + receipt.receipt_no = @receipt_no + receipt.receipt_date = @requested_at #requet-at + receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char + receipt.item_sequence = @item_sequence + receipt.category_code = '' + receipt.category_name = '' + receipt.sub_category_code = 0 + receipt.sub_category_name = 0 + receipt.report_group_code = 0 + receipt.report_group_name = 0 + receipt.item_code = '' + receipt.item_name = '' + receipt.qty = @total_qty + receipt.transaction_type = "Tender" + receipt.gross_sales = @total_gross_sales + receipt.discount_code = '' + receipt.discount_amount = 0 + receipt.sales = @total_sales + receipt.tax_amount = 0 + receipt.service_charges = 0 + receipt.net_sales = @total_net_sales + receipt.is_set_item = false + receipt.is_foc = false + receipt.is_staff_meal = false + receipt.is_raw_wastage = false + receipt.is_semi_wastage = false + receipt.is_wastage = false + receipt.is_spoilage = false + receipt.is_sampling = false + receipt.tax_able = false + receipt.is_void = false + receipt.remarks = "" + receipt.save + end + end + +end \ No newline at end of file diff --git a/spec/models/receipt_detail_spec.rb b/spec/models/receipt_detail_spec.rb new file mode 100644 index 00000000..017ee888 --- /dev/null +++ b/spec/models/receipt_detail_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ReceiptDetail, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/receipt_spec.rb b/spec/models/receipt_spec.rb new file mode 100644 index 00000000..3b140805 --- /dev/null +++ b/spec/models/receipt_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Receipt, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 84fe089568ad6e81b94af143fdfce3845fe070d6 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 13 Mar 2018 17:53:04 +0630 Subject: [PATCH 18/18] Active tab in dashboard, Manager Tab, Union Payment --- app/assets/stylesheets/login.scss | 5 ++++ .../origami/unionpay_controller.rb | 1 + app/views/layouts/login_dashboard.html.erb | 29 +++++++++++++++++-- app/views/origami/unionpay/index.html.erb | 1 - 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/login.scss b/app/assets/stylesheets/login.scss index 66252d60..b5f29da6 100755 --- a/app/assets/stylesheets/login.scss +++ b/app/assets/stylesheets/login.scss @@ -8,6 +8,11 @@ background-color: #2790a5; } +.active_tab{ + border-style: solid; + border-color: #2790a5; +} + .login-page { margin: 0% auto; background-color: #2790a5; diff --git a/app/controllers/origami/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb index 905a1ffb..707a1022 100644 --- a/app/controllers/origami/unionpay_controller.rb +++ b/app/controllers/origami/unionpay_controller.rb @@ -8,6 +8,7 @@ class Origami::UnionpayController < BaseOrigamiController @unionpaycount = 0 others = 0 + @payment_method_setting_nav = PaymentMethodSetting.all @shop = Shop::ShopDetail if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) diff --git a/app/views/layouts/login_dashboard.html.erb b/app/views/layouts/login_dashboard.html.erb index 54bc8b95..f2f6f958 100755 --- a/app/views/layouts/login_dashboard.html.erb +++ b/app/views/layouts/login_dashboard.html.erb @@ -105,6 +105,14 @@