update receipt bill
This commit is contained in:
@@ -9,10 +9,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
sale_items = SaleItem.where("sale_id=?",sale_id)
|
||||
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
rounding_adj = sale_data.grand_total - new_total
|
||||
|
||||
sale_data.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
|
||||
# Print for First Bill to Customer
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
@@ -43,7 +39,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = saleObj.grand_total - new_total
|
||||
|
||||
saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
|
||||
|
||||
rebate_amount = nil
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Reports::ShiftsaleController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class Ability
|
||||
can :index, :dailysale
|
||||
can :index, :saleitem
|
||||
can :index, :receipt_no
|
||||
can :index, :shiftsale
|
||||
|
||||
can :add_customer, Customer
|
||||
can :update_sale_by_customer, Customer
|
||||
@@ -98,14 +99,16 @@ class Ability
|
||||
elsif user.role == "accountant"
|
||||
|
||||
can :index, :dailysale
|
||||
can :manage, :saleitem
|
||||
can :index, :receiptno
|
||||
can :index, :saleitem
|
||||
can :index, :receipt_no
|
||||
can :index, :shiftsale
|
||||
|
||||
elsif user.role == "supervisour"
|
||||
|
||||
can :index, :dailysale
|
||||
can :manage, :saleitem
|
||||
can :index, :receiptno
|
||||
can :index, :saleitem
|
||||
can :index, :receipt_no
|
||||
can :index, :shiftsale
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -93,7 +93,6 @@ class Sale < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
|
||||
self.save!
|
||||
|
||||
#compute sales summary
|
||||
|
||||
@@ -95,7 +95,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
|
||||
text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
|
||||
text "Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
|
||||
@@ -202,6 +202,18 @@ class ReceiptBillPdf < Prawn::Document
|
||||
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||
# end
|
||||
|
||||
if sale_data.rounding_adjustment != 0.0
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Rounding Adjustment", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
@@ -253,18 +265,13 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
if rebate_amount["status"] == true
|
||||
stroke_horizontal_rule
|
||||
rebate = 0
|
||||
rebate_amount["data"].each do |res|
|
||||
|
||||
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate"
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Current Rebate 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["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
rebate = rebate + res["rebate"]
|
||||
|
||||
end
|
||||
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
|
||||
|
||||
@@ -279,6 +286,14 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
end
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Current Rebate 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(rebate, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
if member_info["status"] == true && member_info["data"].present?
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<tr>
|
||||
<th colspan="5">Membership Transactions</th>
|
||||
<% if @response["status"] == true %>
|
||||
<th>Current Balance : <%= @response["data"][0]["balance"]%></th>
|
||||
<th>Current Balance : <%= @response["data"].last["balance"]%></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -1,116 +1,86 @@
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<% if params[:from]%>
|
||||
<tr>
|
||||
<th colspan="17"> Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th style='text-align:center;'>Sr.no</th>
|
||||
<th style='text-align:center;'>Date</th>
|
||||
<th style='text-align:center;'>Void Amount</th>
|
||||
<th style='text-align:center;'>Mpu Sales</th>
|
||||
<th style='text-align:center;'>Master Sales</th>
|
||||
<th style='text-align:center;'>Visa Sales</th>
|
||||
<th style='text-align:center;'>Jcb Sales</th>
|
||||
<th style='text-align:center;'>Paypar Sales</th>
|
||||
<th style='text-align:center;'>Cash Sales</th>
|
||||
<th style='text-align:center;'>Credit Sales</th>
|
||||
<th style='text-align:center;'>FOC Sales</th>
|
||||
<th style='text-align:center;'>(Discount)</th>
|
||||
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
|
||||
<th style='text-align:center;'>Rounding Adj.</th>
|
||||
<th style='text-align:center;'>Grand Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% unless @sale_data.empty? %>
|
||||
|
||||
<tbody>
|
||||
<% void = 0 %>
|
||||
<% mpu = 0 %>
|
||||
<% master = 0 %>
|
||||
<% visa = 0 %>
|
||||
<% jcb = 0 %>
|
||||
<% paypar = 0 %>
|
||||
<% cash = 0 %>
|
||||
<% credit = 0 %>
|
||||
<% foc = 0 %>
|
||||
<% discount = 0 %>
|
||||
<% total = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% count = 1 %> <% rounding_adj = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% void += sale[:void_amount] %>
|
||||
<% mpu += sale[:mpu_amount] %>
|
||||
<% master += sale[:master_amount] %>
|
||||
<% visa += sale[:visa_amount] %>
|
||||
<% jcb += sale[:jcb_amount] %>
|
||||
<% paypar += sale[:paypar_amount] %>
|
||||
<% cash += sale[:cash_amount] %>
|
||||
<% credit += sale[:credit_amount] %>
|
||||
<% foc += sale[:foc_amount] %>
|
||||
<% discount += sale[:total_discount] %>
|
||||
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||
<% grand_total += sale[:grand_total].to_f %>
|
||||
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||
<tr>
|
||||
<td style='text-align:right;'><%= count %></td>
|
||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>
|
||||
</tr>
|
||||
<% count = count + 1 %>
|
||||
<% end %>
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<% if params[:from]%>
|
||||
<tr>
|
||||
<th colspan="7">From Date : <%= params[:from] rescue '-'%> ,To Date : <%= params[:to] rescue '-'%></th>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<th>Cashier Station</th>
|
||||
<th>Cashier Name</th>
|
||||
<th>Shift Name</th>
|
||||
<!-- <th>Void Amount</th> -->
|
||||
<th>Cash Payment</th>
|
||||
<!-- <th>Credit Charges</th> -->
|
||||
<th>Credit Payment</th>
|
||||
<!-- <th>FOC Payment</th> -->
|
||||
<th>Other Payment</th>
|
||||
<!-- <th>Grand Total
|
||||
<br/>Rounding Adj</th> -->
|
||||
<!-- <th>Rounding Adj</th> -->
|
||||
<th>Grand Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% void = 0%>
|
||||
<% cash = 0%>
|
||||
<% credit = 0%>
|
||||
<% accept_credit = 0%>
|
||||
<% foc = 0%>
|
||||
<% card = 0%>
|
||||
<% total = 0%>
|
||||
<% rounding_adj = 0%>
|
||||
<% g_total = 0 %>
|
||||
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="3" style='text-align:center;'>Total</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%></td>
|
||||
</tr>
|
||||
<% @sale_data.each do |result|%>
|
||||
<tr>
|
||||
<td>
|
||||
<%= result.cashier_terminal.name rescue '-'%>
|
||||
</td>
|
||||
<td>
|
||||
<%= result.employee.name rescue '-'%>
|
||||
</td>
|
||||
<td><%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
|
||||
<%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
|
||||
</td>
|
||||
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
|
||||
<td><%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%></td>
|
||||
<td><%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%></td>
|
||||
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
|
||||
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
|
||||
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
|
||||
<td><%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%></td>
|
||||
<td><%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%></td>
|
||||
|
||||
<% total_tax = 0 %>
|
||||
<% unless @tax.empty? %>
|
||||
<% @tax.each do |tax| %>
|
||||
<% total_tax += tax.tax_amount.to_f %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
<% net = total - total_tax %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="12" style='text-align:right;'>Net Amount</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
</table>
|
||||
<!-- <td><%= sprintf "%.2f",result.rounding_adj.to_f.to_d rescue '-'%></td> -->
|
||||
<% grand_total = result.grand_total.to_f %>
|
||||
<td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td>
|
||||
</tr>
|
||||
<% cash += result.cash_sales.to_f %>
|
||||
<% credit += result.credit_sales.to_f %>
|
||||
<% card += result.other_sales.to_f %>
|
||||
|
||||
<% total += result.grand_total.to_f %>
|
||||
<% g_total += grand_total.to_f %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<tr style="border-top: 3px solid grey;">
|
||||
<td colspan="3"></td>
|
||||
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
|
||||
<td><b><%= sprintf("%.2f",cash) rescue '-'%></b></td>
|
||||
<td><b><%= sprintf("%.2f",credit) rescue '-'%></b></td>
|
||||
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
|
||||
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
|
||||
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
|
||||
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
|
||||
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
|
||||
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user