From 1d873ddb68fb4136921b65d4b70a5d9752ced38b Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 12 Jul 2017 17:05:10 +0630 Subject: [PATCH] update member discount and seed for detail --- app/controllers/crm/customers_controller.rb | 16 +--------- .../origami/discounts_controller.rb | 31 +++++++++---------- app/models/seed_generator.rb | 11 +++++-- app/views/crm/customers/show.html.erb | 17 +++------- app/views/origami/discounts/index.html.erb | 18 ++++++----- app/views/origami/home/show.html.erb | 6 +++- app/views/origami/orders/show.html.erb | 6 +++- .../origami/other_charges/index.html.erb | 4 +++ app/views/origami/payments/show.html.erb | 7 ++++- .../origami/room_invoices/index.html.erb | 6 +++- app/views/origami/room_invoices/show.html.erb | 6 +++- app/views/origami/rooms/show.html.erb | 6 +++- app/views/origami/sales/show.html.erb | 6 +++- .../origami/table_invoices/index.html.erb | 6 +++- .../origami/table_invoices/show.html.erb | 6 +++- db/seeds.rb | 5 +-- 16 files changed, 94 insertions(+), 63 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 7b846db0..bbfdb912 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -49,21 +49,7 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) @response = Customer.get_membership_transactions(@customer) - # get member information - total = Customer.get_member_account(@customer) - - - @balance = 0.00 - @accountable_type = '' - if total["status"]==true - total["data"].each do |res| - if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" - @balance += res["balance"] - # @accountable_type = res["accountable_type"] - @accountable_type = "Rebate Balance" - end - end - end + # @response = "" #end customer amount diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index ce3a4f9d..6aa76921 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -170,37 +170,36 @@ class Origami::DiscountsController < BaseOrigamiController response = {status: false, message: "Can't open membership server "} rescue Net::OpenTimeout - response = { status: false , message: "Can't open membership server "} - rescue OpenURI::HTTPError response = { status: false, message: "Can't open membership server "} rescue SocketError response = { status: false, message: "Can't open membership server "} end - # {"status":true,"discount_earned":360.0,"is_bonus":false} - # {"status":false,"message":"Can't open membership server "} - - - puts "ssssssssss" - puts response.to_json["status"] - puts response["status"] table_id = sale.bookings[0].dining_facility_id table_type = DiningFacility.find(table_id).type - + puts response.to_json # Re-calc All Amount in Sale if response["status"] == true - sale.compute_by_sale_items(sale_id, sale.sale_items, response["discount_earned"]) + discount_amount = response["discount_earned"] + if response["discount_bonus_earned"] + discount_amount = discount_amount + response["discount_bonus_earned"] + end + sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount') result = {:status=> "Success", :table_id => table_id,:table_type => table_type } end - if response[:status] == false - result = {:status=> response[:message], :table_id => table_id,:table_type => table_type } - end - if response["status"] == 500 - result = {:status=> response["message"], :table_id => table_id,:table_type => table_type } + + if response["status"] == "500" + result = {:status=> response["error"], :table_id => table_id,:table_type => table_type } end + if !response.nil? + if response[:status] == false + result = {:status=> response[:message], :table_id => table_id,:table_type => table_type } + end + end + render :json => result.to_json end diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index a88cd8d7..335ab131 100644 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -60,8 +60,15 @@ class SeedGenerator < ApplicationRecord seed.save end - padding_len = 5 - prefix.length - next_code = prefix + seed.current.to_s.to_s.rjust((4-prefix.length)+1,'0') + + if prefix.length == 1 + padding_len = 5 - prefix.length + count = 4-prefix.length + else prefix.length == 2 + padding_len = 6 - prefix.length + count = 5-prefix.length + end + next_code = prefix + seed.current.to_s.to_s.rjust((count)+1,'0') return next_code end end diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 21a05d9c..f25aa4c8 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -64,18 +64,11 @@
- - - - - - - - - - + + + @@ -86,9 +79,9 @@ <% @response["data"].each do |transaction| %> - + - + diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index d59c74d4..35e290e3 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -67,7 +67,12 @@ --> - + <%if @sale_data.discount_type == 'member_discount'%> + + <%else%> + + <%end%> + @@ -503,18 +508,17 @@ $(document).ready(function(){ success:function(result){ if (result.status == "Success") { - status = result.status + type = 'green' + btn_color = 'btn-green' + }else{ type = 'red' btn_color = 'btn-red' - }else{ - status = result.status - type = '' - btn_color = 'btn-green' + } $.confirm({ title: 'Infomation!', - content: status, + content: result.status, columnClass: 'small', type: type, buttons: { diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 73959b5b..15f28cf8 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -220,7 +220,11 @@ - + <%if @obj_sale.discount_type == 'member_discount'%> + + <%else%> + + <%end%> diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index 40388847..e8c391d1 100644 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -175,7 +175,11 @@ - + <%if @selected_item.discount_type == 'member_discount'%> + + <%else%> + + <%end%> diff --git a/app/views/origami/other_charges/index.html.erb b/app/views/origami/other_charges/index.html.erb index 20bb5a4b..4c617477 100644 --- a/app/views/origami/other_charges/index.html.erb +++ b/app/views/origami/other_charges/index.html.erb @@ -59,7 +59,11 @@ + <%if @sale_data.discount_type == 'member_discount'%> + + <%else%> + <%end%> diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 1a325800..63b6b0d0 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -68,7 +68,12 @@ - + <%if @sale_data.discount_type == 'member_discount'%> + + <%else%> + + <%end%> + diff --git a/app/views/origami/room_invoices/index.html.erb b/app/views/origami/room_invoices/index.html.erb index 71b9bee7..3d88622e 100644 --- a/app/views/origami/room_invoices/index.html.erb +++ b/app/views/origami/room_invoices/index.html.erb @@ -40,7 +40,11 @@ - + <%if @sale.discount_type == 'member_discount'%> + + <%else%> + + <%end%> diff --git a/app/views/origami/room_invoices/show.html.erb b/app/views/origami/room_invoices/show.html.erb index b44340d4..86cb1789 100644 --- a/app/views/origami/room_invoices/show.html.erb +++ b/app/views/origami/room_invoices/show.html.erb @@ -106,7 +106,11 @@ - + <%if @sale.discount_type == 'member_discount'%> + + <%else%> + + <%end%> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 66a48522..988bcf5a 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -203,7 +203,11 @@ - + <%if @obj.discount_type == 'member_discount'%> + + <%else%> + + <%end%> <% if @status == "sale" %> diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index 9a8dc95d..dd58a577 100644 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -164,7 +164,11 @@ - + <%if @sale.discount_type == 'member_discount'%> + + <%else%> + + <%end%> diff --git a/app/views/origami/table_invoices/index.html.erb b/app/views/origami/table_invoices/index.html.erb index 95a6ee33..834d5f36 100644 --- a/app/views/origami/table_invoices/index.html.erb +++ b/app/views/origami/table_invoices/index.html.erb @@ -40,7 +40,11 @@ - + <%if @sale.discount_type == 'member_discount'%> + + <%else%> + + <%end%> diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb index c49ddfbc..b5769e02 100644 --- a/app/views/origami/table_invoices/show.html.erb +++ b/app/views/origami/table_invoices/show.html.erb @@ -106,7 +106,11 @@ - + <%if @sale.discount_type == 'member_discount'%> + + <%else%> + + <%end%> diff --git a/db/seeds.rb b/db/seeds.rb index 8fe62bde..08233594 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -138,7 +138,7 @@ menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size" menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"}) menu_item_attribute_size_large = MenuItemAttribute.create({attribute_type:"size", name: "Large", value: "large"}) -shop = Shop.create({id:1, name: "Beauty In the Pot", address:'No.42-A, Sayar San Road, Bahan, Yangon', township:"Bahan",state:"Yangon",city:"Yangon", country:"Myanmar", phone_no:"+95(9) 252221188, +95(9) 252221177",reservation_no:"111",license:"123", +shop = Shop.create({id:1, name: "OSAKA OHSHO", address:'No. 256, Kyaikkasan Road, Tamwe Township, Yangon', township:"Tamwe",state:"Yangon",city:"Yangon", country:"Myanmar", phone_no:"Tel: 09-258676611",reservation_no:"111",license:"123", activated_at:"2017-06-26 08:36:24",license_data:"test",base_currency:"111",id_prefix:"111"}) #Default Order Queue stations # order_queue_station1 = OrderQueueStation.create({station_name: "Queue Station 1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"}) @@ -172,7 +172,8 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {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"}, - {membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} + {membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"member_discount",gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:6},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"})
Membership TransactionsCurrent Balance : <%= @balance%>
DateRedeemRebateBalanceDiscount Amount From Account Status Receipt No
<%= transaction["date"]%><%= transaction["redeem"]%> <%= transaction["rebate"] %><%= transaction["balance"] %> <%= transaction["account_status"] %> <%= transaction["status"] %> <%= transaction["receipt_no"] %>
Discount:Member Discount:Discount:(<%=@sale_data.total_discount rescue 0%>)
Discount:Member Discount:Discount:(<%= @obj_sale.total_discount rescue 0%>)
<%= sub_total %>
Discount:Member Discount:Discount:(<%=@selected_item.total_discount rescue 0%>)
<%=sub_total%>
Member Discount:Discount:(<%=@sale_data.total_discount rescue 0%>)
(Discount)Member Discount:(Discount)(<%=@sale_data.total_discount rescue 0%>)
Discount:Member Discount:Discount:(<%= @sale.total_discount rescue 0%>)
<%= sub_total %>
Discount:Member Discount:Discount:(<%= @sale.total_discount rescue 0%>)
<%= sub_total %>
Discount:Member Discount:Discount:(<%=@obj.total_discount rescue 0%>)
<%= sub_total %>
Discount:Member Discount:Discount:(<%= @sale.total_discount rescue 0%>)
Discount:Member Discount:Discount:(<%= @sale.total_discount rescue 0%>)
<%= sub_total %>
Discount:Member Discount:Discount:(<%= @sale.total_discount rescue 0%>)