update crm
This commit is contained in:
@@ -9,11 +9,11 @@ class Api::BillController < Api::ApiController
|
||||
#create Bill by Booking ID
|
||||
if (params[:booking_id])
|
||||
@sale = Sale.new
|
||||
@status = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
|
||||
|
||||
elsif (params[:order_id])
|
||||
@sale = Sale.new
|
||||
@status = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name)
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,9 +71,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
)
|
||||
|
||||
if response["status"] == true
|
||||
puts "hhhhhhhhhhhhhhhhhh"
|
||||
puts params[:sale_id]
|
||||
puts response.to_json
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
|
||||
if params[:sale_id] != 0
|
||||
@@ -188,5 +185,3 @@ class Crm::CustomersController < BaseCrmController
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_type, :membership_authentication_code)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@sale_data.sale_payments.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash = spay.payment_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ class Sale < ApplicationRecord
|
||||
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)
|
||||
puts "get invoice from booking"
|
||||
booking = Booking.find(booking_id)
|
||||
status = false
|
||||
Rails.logger.debug "Booking -> " + booking.id.to_s
|
||||
|
||||
@@ -16,11 +16,8 @@ class SaleOrder < ApplicationRecord
|
||||
|
||||
private
|
||||
def generate_sale_order_id
|
||||
puts "create slae order id"
|
||||
self.class.name
|
||||
saleOrderId = SeedGenerator.generate_id(self.class.name, "SOI")
|
||||
puts saleOrderId
|
||||
self.sale_order_id = saleOrderId
|
||||
puts "create sale order id"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -205,12 +205,23 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount)
|
||||
puts "sale update"
|
||||
#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
|
||||
|
||||
if (self.sale.grand_total <= self.sale.amount_received.to_f && self.sale.amount_changed.to_f > 0)
|
||||
all_received_amount = 0.0
|
||||
sObj = self.sale
|
||||
sObj.sale_payments.each do |spay|
|
||||
puts spay
|
||||
puts spay.payment_amount
|
||||
all_received_amount += spay.payment_amount.to_f
|
||||
end
|
||||
puts all_received_amount
|
||||
puts self.sale.grand_total
|
||||
if (self.sale.grand_total <= all_received_amount)
|
||||
puts " sale update ......"
|
||||
self.sale.payment_status = "paid"
|
||||
self.sale.sale_status = "completed"
|
||||
self.sale.save!
|
||||
|
||||
@@ -2,19 +2,15 @@ class SeedGenerator < ApplicationRecord
|
||||
|
||||
def self.generate_id(model, prefix)
|
||||
seed = SeedGenerator.find_by_model(model)
|
||||
puts "found seed"
|
||||
puts seed
|
||||
new_receipt_no = 0
|
||||
|
||||
if (seed.nil?)
|
||||
puts "seed is null"
|
||||
seed = SeedGenerator.new()
|
||||
seed.model = model
|
||||
new_receipt_no = seed.next
|
||||
seed.save
|
||||
|
||||
else
|
||||
puts "seed is not null"
|
||||
current_no = seed.next
|
||||
seed.next = seed.next + seed.increase_by
|
||||
seed.current = current_no
|
||||
@@ -22,8 +18,6 @@ class SeedGenerator < ApplicationRecord
|
||||
end
|
||||
|
||||
padding_len = 15 - prefix.length
|
||||
puts prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||
puts "this is actural sale orde"
|
||||
saleOrderId = prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||
return saleOrderId
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-8">CASH</div>
|
||||
<div class="col-md-4" id="cash" >0.0</div>
|
||||
<div class="col-md-4" id="cash" ><%= @cash %></div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row" id="credit_payment">
|
||||
|
||||
Reference in New Issue
Block a user