diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index c1d43773..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}); diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 2a618214..b5bcb827 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -192,7 +192,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; }); @@ -205,10 +205,11 @@ $(document).ready(function(){ var url = "origami/"+customer_id+"/get_customer/" } - $('.customer_detail').removeClass('hide'); + $('.customer_detail').removeClass('hide'); + //Start Ajax - $.ajax({ - type: "GET", + $.ajax({ + type: "GET", url: url, data: {}, dataType: "json", @@ -217,8 +218,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 = + '' + data["response_data"]["data"][i]["accountable_type"] +'' + +'' + balance + ''; + + $(".rebate_amount").append(row); + } + } }); } diff --git a/app/assets/javascripts/payment.js b/app/assets/javascripts/payment.js new file mode 100644 index 00000000..b7aadf05 --- /dev/null +++ b/app/assets/javascripts/payment.js @@ -0,0 +1,40 @@ +// number key pad +$(document).on('click', '.cashier_number', function(event){ + event.stopPropagation(); + event.preventDefault(); + if(event.handled !== true) { + var original_value; + original_value = $('#amount').text(); + + var input_value = $(this).attr("data-value"); + + var input_type = $(this).attr("data-type"); + switch (input_type) { + case 'num': + if (original_value == "0.0"){ + $('#amount').text(input_value); + }else{ + $('#amount').append(input_value); + } + break; + + case 'add': + var input_value = $(this).attr("data-value"); + amount = parseInt(input_value) + parseInt(original_value); + $('#amount').html(amount); + + break; + case 'clr': + $('#amount').html("0.0"); + break; + case 'del' : + var cash=$('#amount').text(); + $('#amount').text(cash.substr(0,cash.length-1)); + break; + + } + event.handled = true; + } else { + return false; + } +}); diff --git a/app/assets/javascripts/transactions.js b/app/assets/javascripts/transactions.js new file mode 100644 index 00000000..12e8ee44 --- /dev/null +++ b/app/assets/javascripts/transactions.js @@ -0,0 +1,7 @@ +//= require jquery +//= require bootstrap +//= require jquery_ujs +//= require turbolinks +//= require cable +//= require jquery-ui +//= require bootstrap-datepicker \ No newline at end of file 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/assets/stylesheets/transactions.scss b/app/assets/stylesheets/transactions.scss new file mode 100644 index 00000000..5ca9b171 --- /dev/null +++ b/app/assets/stylesheets/transactions.scss @@ -0,0 +1,5 @@ +@import "bootstrap"; +@import "font-awesome"; +@import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; \ No newline at end of file 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/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 1f35da76..eac87e1e 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? @@ -45,6 +48,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 @@ -75,12 +107,13 @@ 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 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 +126,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 +135,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 +144,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 +173,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/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 7d0b5502..3215f9e6 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -10,19 +10,22 @@ class Origami::CustomersController < BaseOrigamiController def show end - - def add_customer @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/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/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/payments_controller.rb b/app/controllers/origami/payments_controller.rb index bdae0f0e..a9437736 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -27,22 +27,28 @@ 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' } ) - + @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/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index b68fd30a..99601449 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) @@ -18,7 +36,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/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/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/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/settings/orders_controller.rb b/app/controllers/transactions/orders_controller.rb similarity index 61% rename from app/controllers/settings/orders_controller.rb rename to app/controllers/transactions/orders_controller.rb index b5bbdc1c..35cefe6f 100644 --- a/app/controllers/settings/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -1,16 +1,16 @@ -class Settings::OrdersController < ApplicationController +class Transactions::OrdersController < ApplicationController def index filter = params[:filter] if filter.nil? - orders = Order.order("order_id desc").limit(1000) + orders = Order.order("order_id desc") else - order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page]) + order = Order.search(filter) if order.count > 0 orders = order else - orders = Order.order("order_id desc").limit(1000) - flash[:notice] = "There is no data." + orders = Order.order("order_id desc") + end end @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) 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/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/models/order.rb b/app/models/order.rb index feb49cfa..397bd2f3 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" }) @@ -311,6 +311,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 c1e1d262..5adb8a33 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) @@ -260,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/models/sale_payment.rb b/app/models/sale_payment.rb index 894592b5..e0fe2e7c 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' @@ -211,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| @@ -255,10 +257,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/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index d72c6a38..f3819466 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -14,7 +14,7 @@
-
+
@@ -25,8 +25,8 @@ <%= form_tag crm_customers_path, :method => :get do %> -
- +
+
<% end %> @@ -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,12 @@
<%end%>
+
@@ -129,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; @@ -172,9 +178,9 @@ $(function() { //$(".edit_customer").attr('method', 'PATCH'); } }); - }else{ + // }else{ - } + // } }) function update_sale(customer_id,sale_id) { @@ -199,7 +205,6 @@ $(function() { success: function(data) { if(data.status == true) { - alert('Customer has assigned'); window.location.href = '/origami' }else{ alert('Record not found!'); @@ -216,7 +221,4 @@ $(function() { } - - - - + \ No newline at end of file diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index df1184b7..e3530017 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -1,113 +1,130 @@
-
- -
-
+
+ + + + -
-
- -
-
-
- - - - - - - - - - +
-
- - - - - - - - - -
NameEmailContact noCompanyDate Of Birth
<%= @crm_customer.name %><%= @crm_customer.email %><%= @crm_customer.contact_no %><%= @crm_customer.company %><%= @crm_customer.date_of_birth %>
-
-

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/crm/customers/showbackup.html.erb b/app/views/crm/customers/showbackup.html.erb new file mode 100644 index 00000000..936192cf --- /dev/null +++ b/app/views/crm/customers/showbackup.html.erb @@ -0,0 +1,85 @@ +
+
+ +
+
+ + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
NameEmailContact noCompanyDate Of BirthMembership Account
<%= @crm_customer.name %><%= @crm_customer.email %><%= @crm_customer.contact_no %><%= @crm_customer.company %><%= @crm_customer.date_of_birth %>
+
+ + +

Sale Items

+ + + + + + + + + + + + + + + <% @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 %>
+
+
+ +
+ + +
+ + + + + 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/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 @@