update crm and bill

This commit is contained in:
Aung Myo
2017-07-02 14:06:21 +06:30
parent 09370a2a78
commit a0e16bd485
4 changed files with 87 additions and 34 deletions

View File

@@ -48,7 +48,22 @@ class Crm::CustomersController < BaseCrmController
#get customer amount
@customer = Customer.find(params[:id])
@response = Customer.get_membership_transactions(@customer)
@response = Customer.get_membership_transactions(@customer)
# get member information
total = Customer.get_member_account(@customer)
@balance = 0.00
@accountable_type = ''
if total["status"]==true
total["data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
@balance += res["balance"]
# @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end
end
end
# @response = ""
#end customer amount

View File

@@ -270,21 +270,17 @@ class ReceiptBillPdf < Prawn::Document
if rebate_amount["status"] == true
stroke_horizontal_rule
rebate = 0
redeem = 0
rebate_amount["data"].each do |res|
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
redeem = redeem + res["redeem"]
end
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate"
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate"
rebate = rebate + res["rebate"]
@@ -294,11 +290,35 @@ class ReceiptBillPdf < Prawn::Document
text "Rebate Earn", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateBonusAccount" && res["status"]== "Rebate"
rebate = rebate + res["rebate"]
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
end

View File

@@ -32,6 +32,7 @@
<th>NRC/Passport No</th>
<th>Address</th>
<th>DOB</th>
<th>Membership Type</th>
</tr>
</thead>
@@ -45,8 +46,16 @@
<td><%= @customer.nrc_no %></td>
<td><%= @customer.address%></td>
<td><%= @customer.date_of_birth %></td>
<% if @customer.membership_type.to_f > 0%>
<td><%lookup= Lookup.find_by_value(@customer.membership_type) %>
<%= lookup.name %>
</td>
<%else%>
<td>-</td>
<%end%>
</tr>
<tr><th colspan="8"></th></tr>
<tr><th colspan="9"></th></tr>
</tbody>
</table>
@@ -55,21 +64,19 @@
<div class="table-responsive">
<table class="table table-striped">
<thead>
<%
if @response["data"].present? %>
<tr>
<th colspan="5">Membership Transactions</th>
<% if @response["status"] == true %>
<th>Current Balance : <%= @response["data"].last["balance"]%></th>
<% end %>
<th>Current Balance : <%= @balance%></th>
</tr>
<% end %>
<tr>
<th>Date</th>
<th>Redeem</th>
<th>Rebate</th>
<th>Balance</th>
<!-- <th>Account No</th> -->
<th>From Account</th>
<th>Status</th>
<th>Receipt No</th>
</tr>
@@ -82,7 +89,7 @@
<td><%= transaction["redeem"]%></td>
<td><%= transaction["rebate"] %></td>
<td><%= transaction["balance"] %></td>
<!-- <td><%= transaction["account_no"] %></td> -->
<td><%= transaction["account_status"] %></td>
<td><%= transaction["status"] %></td>
<td><%= transaction["receipt_no"] %></td>

View File

@@ -39,6 +39,9 @@
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Customer Details</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#sale_audit" role="tab">Sale Audits</a>
</li> -->
</ul>
<!-- Nav tabs - End -->
@@ -235,23 +238,31 @@
</div>
</div>
<div class="tab-pane" id="sale_audit" role="tabpanel">
<br>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Status</th>
<th>Action At</th>
<th>Approved By</th>
<th>Remark</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- <div class="col-lg-2 col-md-2 col-sm-2">
<a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary btn-lg">
<i class="fa fa-arrow-left fa-lg"></i> Back
</a>
<a href="<%= transactions_void_path(@sale)%>" style="margin-top: 10px " class="btn btn-danger btn-lg">
<i class="fa fa-trash fa-lg"></i> Void Sale
</a>
<a href="<%= transactions_manual_complete_sale_path(@sale)%>" style="margin-top: 10px " class="btn btn-success btn-lg">
<i class="fa fa-invoice fa-lg"></i> Complete Sale
</a>
</div> -->
</div>