update sale and customer
This commit is contained in:
@@ -51,33 +51,13 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
|
|
||||||
#get customer amount
|
#get customer amount
|
||||||
@customer = Customer.find(params[:id])
|
@customer = Customer.find(params[:id])
|
||||||
|
response = Customer.get_member_account(@customer)
|
||||||
|
|
||||||
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'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if(response["status"] == true)
|
if(response["status"] == true)
|
||||||
@membership = response["data"]
|
@membership = response["data"]
|
||||||
else
|
else
|
||||||
@membership = 0
|
@membership = 0
|
||||||
end
|
end
|
||||||
# @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 customer amount
|
||||||
|
|
||||||
|
|||||||
@@ -70,19 +70,7 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
|
|
||||||
@customer = Customer.find(params[:customer_id])
|
@customer = Customer.find(params[:customer_id])
|
||||||
|
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
response = Customer.get_member_account(@customer)
|
||||||
|
|
||||||
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'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js do
|
format.js do
|
||||||
|
|||||||
@@ -92,6 +92,16 @@ class Transactions::SalesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def void
|
||||||
|
@sale = params[:sale_id]
|
||||||
|
@reason = Lookup.where("lookup_type = 'void_reason'")
|
||||||
|
end
|
||||||
|
|
||||||
|
def manual_void_sale
|
||||||
|
sale_id = params[:sale_id]
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_transactions_sale
|
def set_transactions_sale
|
||||||
|
|||||||
@@ -12,21 +12,40 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
paginates_per 50
|
paginates_per 50
|
||||||
|
|
||||||
def self.get_member_group
|
# def self.get_member_group
|
||||||
|
|
||||||
|
# membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
|
# memberaction = MembershipAction.find_by_membership_type("get_all_member_group")
|
||||||
|
# app_token = membership.auth_token.to_s
|
||||||
|
|
||||||
|
# url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
# response = HTTParty.get(url,
|
||||||
|
# :body => { app_token: app_token}.to_json,
|
||||||
|
# :headers => {
|
||||||
|
# 'Content-Type' => 'application/json',
|
||||||
|
# 'Accept' => 'application/json'
|
||||||
|
# }
|
||||||
|
# )
|
||||||
|
# puts response.body, response.code, response.message, response.headers.inspect
|
||||||
|
|
||||||
|
# return response;
|
||||||
|
|
||||||
|
# end
|
||||||
|
|
||||||
|
def self.get_member_account(customer)
|
||||||
|
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.find_by_membership_type("get_all_member_group")
|
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
|
||||||
app_token = membership.auth_token.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
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
response = HTTParty.get(url,
|
|
||||||
:body => { app_token: app_token}.to_json,
|
response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||||
:headers => {
|
:headers => {
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
puts response.body, response.code, response.message, response.headers.inspect
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
<td>Grand Total</td>
|
<td>Grand Total</td>
|
||||||
<td colspan="2"><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
<td colspan="2"><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td> <td></tr>
|
<tr><td colspan="5"> <td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan=2 style="text-align:center"></td>
|
<td colspan=2 style="text-align:center"></td>
|
||||||
<td>Pay Amount</td>
|
<td>Pay Amount</td>
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan=2 style="text-align:center"></td>
|
<td colspan=2 style="text-align:center"></td>
|
||||||
<td>Payment <%= r.payment_method rescue ' '%></td>
|
<td>Payment <%= r.payment_method rescue ' '%></td>
|
||||||
<td><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
|
<td colspan="2"><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@@ -171,12 +171,12 @@
|
|||||||
<i class="fa fa-arrow-left fa-lg"></i> Back
|
<i class="fa fa-arrow-left fa-lg"></i> Back
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
|
<!-- <a href="<%= transactions_void_path(@sale)%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
|
||||||
<i class="fa fa-trash fa-lg"></i> Void Sale
|
<i class="fa fa-trash fa-lg"></i> Void Sale
|
||||||
</a>
|
</a>
|
||||||
<a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
|
<a href="<%= transactions_manual_void_sale_path(@sale)%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
|
||||||
<i class="fa fa-invoice fa-lg"></i> Complete Sale
|
<i class="fa fa-invoice fa-lg"></i> Complete Sale
|
||||||
</a>
|
</a> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li><a href="<%= crm_root_path %>">Home</a></li>
|
|
||||||
<li class="active">
|
|
||||||
<a href="<%= transactions_sales_path %>">Sale</a>
|
|
||||||
</li>
|
|
||||||
<li class="active">
|
|
||||||
<a href="<%= transactions_sales_path %>"><%= @sale.sale_id %></a>
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<div class="main-box-body clearfix">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td colspan="4">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="6"> </td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Receipt Date </th>
|
|
||||||
<th>Receipt no</th>
|
|
||||||
<th>Cashier</th>
|
|
||||||
<th>Sales status</th>
|
|
||||||
<th>Receipt generated at</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td><%= @sale.receipt_date.strftime("%d-%M-%Y") %></td>
|
|
||||||
<td><%= @sale.receipt_no %></td>
|
|
||||||
<td><%= @sale.cashier rescue '-' %></td>
|
|
||||||
<td> <%= @sale.sale_status %> </td>
|
|
||||||
<td> <%= @sale.requested_at.strftime("%d-%m-%Y") %> </td>
|
|
||||||
</tr>
|
|
||||||
<tr style="border-top:2px solid #000">
|
|
||||||
<th>Sale item name</th>
|
|
||||||
<th> Qty</th>
|
|
||||||
<th>Unit price</th>
|
|
||||||
<th>Total pirce </th>
|
|
||||||
<th>Created at</th>
|
|
||||||
</tr>
|
|
||||||
<% @sale.sale_items.each do |s| %>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td><%=s.product_name rescue ' '%></td>
|
|
||||||
<td><%=s.qty rescue ' '%></td>
|
|
||||||
<td><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
<td><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
<td><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %></td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<tr style="border-top:2px solid #000">
|
|
||||||
<td colspan=2 style="text-align:center"></td>
|
|
||||||
<td>Total</td>
|
|
||||||
<td colspan="2"><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan=2 style="text-align:center"></td>
|
|
||||||
<td>Discount</td>
|
|
||||||
<td colspan="2"><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan=2 style="text-align:center"></td>
|
|
||||||
<td>Tax</td>
|
|
||||||
<td colspan="2"><%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan=2 style="text-align:center"></td>
|
|
||||||
<td>Grand Total</td>
|
|
||||||
<td colspan="2"><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
</tr>
|
|
||||||
<tr><td> <td></tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan=2 style="text-align:center"></td>
|
|
||||||
<td>Pay Amount</td>
|
|
||||||
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan=2 style="text-align:center"></td>
|
|
||||||
<td>Change</td>
|
|
||||||
<td colspan="2"><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
59
app/views/transactions/sales/void.html.erb
Normal file
59
app/views/transactions/sales/void.html.erb
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li><a href="<%= crm_root_path %>">Home</a></li>
|
||||||
|
<li class="active">
|
||||||
|
<a href="<%= transactions_sales_path %>">Sale</a>
|
||||||
|
</li>
|
||||||
|
<li class="active">
|
||||||
|
<a href="<%= transactions_sale_path(@sale) %>"><%= %></a>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-lg-10 col-md-10 col-sm-10">
|
||||||
|
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||||
|
|
||||||
|
<div class="tab-pane active" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||||
|
<h3>Choose your reason</h3>
|
||||||
|
<table>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div class="checkbox checkbox-primary">
|
||||||
|
<input id="checkbox" class="styled checkbox-primary" type="checkbox" checked="">
|
||||||
|
<label for="checkbox">
|
||||||
|
Primary
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||||
|
|
||||||
|
<a href="<%= transactions_sale_path(@sale)%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
|
||||||
|
<i class="fa fa-arrow-left fa-lg"></i> Back
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -198,6 +198,8 @@ Rails.application.routes.draw do
|
|||||||
namespace :transactions do
|
namespace :transactions do
|
||||||
resources :sales
|
resources :sales
|
||||||
resources :orders
|
resources :orders
|
||||||
|
get "/sales/:sale_id/void" =>"sales#void", :as => "void"
|
||||||
|
post "sales/manual_void_sale", to: "sales#manual_void_sale", :as => "manual_void_sale"
|
||||||
end
|
end
|
||||||
|
|
||||||
#--------- Reports Controller Sections ------------#
|
#--------- Reports Controller Sections ------------#
|
||||||
|
|||||||
Reference in New Issue
Block a user