diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index ba451027..d314222b 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -67,8 +67,7 @@ class Crm::CustomersController < BaseCrmController # POST /crm/customers # POST /crm/customers.json - def create - + def create @crm_customers = Customer.new(customer_params) respond_to do |format| diff --git a/app/models/customer.rb b/app/models/customer.rb index c1751104..dff92ba2 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -10,7 +10,7 @@ class Customer < ApplicationRecord validates :contact_no, uniqueness: true, numericality: true validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create } validates :card_no, uniqueness: true - validates :paypar_account_no, uniqueness: true + # validates :paypar_account_no, uniqueness: true paginates_per 50 diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 69aa2143..ff2f6e2f 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -390,11 +390,14 @@ class SalePayment < ApplicationRecord total_percentage = 0 type_arr = [] - response["membership_campaign_data"].each do |a| - data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i} - total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i - - type_arr.push(data) + # Check for present response fields + if response["membership_campaign_data"].present? + response["membership_campaign_data"].each do |a| + data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i} + total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i + + type_arr.push(data) + end end rebate_arr =[] diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index 5ec0b903..1eda0bec 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -10,7 +10,7 @@ str.gsub!('["', '') str.gsub!('"]', '') %> <%= str %> - <% end -%> + <% end %>