From 79a04ea9980192be65a94e8f4728d5c9c08afadb Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 14 Jan 2020 11:14:21 +0630 Subject: [PATCH] rake --- .../20200113100120_addcolumnsubdomain_shop.rb | 5 + lib/tasks/add_shopcode.rake | 172 ++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 db/migrate/20200113100120_addcolumnsubdomain_shop.rb create mode 100644 lib/tasks/add_shopcode.rake diff --git a/db/migrate/20200113100120_addcolumnsubdomain_shop.rb b/db/migrate/20200113100120_addcolumnsubdomain_shop.rb new file mode 100644 index 00000000..5c9a223b --- /dev/null +++ b/db/migrate/20200113100120_addcolumnsubdomain_shop.rb @@ -0,0 +1,5 @@ +class AddcolumnsubdomainShop < ActiveRecord::Migration[5.1] + def change + add_column :shops, :subdomain, :string + end +end diff --git a/lib/tasks/add_shopcode.rake b/lib/tasks/add_shopcode.rake new file mode 100644 index 00000000..fe2fb5de --- /dev/null +++ b/lib/tasks/add_shopcode.rake @@ -0,0 +1,172 @@ +namespace :shop_code do + task :add => :environment do + # rake shop_code:add shop_code= + puts ENV[shop_code] + gateway_communication_type = Lookup.create([{lookup_type:'gateway_communication_type',name: 'API',value: 'api',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'gateway_communication_type',name: 'USB',value: 'usb',shop_code: '#{ENV[shop_code]}'}]) + + payment_methods = Lookup.create([{lookup_type:'payment_methods',name: 'Cash',value: 'cash',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'CreditNote',value: 'creditnote',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - VISA',value: 'visa',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - MASTER',value: 'master',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - JCB',value: 'jcb',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - UnionPay',value: 'unionpay',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - MPU',value: 'jcb',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Vochure',value: 'vochure',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Giftcard',value: 'gift',shop_code: '#{ENV[shop_code]}'}]) + + payment_status = Lookup.create([{lookup_type:'payment_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_status',name: 'paid',value: 'paid',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_status',name: 'Fail',value: 'fail',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_status',name: 'Outstanding',value: 'outstanding',shop_code: '#{ENV[shop_code]}'}]) + + sales_status = Lookup.create([{lookup_type:'sales_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'sales_status',name: 'Void',value: 'void',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'sales_status',name: 'Completed',value: 'completed',shop_code: '#{ENV[shop_code]}'}]) + + order_status = Lookup.create([{lookup_type:'order_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_status',name: 'Completed',value: 'completed',shop_code: '#{ENV[shop_code]}'}]) + + order_item_status = Lookup.create([{lookup_type:'order_item_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_item_status',name: 'Processing',value: 'processing',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_item_status',name: 'Served',value: 'served',shop_code: '#{ENV[shop_code]}'},{lookup_type:'order_item_status',name: 'BIlled',value: 'billed',shop_code: '#{ENV[shop_code]}'}]) + + #order_source [tablet,order_station,emenu,api] + order_source = Lookup.create([{lookup_type:'order_source',name: 'API',value: 'api',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_source',name: 'Tablet',value: 'tablet',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_source',name: 'EMenu',value: 'emenu',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_source',name: 'Order Station',value: 'order_station',shop_code: '#{ENV[shop_code]}'}]) + + #order_type [dine-in,takeaway,delivery] + order_type = Lookup.create([{lookup_type:'order_type',name: 'Dine-in',value: 'dine-in',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_type',name: 'Takeaway',value: 'takeaway',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_type',name: 'Delivery',value: 'delivery',shop_code: '#{ENV[shop_code]}'}]) + + #menu_item_type:[simple| set| DIY] + menu_item_type = Lookup.create([{lookup_type:'menu_item_type',name: 'SIMPLE',value: 'simpleItem',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'menu_item_type',name: 'Set Menu',value: 'setMenu',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'menu_item_type',name: 'DIY',value: 'diy',shop_code: '#{ENV[shop_code]}'} + ]) + + member_group_type = Lookup.create([{lookup_type:'member_group_type',name: 'Normal',value: '1',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'member_group_type',name: 'Platinum',value: '5',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'member_group_type',name: 'Silver',value: '4',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'member_group_type',name: 'Gold',value: '3',shop_code: '#{ENV[shop_code]}'} + ]) + + #menu_item_attribute:[size|] + menu_item_attribute_type = Lookup.create([{lookup_type:'menu_item_attribute_type',name: 'Size',value: 'size',shop_code: '#{ENV[shop_code]}'}]) + + #Employee Roles + employee_roles = Lookup.create([{lookup_type:'employee_roles',name: 'Cashier',value: 'cashier',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Waiter',value: 'waiter',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Supervisor',value: 'supervisor',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Manager',value: 'manager',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Accountant',value: 'account',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Administrator',value: 'administrator',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'FoodCourt Cashier',value: 'foodcourt_cashier',shop_code: '#{ENV[shop_code]}'}]) + + #booking_status + booking_status = Lookup.create([{lookup_type:'booking_status',name: 'Available',value: 'available',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Reserved',value: 'reserved',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Occupied',value: 'occupied',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Cleaning',value: 'cleaning',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Moved',value: 'moved',shop_code: '#{ENV[shop_code]}'}]) + + #booking_status + account_type = Lookup.create([{lookup_type:'account_type',name: 'Income',value: '0',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'account_type',name: 'Expense',value: '1',shop_code: '#{ENV[shop_code]}'}]) + + # sale void reason + void_reason = Lookup.create([{lookup_type:'void_reason',name: 'Approve By Manager',value: 'Approve By Manager',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'void_reason',name: 'Customer Mistake',value: 'Customer Mistake',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'void_reason',name: 'Cashier Mistake',value: 'Cashier Mistake',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'void_reason',name: 'Waiter Mistake',value: 'Waiter Mistake',shop_code: '#{ENV[shop_code]}'}]) + + # sale void reason + float_value = Lookup.create([{lookup_type:'float_value',name: '500',value: '500',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'float_value',name: '1000',value: '1000',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'float_value',name: '5000',value: '5000',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'float_value',name: '10000',value: '10000',shop_code: '#{ENV[shop_code]}'}]) + + # customer type + customer_type = Lookup.create([{lookup_type:'customer_type',name: 'Dinein',value: 'Dinein',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'customer_type',name: 'FoodCourt',value: 'FoodCourt',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'customer_type',name: 'Takeaway',value: 'Takeaway',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'customer_type',name: 'Delivery',value: 'Delivery',shop_code: '#{ENV[shop_code]}'}]) + + #unit + units = Lookup.create([{lookup_type:'unit',name: 'PCS',value: 'pcs',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'unit',name: 'KG',value: 'kg',shop_code: '#{ENV[shop_code]}'}]) + + + # Country + countries = Lookup.create({lookup_type:'country',name: 'Japan',value: 'Japan',shop_code: '#{ENV[shop_code]}'}) + + # number formats + number_formats = Lookup.create([{lookup_type: 'number_format',name: 'precision','2',shop_code: '#{ENV[shop_code]}'}, + {lookup_type: 'number_format',name: 'delimiter','1',shop_code: '#{ENV[shop_code]}'}, + {lookup_type: 'number_format',name: 'strip_insignificant_zeros','0',shop_code: '#{ENV[shop_code]}'}]) + + # tax_profiles + tax_profiles = Lookup.create([{lookup_type:'tax_profiles',name: 'Cashier',value: 'cashier',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'tax_profiles',name: 'FoodCourt',value: 'food_court',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'tax_profiles',name: 'Online Order',value: 'online_order',shop_code: '#{ENV[shop_code]}'}]) + + # Default CUSTOMER + customer = Customer.create({name:"WALK-IN",email: "cus1@customer.com",contact_no:"000000000",card_no:"000",customer_type:"Dinein",tax_profiles:["2","1"],shop_code: '#{ENV[shop_code]}'}) + customer2 = Customer.create({name:"TAKEAWAY",email: "cus2@customer.com",contact_no:"111111111",card_no:"111",customer_type:"Takeaway",tax_profiles:["1"],shop_code: '#{ENV[shop_code]}'}) + + # Tax Profile FoodCourt + commercial_taxes_online_order = TaxProfile.create({id:1,name: "Commercial Tax",group_type: "food_court",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + service_charges_online_order = TaxProfile.create({id:2,name: "Service Charges",group_type: "food_court",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + #Tax Profile Online Order + commercial_taxes_online_order = TaxProfile.create({id:3,name: "Commercial Tax",group_type: "online_order",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + service_charges_online_order = TaxProfile.create({id:4,name: "Service Charges",group_type: "online_order",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + convenience_charges_online_order= TaxProfile.create({id:5,name: "Convenience Charges",group_type: "online_order",rate:5.0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + shop = Shop.create({name: "",address:'',township:"",state:"",city:"Yangon",country:"Myanmar",phone_no:"",reservation_no:"111",license:"", + license_data:"test",base_currency:"111",id_prefix:"111",is_rounding_adj:"0",quick_sale_summary:"0",shop_code: '#{ENV[shop_code]}'}) + + #Create Adminstrator employee + admin_employee = Employee.create({name: "Administrator",role: "administrator",password: "99999",emp_id:"999",created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + foodcourt_employee = Employee.create({name: "FoodCourt Cashier",role: "foodcourt_cashier",password: "22222",emp_id:"221",created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + + order_item_printer=PrintSetting.create({name: "OrderItemPdf",unique_code: "OrderItemPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + order_summary_printer=PrintSetting.create({name: "Order Summary",unique_code: "OrderSummaryPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + request_bill_printer=PrintSetting.create({name: "Receipt Bill",unique_code: "ReceiptBillPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + close_cashier_printer=PrintSetting.create({name: "Close Cashier",unique_code: "CloseCashierPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + crm_order_printer=PrintSetting.create({name: "CRM Order",unique_code: "CrmOrderPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + queue_no_printer=PrintSetting.create({name: "Queue No",unique_code: "QueueNoPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + + zone = Zone.create({id:1,name: "H1",is_active:true,created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paymal.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",shop_code: '#{ENV[shop_code]}'}) + + member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"search_paypar_security_code",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_security_code",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'} + ]) + + payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "/api/membership_campaigns/redeem",merchant_account_id:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"PAYMAL",gateway_url: "/api/create_payment",merchant_account_id:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}) + + puts " Finished System Default Set Up Data" + + end +end