From 1ef88c4e7042fe9f547af4506247aa77cbaf392a Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 13 Jun 2017 14:37:23 +0630 Subject: [PATCH 01/18] update --- app/views/origami/payments/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index f9ae06b7..c23a17cf 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -6,8 +6,8 @@
- - + + From 8a7c1f0d888c71287e37bd907d0ad0b53d9475ff Mon Sep 17 00:00:00 2001 From: Phyo Date: Tue, 13 Jun 2017 16:05:20 +0630 Subject: [PATCH 02/18] Payment Vs Tax --- .../origami/redeem_payments_controller.rb | 20 ++++++++++++++++++- app/views/origami/payments/show.html.erb | 2 +- .../origami/redeem_payments/index.html.erb | 7 +++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index b68fd30a..1f650e36 100644 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -4,7 +4,25 @@ class Origami::RedeemPaymentsController < BaseOrigamiController payment_method = params[:payment_method] @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) - @food_prices, @beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) + + # limit redeem_amount + food_prices, beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) + @payparcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "paypar" + @payparcount = @payparcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + is_bervage_exceed = others - (beverage_prices + sale_data.total_tax) + if is_bervage_exceed < 0 + @food_prices = food_prices - @payparcount + else + @food_prices = food_prices - @payparcount -is_bervage_exceed + end + if sale_data if sale_data.customer_id customer_data= Customer.find_by_customer_id(sale_data.customer_id) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index a47fb64f..f582007a 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -253,6 +253,6 @@ function update_balance(){ var amount_due = $('#amount_due').text(); var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) var result = amount_due - total - $('#balance').text(result); + $('#balance').text(result.toFixed(2)); } diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index ae714bea..7936e66a 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -18,8 +18,11 @@
-

You can rebate upto <%= @food_prices %>

+ <% if @payparcount > 0 %> +

Last time rebate amount is <%= @payparcount %>

+ <% end %> +

You can rebate upto <%= @food_prices %>

@@ -117,7 +120,7 @@ $("#redeem").click(function(){ valid_amount = $("#valid_amount").val(); sale_id = $("#valid_amount").attr('data-value'); membership_id = $("#valid_amount").attr('data-member-value'); - redeem_amount = parseInt($("#used_amount").text()); + redeem_amount = parseFloat($("#used_amount").text()); if(redeem_amount<=0 ){ alert("Please type valid amount"); From 19160a96308623723a12e5124de17a48a333fd67 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Tue, 13 Jun 2017 17:41:50 +0630 Subject: [PATCH 03/18] Change redeem name --- app/views/origami/redeem_payments/index.html.erb | 4 ++-- config/routes.rb | 2 +- db/seeds.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index ae714bea..50ae6ee1 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -5,14 +5,14 @@
- +

- +
0.0

diff --git a/config/routes.rb b/config/routes.rb index c4592d6d..697b4741 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -95,7 +95,7 @@ Rails.application.routes.draw do get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index" post 'payment/mpu' => "mpu#create" - get 'sale/:sale_id/payment/others_payment/REDEEM' => "redeem_payments#index" + get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index" #---------Add Customer --------------# #resources :customers diff --git a/db/seeds.rb b/db/seeds.rb index 1e3e30b1..4d241119 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -156,7 +156,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"REDEEM",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) # shop = Shop.create( From 7f7d579d2f51f364aada2b626570b45242ec032b Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 13 Jun 2017 18:28:22 +0630 Subject: [PATCH 04/18] add auth token: exit --- app/assets/javascripts/origami.js | 15 ++++- app/controllers/crm/customers_controller.rb | 41 +++++++++++-- app/controllers/origami/home_controller.rb | 3 +- .../origami/redeem_payments_controller.rb | 3 +- .../reports/daily_sale_controller.rb | 14 +---- app/models/sale_payment.rb | 7 ++- app/views/crm/customers/show.html.erb | 9 ++- app/views/origami/customers/index.html.erb | 57 ++++++++++--------- app/views/origami/home/index.html.erb | 7 ++- .../_shift_sale_report_filter.html.erb | 0 config/routes.rb | 2 +- db/seeds.rb | 14 ++--- 12 files changed, 106 insertions(+), 66 deletions(-) rename app/views/reports/{receipt_no => }/_shift_sale_report_filter.html.erb (100%) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 0079142f..fbf641df 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -185,7 +185,7 @@ $(document).ready(function(){ }else{ var sale_id = $(".selected-item").find(".order-cid").text(); } - window.location.href = '/origami/'+ sale_id + "/add_customer" + window.location.href = '/origami/'+ sale_id + "/customers" return false; }); @@ -199,6 +199,7 @@ $(document).ready(function(){ } $('.customer_detail').removeClass('hide'); + //Start Ajax $.ajax({ type: "GET", @@ -210,8 +211,16 @@ $(document).ready(function(){ $.each(data["response_data"]["data"], function (i) { if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ var balance = data["response_data"]["data"][i]["balance"]; - console.log(balance); - $("#customer_amount").text(balance); + if (data["response_data"]["status"]==true) { + $('.rebate_amount').removeClass('hide'); + console.log(balance); + row = + '
' + +''; + + $(".rebate_amount").append(row); + } + } }); } diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 1f35da76..57f4eafc 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -45,6 +45,35 @@ class Crm::CustomersController < BaseCrmController @sale_items = @sale_items + sale.sale_items end end + + #get customer amount + @customer = Customer.find(params[:id]) + + membership = MembershipSetting.find_by_membership_type("paypar_url") + + memberaction = MembershipAction.find_by_membership_type("get_all_member_account") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + } + ) + + @type = "-" + @balance = 0.00 + response["data"].each do |res| + if res["accountable_type"] == "RebateAccount" + @balance = res["balance"] + @type = "RebateAccount" + end + end + + #end customer amount + end # GET /crm/customers/new @@ -76,11 +105,12 @@ class Crm::CustomersController < BaseCrmController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, dob: dob, - member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json, + member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -93,7 +123,7 @@ class Crm::CustomersController < BaseCrmController status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' } + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} end @@ -102,7 +132,7 @@ class Crm::CustomersController < BaseCrmController @crm_customers.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} else format.html { redirect_to crm_customers_path, notice: response["message"] } end @@ -111,7 +141,7 @@ class Crm::CustomersController < BaseCrmController if params[:sale_id] flash[:errors] = @crm_customers.errors - format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } else flash[:errors] = @crm_customers.errors @@ -140,11 +170,12 @@ end membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("update_membership_customer") merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, dob: dob, - id: id,member_group_id:member_group_id,merchant_uid:merchant_uid}.to_json, + id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index de526f81..22c0c119 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -74,9 +74,10 @@ class Origami::HomeController < BaseOrigamiController memberaction = MembershipAction.find_by_membership_type("get_all_member_account") merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json, + response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index b68fd30a..94636c70 100644 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -18,7 +18,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController @campaign_type_id = member_actions.additional_parameter["campaign_type_id"] url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s merchant_uid= member_actions.merchant_account_id - membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid) + auth_token = member_actions.auth_token.to_s + membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token) if membership_data["status"]==true @membership_rebate_balance=membership_data["balance"] @out = true, @membership_rebate_balance,@membership_id diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_sale_controller.rb index b4c701ae..b487c269 100644 --- a/app/controllers/reports/daily_sale_controller.rb +++ b/app/controllers/reports/daily_sale_controller.rb @@ -1,21 +1,9 @@ class Reports::DailySaleController < BaseReportController - PERIOD = { - "today" => 0, - "yesterday" => 1, - "this_week" => 2, - "last_week" => 3, - "last_7" => 4, - "this_month" => 5, - "last_month" => 6, - "last_30" => 7, - "this_year" => 8, - "last_year" => 9 - } def index from, to = get_date_range_from_params @sale_data = Sale.get_receipt_no_list(from,to) @sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50) -end + end end \ No newline at end of file diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 894592b5..72260344 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -66,9 +66,9 @@ class SalePayment < ApplicationRecord end - def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid) + def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token) response = HTTParty.get(url, - :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid}.to_json, + :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -83,11 +83,12 @@ class SalePayment < ApplicationRecord if !membership_actions_data.nil? url = paypar_url.to_s + membership_actions_data.gateway_url.to_s merchant_uid = membership_actions_data.merchant_account_id + auth_token = membership_actions_data.auth_token campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"] sale_data = Sale.find_by_sale_id(sale_id) if sale_data response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid}.to_json, + :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index df1184b7..62ebf9c0 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -26,6 +26,9 @@ + + + @@ -36,7 +39,11 @@ - + + + <% +puts "hhhhhhhhhhhhhhhhhhhhh" + puts @member_data.to_json %>
Receipt No : <%=@sale_data.receipt_no rescue ' '%>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>Receipt No : <%=@sale_data.receipt_no rescue ' '%>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Table No <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %>' + data["response_data"]["data"][i]["accountable_type"] +'' + balance + 'Contact no Company Date Of BirthMembership AccountBalanceType
<%= @crm_customer.contact_no %> <%= @crm_customer.company %> <%= @crm_customer.date_of_birth %> <%= @balance %> <%= @type %>
diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index bb3c96e6..6fa5ae03 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -14,7 +14,7 @@
-
+
@@ -38,7 +38,6 @@ Company Contact no Email - Date of Birth @@ -51,10 +50,7 @@ <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> <%= crm_customer.email %> - - <%= crm_customer.date_of_birth rescue '-' %> - - + <% end %> @@ -68,7 +64,7 @@
-
+
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> @@ -92,27 +88,32 @@
- - <%= f.text_field :date_of_birth,:class=>"form-control datepicker"%> + + <%= f.text_field :date_of_birth,:class=>"form-control datepicker"%> +
+ +
+ + +
+ +
+ <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> + +
+ <%end%> +
+ - -
- - -
- -
- <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> - -
- <%end%> -
@@ -197,7 +198,7 @@ success: function(data) { if(data.status == true) { - alert('Customer has assigned'); + window.location.href = '/origami' }else{ alert('Record not found!'); diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 24410ef8..f9356f68 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -297,9 +297,7 @@

Customer :

-
-

Amount :

-
+
@@ -373,6 +371,9 @@ + + +
Grand Total: <%=@selected_item.grand_total rescue 0%>
diff --git a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb b/app/views/reports/_shift_sale_report_filter.html.erb similarity index 100% rename from app/views/reports/receipt_no/_shift_sale_report_filter.html.erb rename to app/views/reports/_shift_sale_report_filter.html.erb diff --git a/config/routes.rb b/config/routes.rb index c4592d6d..1a031ded 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,7 +99,7 @@ Rails.application.routes.draw do #---------Add Customer --------------# #resources :customers - get '/:sale_id/add_customer', to: "customers#add_customer" + get '/:sale_id/customers', to: "customers#add_customer" get '/:customer_id/get_customer' => 'home#get_customer' post '/:sale_id/update_sale' , to: "home#update_sale_by_customer"#update customer id in sale table end diff --git a/db/seeds.rb b/db/seeds.rb index 1e3e30b1..709a20ee 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -145,13 +145,13 @@ crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrder member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) -member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"} +member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) From 0d5767b022a8c04071c29270d5a4d8c515f4deec Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 13 Jun 2017 18:37:14 +0630 Subject: [PATCH 05/18] Update --- db/seeds.rb | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 1e3e30b1..3f2621a8 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -96,29 +96,29 @@ food = Account.create({title: "Food", account_type: "0"}) beverage = Account.create({title: "Beverage", account_type: "1"}) #Default menu -menu = Menu.create({name: "Default Menu", is_active: true, created_by: "SYSTEM DEFAULT"}) - -menu_options = MenuItemOption.create([{name: "Less Spicy", value: "less_spicy"},{name: "Spicy", value: "spicy"},{name: "Super Spicy", value: "super_spicy"}]) -menu_options = MenuItemOption.create([{name: "Less Oil", value: "less_oil"},{name: "No MSG", value: "no_msg"},{name: "Less Sweet", value: "less_sweet"}]) - -#Default Menu Category -menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Sample Menu Category 1", alt_name: "Sample Alternate Name 1", order_by: 1,created_by: "SYSTEM DEFAULT"}) -menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Sample Menu Category 2", alt_name: "Sample Alternate Name 2", order_by: 2,created_by: "SYSTEM DEFAULT"}) -menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 3", alt_name: "Sample Alternate Name 3", order_by: 3,created_by: "SYSTEM DEFAULT"}) -menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 4", alt_name: "Sample Alternate Category 4", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"}) - -#Default Menu items -menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) -menu_item0_instance = MenuItemInstance.create([{item_instance_name:"half portion",item_instance_code:"II0101", menu_item: menu_category1_menu_item0, price:12.00, is_on_promotion:false}]) -menu_item0_instance = MenuItemInstance.create([{item_instance_name:"full portion",item_instance_code:"01001-2", menu_item: menu_category1_menu_item0, price:18.00, is_on_promotion:false}]) - -menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 , account: food}) -menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "Default Menu Item Name 2",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 , account: food}) -menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 , account: food}) - -menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) -menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) -menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 , account: food}) +# menu = Menu.create({name: "Default Menu", is_active: true, created_by: "SYSTEM DEFAULT"}) +# +# menu_options = MenuItemOption.create([{name: "Less Spicy", value: "less_spicy"},{name: "Spicy", value: "spicy"},{name: "Super Spicy", value: "super_spicy"}]) +# menu_options = MenuItemOption.create([{name: "Less Oil", value: "less_oil"},{name: "No MSG", value: "no_msg"},{name: "Less Sweet", value: "less_sweet"}]) +# +# #Default Menu Category +# menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Sample Menu Category 1", alt_name: "Sample Alternate Name 1", order_by: 1,created_by: "SYSTEM DEFAULT"}) +# menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Sample Menu Category 2", alt_name: "Sample Alternate Name 2", order_by: 2,created_by: "SYSTEM DEFAULT"}) +# menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 3", alt_name: "Sample Alternate Name 3", order_by: 3,created_by: "SYSTEM DEFAULT"}) +# menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 4", alt_name: "Sample Alternate Category 4", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"}) +# +# #Default Menu items +# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) +# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"half portion",item_instance_code:"II0101", menu_item: menu_category1_menu_item0, price:12.00, is_on_promotion:false}]) +# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"full portion",item_instance_code:"01001-2", menu_item: menu_category1_menu_item0, price:18.00, is_on_promotion:false}]) +# +# menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 , account: food}) +# menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "Default Menu Item Name 2",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 , account: food}) +# menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 , account: food}) +# +# menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +# menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +# menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 , account: food}) menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"}) menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"}) From 8a6c0bf059ad503cffbaa7ca7ae48e8b272783b6 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 13 Jun 2017 18:46:43 +0630 Subject: [PATCH 06/18] update rebate amount in payment --- app/controllers/origami/payments_controller.rb | 18 ++++++++++++------ app/views/origami/payments/show.html.erb | 7 ++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index bdae0f0e..4ac519b0 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -27,10 +27,11 @@ class Origami::PaymentsController < BaseOrigamiController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("get_all_member_account") - merchant_uid = memberaction.merchant_account_id.to_s + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json, + response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -38,11 +39,16 @@ class Origami::PaymentsController < BaseOrigamiController ) @balance = 0.00 - response["data"].each do |res| - if res["accountable_type"] == "RebateAccount" - @balance = res["balance"] - end + @accountable_type = '' + if response["data"]==true + response["data"].each do |res| + if res["accountable_type"] == "RebateAccount" + @balance = res["balance"] + @accountable_type = res["accountable_type"] + end + end end + #end customer amount @sale_data.sale_payments.each do |spay| diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index f582007a..a6a6dd41 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -15,7 +15,6 @@ Customer : <%= @sale_data.customer.name%> - Points : <%= @balance %> @@ -70,6 +69,12 @@ Grand Total <%=@sale_data.grand_total rescue 0%> + <%if @balance > 0%> + + <%= @accountable_type %> + <%=@balance%> + + <% end %> From c6ee0e9d25f7ea55369e66c9ce7af4c8723ff0b1 Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 13 Jun 2017 18:55:20 +0630 Subject: [PATCH 07/18] update seed --- db/seeds.rb | 83 ++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index d47decef..ff505a83 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -81,12 +81,12 @@ customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_ customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111"}) #Default ZOne -zone = Zone.create({id:1, name: "Default Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) -zone2 = Zone.create({id:2, name: "Default Zone 2", is_active:true, created_by: "SYSTEM DEFAULT"}) +zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) +zone2 = Zone.create({id:2, name: "VIP Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) #Default dining_facilities -table = Table.create({name:"Default Table", zone: zone, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"}) -room = Room.create({name:"Default Room", zone: zone2, status:"available", seater: 4 , order_by:1, created_by:"SYSTEM DEFAULT"}) +table = Table.create({name:"Table 1", zone: zone, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"}) +room = Room.create({name:"Table 2", zone: zone2, status:"available", seater: 4 , order_by:1, created_by:"SYSTEM DEFAULT"}) #Tax Profile tax_profiles = TaxProfile.create({id:1, name: "Commerical Tax", rate:5.0, order_by:1, created_by:"SYSTEM DEFAULT"}) @@ -96,29 +96,29 @@ food = Account.create({title: "Food", account_type: "0"}) beverage = Account.create({title: "Beverage", account_type: "1"}) #Default menu -# menu = Menu.create({name: "Default Menu", is_active: true, created_by: "SYSTEM DEFAULT"}) -# -# menu_options = MenuItemOption.create([{name: "Less Spicy", value: "less_spicy"},{name: "Spicy", value: "spicy"},{name: "Super Spicy", value: "super_spicy"}]) -# menu_options = MenuItemOption.create([{name: "Less Oil", value: "less_oil"},{name: "No MSG", value: "no_msg"},{name: "Less Sweet", value: "less_sweet"}]) -# -# #Default Menu Category -# menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Sample Menu Category 1", alt_name: "Sample Alternate Name 1", order_by: 1,created_by: "SYSTEM DEFAULT"}) -# menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Sample Menu Category 2", alt_name: "Sample Alternate Name 2", order_by: 2,created_by: "SYSTEM DEFAULT"}) -# menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 3", alt_name: "Sample Alternate Name 3", order_by: 3,created_by: "SYSTEM DEFAULT"}) -# menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 4", alt_name: "Sample Alternate Category 4", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"}) -# -# #Default Menu items -# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) -# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"half portion",item_instance_code:"II0101", menu_item: menu_category1_menu_item0, price:12.00, is_on_promotion:false}]) -# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"full portion",item_instance_code:"01001-2", menu_item: menu_category1_menu_item0, price:18.00, is_on_promotion:false}]) -# -# menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 , account: food}) -# menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "Default Menu Item Name 2",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 , account: food}) -# menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 , account: food}) -# -# menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) -# menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) -# menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 , account: food}) +menu = Menu.create({name: "Main Menu", is_active: true, created_by: "SYSTEM DEFAULT"}) + +menu_options = MenuItemOption.create([{name: "Less Spicy", value: "less_spicy"},{name: "Spicy", value: "spicy"},{name: "Super Spicy", value: "super_spicy"}]) +menu_options = MenuItemOption.create([{name: "Less Oil", value: "less_oil"},{name: "No MSG", value: "no_msg"},{name: "Less Sweet", value: "less_sweet"}]) + +#Default Menu Category +menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base", alt_name: "Soup_base", order_by: 1,created_by: "SYSTEM DEFAULT"}) +menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 2,created_by: "SYSTEM DEFAULT"}) +menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Pork", alt_name: "Pork", order_by: 3,created_by: "SYSTEM DEFAULT"}) +menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Chicken", alt_name: "Chicken", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"}) + +#Default Menu items +menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) +menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Single Pot",item_instance_code:"II0011", menu_item: menu_category1_menu_item0, price:00.00, is_on_promotion:false}]) +menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0041", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}]) + +menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Twin Pot", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 , account: food}) +menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "VIP Room Individual Pot",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 , account: food}) +menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 , account: food}) + +menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 , account: food}) menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"}) menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"}) @@ -137,7 +137,7 @@ zone_queue_station = OrderQueueProcessByZone.create({order_queue_station: zone_o #Create Adminstrator employee admin_employee = Employee.create({name: "Administrator", role: "Administrator", password: "99999", emp_id:"999", created_by: "SYSTEM DEFAULT"}) - +admin_employee = Employee.create({name: "Waiter", role: "Waiter", password: "11111", emp_id:"111", created_by: "SYSTEM DEFAULT"}) order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) @@ -145,22 +145,19 @@ crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrder member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) -member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, - {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, - {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, - {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, - {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, - {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, - {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} +member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, + {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http//192.168.1.47:3006"}) +payment_methods = PaymentMethodSetting.create({payment_method:"REDEEM",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) -payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) - - -# shop = Shop.create( -# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", -# country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license", -# activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"} -# ) +puts " Finished System Default Set Up Data " From 3db3b8c7e7edcde7650d7ec7f3ac521c2e62bebd Mon Sep 17 00:00:00 2001 From: Moe Su Date: Tue, 13 Jun 2017 19:01:14 +0630 Subject: [PATCH 08/18] add auth_token --- .../origami/payments_controller.rb | 3 ++- app/models/sale_payment.rb | 4 ++-- dump.rdb | Bin 22659 -> 22762 bytes 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index bdae0f0e..8166aa49 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -28,9 +28,10 @@ class Origami::PaymentsController < BaseOrigamiController memberaction = MembershipAction.find_by_membership_type("get_all_member_account") merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json, + response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 72260344..029afdf9 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -256,10 +256,10 @@ class SalePayment < ApplicationRecord membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("rebate") campaign_type_id = memberaction.additional_parameter["campaign_type_id"] - app_token = membership.auth_token.to_s + auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_amount: total_amount,campaign_type_id: campaign_type_id, - receipt_no: receipt_no}.to_json, + receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' diff --git a/dump.rdb b/dump.rdb index a7b3490249f64dc90e8b1f51e3ee17691505015e..9ce916eda38f8373c8dd26cf3de8976b140fd4ee 100644 GIT binary patch delta 461 zcmWO1ziSgw902fly_j4tDs)qbBxe(;!wc{Cd*6UaL?~n`;$jKdd-v`+)OM(K6hS8! zQLdvxhbU6HlllX9w{E&P_Xs$+h?C$T_CNT19v=oj4})i9Y4ZK*t-sOzd%43~`PP@U zr_aYP&fJ-Fx}6xIyAeXo;#c@&kXq`sw*pIL01Lwf21XP%mO0B^9xBCX@v=dRBg)sf zbV7sIPFkwGvm~PwK&QREPPUV$yScla?p_>G0h&u`BpEW$ibHP`ZEt)!Zg-o8um}GR zf}})m>RDOr1eYEr=QjS-vP7cBWec1$k{gk{ZBdfj%*Z@>A1Kn>tD~~b6rp^mIZ(># z)75d%Lo%t*yKyytHEnv38k9_CF|`~EPXJrKycsK-8lrO#EE}J%M-}2Vu41Ek>V-Gd zTD1&|mS;NCCe5cqSy1;wD`C%X)Q>ALEI=#g;&BK z!_UQPc>P)=a*k8t8D4P>;*~S~N2_1wqjdyxydE;(_Hxjc(la5MNWqA~ejraKWynE_ Vl|20LEj+jx{l0Ou-MCe>*=x!a)ckA_z9x=+5p=qj$x{lp^R0 zC}U}H#bH9sE|{QQL{p~l5yZhpd;!Hm{Jy7i@8H}!B%{iFT6-;j` Date: Tue, 13 Jun 2017 19:06:50 +0630 Subject: [PATCH 09/18] order controller update --- app/controllers/api/orders_controller.rb | 25 ++++++++++-------------- app/models/order.rb | 2 +- app/models/sale.rb | 3 ++- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 8bd348e2..7fecf7bf 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -33,27 +33,22 @@ class Api::OrdersController < Api::ApiController @order.guest = params[:guest_info] @order.table_id = params[:table_id] @order.new_booking = true - #@order.employee_name = "Emenu" @order.employee_name = current_login_employee.name - - #Create Table Booking or Room Booking if !params["booking_id"].nil? - @order.new_booking = false - @order.booking_id = params[:booking_id] + # check booking id is already completed. + booking = Booking.find(params[:booking_id]) + if !booking.sale_id.nil? + if booking.sale.sale_status == "completed" + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + end + end end @status, @booking = @order.generate - - # rescue Exception => error - # @status = false - # @error_messages = "Exception has occurs on System" - # - # logger.fatal("Exception Raise - " + error.message) - # end - - - end # Description diff --git a/app/models/order.rb b/app/models/order.rb index 9a1afe5d..21c00580 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -25,7 +25,7 @@ class Order < ApplicationRecord booking = nil if self.new_booking - puts "a" + booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) diff --git a/app/models/sale.rb b/app/models/sale.rb index b9ce13d2..c0a73f3d 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -12,7 +12,8 @@ class Sale < ApplicationRecord has_many :sale_taxes has_many :sale_payments has_many :sale_orders - + has_many :bookings + scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } def generate_invoice_from_booking(booking_id, requested_by) From 57f7f1037d155b4398e342d9205f02d848ad8a4d Mon Sep 17 00:00:00 2001 From: Phyo Date: Tue, 13 Jun 2017 19:41:51 +0630 Subject: [PATCH 10/18] Change Amount Bug Fix --- app/models/sale_payment.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 029afdf9..e0fe2e7c 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -212,7 +212,8 @@ class SalePayment < ApplicationRecord def sale_update_payment_status(paid_amount) #update amount_outstanding self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f - self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f + + self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f all_received_amount = 0.0 sObj = Sale.find(self.sale_id) sObj.sale_payments.each do |spay| From 71f88f8a5de32e2cd79bd14ba06cb947d302bd20 Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 13 Jun 2017 19:49:25 +0630 Subject: [PATCH 11/18] Update --- app/controllers/origami/jcb_controller.rb | 17 ++ app/controllers/origami/master_controller.rb | 17 ++ app/controllers/origami/visa_controller.rb | 17 ++ app/views/origami/jcb/create.json.jbuilder | 5 + app/views/origami/jcb/index.html.erb | 144 +++++++++++++++++ app/views/origami/master/create.json.jbuilder | 5 + app/views/origami/master/index.html.erb | 144 +++++++++++++++++ app/views/origami/mpu/index.html.erb | 146 ++++++++++++++++++ app/views/origami/visa/create.json.jbuilder | 5 + app/views/origami/visa/index.html.erb | 144 +++++++++++++++++ config/routes.rb | 15 +- 11 files changed, 654 insertions(+), 5 deletions(-) create mode 100644 app/controllers/origami/jcb_controller.rb create mode 100644 app/controllers/origami/master_controller.rb create mode 100644 app/controllers/origami/visa_controller.rb create mode 100644 app/views/origami/jcb/create.json.jbuilder create mode 100644 app/views/origami/jcb/index.html.erb create mode 100644 app/views/origami/master/create.json.jbuilder create mode 100644 app/views/origami/master/index.html.erb create mode 100644 app/views/origami/visa/create.json.jbuilder create mode 100644 app/views/origami/visa/index.html.erb diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb new file mode 100644 index 00000000..9be83462 --- /dev/null +++ b/app/controllers/origami/jcb_controller.rb @@ -0,0 +1,17 @@ +class Origami::JcbController < BaseOrigamiController + + def index + @sale_id = params[:sale_id] + end + + def create + cash = params[:amount] + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu") + end + end + +end diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb new file mode 100644 index 00000000..92ab7ebb --- /dev/null +++ b/app/controllers/origami/master_controller.rb @@ -0,0 +1,17 @@ +class Origami::MasterController < BaseOrigamiController + + def index + @sale_id = params[:sale_id] + end + + def create + cash = params[:amount] + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu") + end + end + +end diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb new file mode 100644 index 00000000..043bd43c --- /dev/null +++ b/app/controllers/origami/visa_controller.rb @@ -0,0 +1,17 @@ +class Origami::VisaController < BaseOrigamiController + + def index + @sale_id = params[:sale_id] + end + + def create + cash = params[:amount] + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu") + end + end + +end diff --git a/app/views/origami/jcb/create.json.jbuilder b/app/views/origami/jcb/create.json.jbuilder new file mode 100644 index 00000000..9767a7d8 --- /dev/null +++ b/app/views/origami/jcb/create.json.jbuilder @@ -0,0 +1,5 @@ +if(@status) + json.status @status +else + json.status false +end diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb new file mode 100644 index 00000000..a0760b38 --- /dev/null +++ b/app/views/origami/jcb/index.html.erb @@ -0,0 +1,144 @@ +
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+
+
+ +
+ diff --git a/app/views/origami/master/create.json.jbuilder b/app/views/origami/master/create.json.jbuilder new file mode 100644 index 00000000..9767a7d8 --- /dev/null +++ b/app/views/origami/master/create.json.jbuilder @@ -0,0 +1,5 @@ +if(@status) + json.status @status +else + json.status false +end diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb new file mode 100644 index 00000000..a0760b38 --- /dev/null +++ b/app/views/origami/master/index.html.erb @@ -0,0 +1,144 @@ +
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+
+
+ +
+ diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index 7b483a75..3d9d1024 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -1,3 +1,149 @@ +
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+
+
+ +
+ + +

MPU

diff --git a/app/views/origami/visa/create.json.jbuilder b/app/views/origami/visa/create.json.jbuilder new file mode 100644 index 00000000..9767a7d8 --- /dev/null +++ b/app/views/origami/visa/create.json.jbuilder @@ -0,0 +1,5 @@ +if(@status) + json.status @status +else + json.status false +end diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb new file mode 100644 index 00000000..a0760b38 --- /dev/null +++ b/app/views/origami/visa/index.html.erb @@ -0,0 +1,144 @@ +
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+
+
+ +
+ diff --git a/config/routes.rb b/config/routes.rb index 6bfe588e..2199ad67 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,15 +86,20 @@ Rails.application.routes.draw do #--------- Payment ------------# get 'sale/:sale_id/payment' => 'payments#show' + post 'payment/cash' => 'payments#create' + post 'payment/mpu' => "mpu#create" + post 'payment/jcb' => "jcb#create" + post 'payment/master' => "master#create" + post 'payment/visa' => "master#visa" post 'payment/paypar' => 'paypar_payments#create' + get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/payment/others_payment' => "others_payments#index" - - # get 'sale/:sale_id/payment/others_payment/:payment_method' => "redeem_payments#index" - get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index" - post 'payment/mpu' => "mpu#create" + get 'sale/:sale_id/payment/others_payment/VISA' => "visa#index" + get 'sale/:sale_id/payment/others_payment/Master' => "master#index" + get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index" get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index" #---------Add Customer --------------# @@ -170,7 +175,7 @@ Rails.application.routes.draw do resources :lookups #orders resources :orders - #sales + #sales resources :sales #cashier_terminals resources :cashier_terminals From 2e316f46febc0d89f81072eaf6490d6767f5e76e Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 13 Jun 2017 19:58:15 +0630 Subject: [PATCH 12/18] seed updated --- db/seeds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index ff505a83..9db92184 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -109,7 +109,7 @@ menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Chicken", #Default Menu items menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) -menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Single Pot",item_instance_code:"II0011", menu_item: menu_category1_menu_item0, price:00.00, is_on_promotion:false}]) +menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Single Pot",item_instance_code:"II0011", menu_item: menu_category1_menu_item0, price:12.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0041", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}]) menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Twin Pot", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 , account: food}) @@ -158,6 +158,6 @@ payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http//192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http//192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"REDEEM",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) puts " Finished System Default Set Up Data " From b86ae8d32d5c94863de7e304170c5b5138c87fc5 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 13 Jun 2017 20:11:24 +0630 Subject: [PATCH 13/18] customer search --- app/controllers/crm/customers_controller.rb | 9 ++-- .../origami/customers_controller.rb | 11 +++-- app/models/customer.rb | 7 ++- app/views/crm/customers/index.html.erb | 43 ++++++++++--------- app/views/layouts/CRM.html.erb | 2 +- app/views/origami/customers/index.html.erb | 29 +++++++------ 6 files changed, 61 insertions(+), 40 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 57f4eafc..f3a1fdf1 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -10,9 +10,12 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Customer.order("customer_id").page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) else - @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end + @crm_customers = Customer.search(filter) + + end #@crm_customers = Customer.all - @crm_customer = Customer.new + @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) + @crm_customer = Customer.new if flash["errors"] @crm_customer.valid? @@ -52,7 +55,7 @@ class Crm::CustomersController < BaseCrmController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("get_all_member_account") - merchant_uid = memberaction.merchant_account_id.to_s + merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 7d0b5502..e3fc7378 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -17,12 +17,17 @@ class Origami::CustomersController < BaseOrigamiController @sale_id = params[:sale_id] filter = params[:filter] + filter = params[:filter] + if filter.nil? - @crm_customers = Customer.order("name").page params[:page] + @crm_customers = Customer.order("customer_id").page(params[:page]) + #@products = Product.order("name").page(params[:page]).per(5) else - @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page params[:page] + @crm_customers = Customer.search(filter) + end - # @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2) + #@crm_customers = Customer.all + @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @crm_customer = Customer.new if flash["errors"] diff --git a/app/models/customer.rb b/app/models/customer.rb index b5e101cb..93834b43 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -34,12 +34,17 @@ class Customer < ApplicationRecord def self.search(search) if search - find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) + # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) + where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) else find(:all) end end + # def self.search(search) + # where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) + # end + def lastest_invoices sales.where(:customer_id => self.id).order("created_at desc").limit(5) end diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index d72c6a38..17f207c3 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -14,7 +14,7 @@
-
+
@@ -42,20 +42,21 @@ - <% @crm_customers.each do |crm_customer| %> - - - - <%= crm_customer.name %> - <%= crm_customer.company %> - <%= crm_customer.contact_no %> - <%= crm_customer.email %> - - <%= link_to 'Show', crm_customer_path(crm_customer) %> - - - - + <% if @crm_customers.count > 0 %> + <% @crm_customers.each do |crm_customer| %> + + + + <%= crm_customer.name %> + <%= crm_customer.company rescue '-' %> + <%= crm_customer.contact_no %> + <%= crm_customer.email %> + <%= link_to 'Show', crm_customer_path(crm_customer) %> + + + <% end %> + <%else%> +

There are no record for your search

<% end %> @@ -66,7 +67,7 @@
-
+
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> @@ -115,6 +116,11 @@
<%end%>
+
@@ -216,7 +222,4 @@ $(function() { } - - - - + \ No newline at end of file diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index 42b559e2..f1a43726 100644 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -21,7 +21,7 @@ <% if !flash["errors"]%> - <%=message%> + <%=message%> <% end %>
<% end %> diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 6fa5ae03..ba6ff75c 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -24,7 +24,8 @@ - <%= form_tag crm_customers_path, :method => :get do %> + <% path ="/origami/#{@sale_id}/customers" %> + <%= form_tag path, :method => :get do %>
@@ -42,17 +43,21 @@ - <% @crm_customers.each do |crm_customer| %> - - - - <%= crm_customer.name %> - <%= crm_customer.company rescue '-' %> - <%= crm_customer.contact_no %> - <%= crm_customer.email %> - - - + <% if @crm_customers.count > 0 %> + <% @crm_customers.each do |crm_customer| %> + + + + <%= crm_customer.name %> + <%= crm_customer.company rescue '-' %> + <%= crm_customer.contact_no %> + <%= crm_customer.email %> + + + + <% end %> + <%else%> +

There are no record for your search

<% end %> From 27971f406b16e23700fbc820582bba232afce31d Mon Sep 17 00:00:00 2001 From: Moe Su Date: Tue, 13 Jun 2017 20:22:28 +0630 Subject: [PATCH 14/18] Seed --- db/seeds.rb | 14 +++++++------- dump.rdb | Bin 22762 -> 23048 bytes 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 9db92184..a7fdc416 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -145,13 +145,13 @@ crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrder member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) -member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}, - {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"} +member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) diff --git a/dump.rdb b/dump.rdb index 9ce916eda38f8373c8dd26cf3de8976b140fd4ee..4f89d45d97d6e100481b552a620caeae3e319d8b 100644 GIT binary patch delta 800 zcmW-c+iFx-06_PdGr3L1#HiTVU}sJy13}!=eZS;E4V3!Qszo2XBsKf0RN{kL=t~F` zguWCi$2UbR#7kO^X{+D`1ltcNNIyUiM`P$0h!3HmAFvi{{rh|J!=vOUGq9|^53j$9KiyiqE6>a2HCwy&3sqAoS+>4p7(l-t&BxBCSq zYH9Pg*|qA!f7D!R!LyYHwiL36G__pG5LHIYSSt?1}MOPzF58Mo0qpZ!=zxJUKW7*N&l-0P$TWLAU* zxLd8v4PfnqGahBP66>;}&r_(3-nVP_kVKB!7`0=ccm8jCk{?Sa780(f&)11$5^Xfk zZP`-3v{_WEr$1)KGZ!?5Oau!V@dRpaA`HPFew7ByY<1xDdhhWlGggx5i6U6&$l1QB ky0(Jyx6PqJp1({Fr5i9j+*SYk#NaB6}h#R)W~sSXyUUu&@y;!6KONFZdpOX#INEdPK$+f1J7guY2!q@OU+>e!cwg zaq)Eg{LRIwbSgpURu`cmgo>ACc50&ha`<9-zc+g_HI_ydt-vzZfQ9A)10y-smU+v4 zXy-Yj%IDnOxwTTza7(DlaX~qqoFS3ZTsNlPPy6nDyXqnDv+)@zZ5D%OyFU~`D#&HFl~BvEhy<|Zvnxq%jV3BYV6He;FANZ`@gUKP zn<%2THlKwN%bjvc8|UgHgASoR4s&BjH>3TmdY&S+zZ?`5deLn4hbj2rj3?Q%mUUS* z;jeM54Fs$daoolTPKa!>UZ@b;Z%*s+AdHBd=R_LmoG>aHd#)MjACLg^Nk<7qSbeD4 zMQK}Z>{Z21v%Qp-uRF(kK~WkGP+^3441z< XXWI>4de07izuNtC<=fiaiT22Uo}#5* From e9d3ca30595c6f35c850abf0e58e4beb3f2706f1 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 13 Jun 2017 20:22:33 +0630 Subject: [PATCH 15/18] pull master for membership --- app/controllers/crm/customers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index f3a1fdf1..eac87e1e 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -107,7 +107,7 @@ class Crm::CustomersController < BaseCrmController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") - merchant_uid = memberaction.merchant_account_id.to_s + merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s From 3db625230428429e4456debdb161ce3661acc352 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 14 Jun 2017 00:09:54 +0630 Subject: [PATCH 16/18] update search and crm --- app/assets/javascripts/application.js | 3 +- app/assets/stylesheets/application.css | 0 app/assets/stylesheets/application.scss | 2 + .../origami/customers_controller.rb | 2 - app/controllers/settings/orders_controller.rb | 32 --- app/controllers/settings/sales_controller.rb | 32 --- .../transactions/sales_controller.rb | 24 +- app/models/order.rb | 9 + app/models/sale.rb | 3 +- app/views/crm/customers/index.html.erb | 25 +- app/views/crm/customers/show.html.erb | 218 +++++++++--------- app/views/layouts/_header.html.erb | 4 +- app/views/origami/customers/index.html.erb | 23 +- app/views/settings/orders/index.html.erb | 68 ------ app/views/settings/orders/show.html.erb | 85 ------- app/views/settings/sales/index.html.erb | 84 ------- app/views/settings/sales/show.html.erb | 103 --------- app/views/transactions/sales/index.html.erb | 133 ++++++----- app/views/transactions/sales/show.html.erb | 174 +++++++------- config/routes.rb | 5 +- 20 files changed, 352 insertions(+), 677 deletions(-) delete mode 100644 app/assets/stylesheets/application.css delete mode 100644 app/controllers/settings/orders_controller.rb delete mode 100644 app/controllers/settings/sales_controller.rb delete mode 100644 app/views/settings/orders/index.html.erb delete mode 100644 app/views/settings/orders/show.html.erb delete mode 100644 app/views/settings/sales/index.html.erb delete mode 100644 app/views/settings/sales/show.html.erb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b0937554..202d4387 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,6 +17,8 @@ //= require turbolinks //= require cable //= require settings/processing_items +//= require jquery-ui +//= require bootstrap-datepicker $(document).on("focus", "[data-behaviour~='datepicker']", function(e){ $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); @@ -153,4 +155,3 @@ $(function(){ } }); */ ->>>>>>> d54fd19d1c18384ee6b21c43ca51587fb7fa843f diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css deleted file mode 100644 index e69de29b..00000000 diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index bed2e04f..a4fa6b9f 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,6 +2,8 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; /* Show it is fixed to the top */ diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index e3fc7378..3215f9e6 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -10,8 +10,6 @@ class Origami::CustomersController < BaseOrigamiController def show end - - def add_customer @sale_id = params[:sale_id] diff --git a/app/controllers/settings/orders_controller.rb b/app/controllers/settings/orders_controller.rb deleted file mode 100644 index b5bbdc1c..00000000 --- a/app/controllers/settings/orders_controller.rb +++ /dev/null @@ -1,32 +0,0 @@ -class Settings::OrdersController < ApplicationController - def index - - filter = params[:filter] - if filter.nil? - orders = Order.order("order_id desc").limit(1000) - else - order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page]) - if order.count > 0 - orders = order - else - orders = Order.order("order_id desc").limit(1000) - flash[:notice] = "There is no data." - end - end - @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) - respond_to do |format| - format.html # index.html.erb - format.json { render json: @orders } - end - end - def show - - @order = Order.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.json { render json: @order } - end - end - -end diff --git a/app/controllers/settings/sales_controller.rb b/app/controllers/settings/sales_controller.rb deleted file mode 100644 index aabc2282..00000000 --- a/app/controllers/settings/sales_controller.rb +++ /dev/null @@ -1,32 +0,0 @@ -class Settings::SalesController < ApplicationController - def index - - search_date = params[:date] - receipt_no = params[:receipt_no] - today = Date.today - - if receipt_no.nil? - @sales = Sale.order("sale_id").page(params[:page]) - #@products = Product.order("name").page(params[:page]).per(5) - else - @sales = Sale.where("receipt_no LIKE ?", "%#{receipt_no}%").order("receipt_no").page(params[:page]) - end - #@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) - respond_to do |format| - format.html # index.html.erb - format.json { render json: @sales } - end - end - - def show - - @sale = Sale.find(params[:id]) - # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id) - respond_to do |format| - format.html # show.html.erb - format.json { render json: @sale } - end - end - - -end \ No newline at end of file diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index ea9e8ccd..edafb1db 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -4,12 +4,34 @@ class Transactions::SalesController < ApplicationController # GET /transactions/sales # GET /transactions/sales.json def index - @transactions_sales = Sale.all + + search_date = params[:date] + receipt_no = params[:receipt_no] + today = Date.today + + if receipt_no.nil? + @sales = Sale.order("sale_id").page(params[:page]) + #@products = Product.order("name").page(params[:page]).per(5) + else + @sales = Sale.search(receipt_no) + end + @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sales } + end end # GET /transactions/sales/1 # GET /transactions/sales/1.json def show + + @sale = Sale.find(params[:id]) + # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id) + respond_to do |format| + format.html # show.html.erb + format.json { render json: @sale } + end end # GET /transactions/sales/new diff --git a/app/models/order.rb b/app/models/order.rb index 21c00580..10c1a6c2 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -292,6 +292,15 @@ class Order < ApplicationRecord end + def self.search(search) + if search + # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) + where("order_id LIKE ?", "%#{search}%") + else + find(:all) + end + end + private def generate_custom_id diff --git a/app/models/sale.rb b/app/models/sale.rb index c0a73f3d..681bed64 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -261,7 +261,8 @@ class Sale < ApplicationRecord def self.search(search) if search - find(:all, :conditions => ['receipt_no LIKE ?', "%#{search}%"]) + # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) + where("receipt_no LIKE ?", "%#{search}%",) else find(:all) end diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 17f207c3..f3819466 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -25,8 +25,8 @@ <%= form_tag crm_customers_path, :method => :get do %> -
- +
+
<% end %> @@ -44,9 +44,9 @@ <% if @crm_customers.count > 0 %> <% @crm_customers.each do |crm_customer| %> - + - + <%= crm_customer.name %> <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> @@ -117,8 +117,9 @@ <%end%>
@@ -135,11 +136,10 @@ $(function() { $('.datepicker').css('cursor','pointer'); }); - $(document).on('click',".checkbox_check",function(){ - if(this.checked){ - + $(document).on('click',".customer_tr",function(){ + // if(this.checked){ var sale_id = $("#sale_id").val() || 0; - var customer_id = $(this).val(); + var customer_id = $(this).attr('data-ref'); if(sale_id != 0){ // var url = "/"+customer_id; @@ -178,9 +178,9 @@ $(function() { //$(".edit_customer").attr('method', 'PATCH'); } }); - }else{ + // }else{ - } + // } }) function update_sale(customer_id,sale_id) { @@ -205,7 +205,6 @@ $(function() { success: function(data) { if(data.status == true) { - alert('Customer has assigned'); window.location.href = '/origami' }else{ alert('Record not found!'); diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 62ebf9c0..e3530017 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -1,120 +1,130 @@
-
- -
-
+
+ + + + -
-
- -
-
-
- - - - - - - - - - - - - +
-
- - - - - - - - - <% -puts "hhhhhhhhhhhhhhhhhhhhh" - puts @member_data.to_json %> - - -
NameEmailContact noCompanyDate Of BirthMembership AccountBalanceType
<%= @crm_customer.name %><%= @crm_customer.email %><%= @crm_customer.contact_no %><%= @crm_customer.company %><%= @crm_customer.date_of_birth %> <%= @balance %> <%= @type %>
-
-

Order Items

+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Name<%= @crm_customer.name %>
Email<%= @crm_customer.email %>
Contact no<%= @crm_customer.contact_no %>
Company<%= @crm_customer.company %>
Date Of Birth<%= @crm_customer.date_of_birth %>
+
+
- - - - - - - - - - - - +
+

Order Details

+
+
Created at Menu ItemQTYUnit Price OptionStatusWaiter
+ + + + + + + + + + + + - - <% @order_items.each do |order_item| %> - - - - - - - - - - <% end %> - -
Order IDMenu ItemQTYUnit Price OptionStatusWaiterCreated at
<%= order_item.created_at %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %>
+ + <% @order_items.each do |order_item| %> + + <%= order_item.order_id %> + <%= order_item.item_name %> + <%= order_item.qty %> + <%= order_item.price %> + <%= order_item.options %> + <%= order_item.order_item_status %> + <%= order_item.item_order_by %> + <%= order_item.created_at.strftime("%d-%m-%y") %> + + <% end %> + + +
+
-

Sale Items

+
+

Sale Details

+
+ + + + + + + + + + + -
Sale ID Menu ItemQTYUnit Price Tax PriceCreated At
- - - - - - - - - - + + <% @sale_items.each do |sale_item| %> + + + + + + + + + + <% end %> + +
Sale ID Menu ItemQTYUnit Price Tax PriceCreated At
<%= sale_item.sale_id %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.unit_price %><%= sale_item.taxable_price %><%= sale_item.created_at %>
+
+
- - <% @sale_items.each do |sale_item| %> - - <%= sale_item.sale_id %> - <%= sale_item.product_name %> - <%= sale_item.qty %> - <%= sale_item.unit_price %> - - <%= sale_item.taxable_price %> - <%= sale_item.created_at %> - - <% end %> - -
-
-
+
+ - - - diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 4a74c7b1..58ecd9b5 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -28,8 +28,8 @@