diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 0d2d9082..2cdd44b5 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -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 diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 6d8df8c6..87fae97d 100644 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -1,5 +1,5 @@ class Reports::ShiftsaleController < BaseReportController - # authorize_resource :class => false + authorize_resource :class => false def index diff --git a/app/models/ability.rb b/app/models/ability.rb index 624fa76a..c4120bc1 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 diff --git a/app/models/sale.rb b/app/models/sale.rb index deb9be9e..2e8794d5 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -93,7 +93,6 @@ class Sale < ApplicationRecord end - self.save! #compute sales summary diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 3817c509..bff0852d 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -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? diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 3cf08856..5d36f5c3 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -60,7 +60,7 @@ Membership Transactions <% if @response["status"] == true %> - Current Balance : <%= @response["data"][0]["balance"]%> + Current Balance : <%= @response["data"].last["balance"]%> <% end %> <% end %> diff --git a/app/views/reports/shiftsale/index.xls.erb b/app/views/reports/shiftsale/index.xls.erb index 67e76e3c..c2a8a6d2 100644 --- a/app/views/reports/shiftsale/index.xls.erb +++ b/app/views/reports/shiftsale/index.xls.erb @@ -1,116 +1,86 @@ -
-
- - - <% if params[:from]%> - - - - <% end %> - - - - - - - - - - - - - - - - - - - <% unless @sale_data.empty? %> - - - <% 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 %> - - - - - - - - - - - - - - - - - - <% count = count + 1 %> - <% end %> +
+
+
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateVoid AmountMpu SalesMaster SalesVisa SalesJcb SalesPaypar SalesCash SalesCredit SalesFOC Sales(Discount)Grand Total +
Rounding Adj.
Rounding Adj.Grand Total
<%= count %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%>
+ + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + + <% void = 0%> + <% cash = 0%> + <% credit = 0%> + <% accept_credit = 0%> + <% foc = 0%> + <% card = 0%> + <% total = 0%> + <% rounding_adj = 0%> + <% g_total = 0 %> - - - - - - - - - - - - - - - + <% @sale_data.each do |result|%> + + + + + + + + + + + - <% total_tax = 0 %> - <% unless @tax.empty? %> - <% @tax.each do |tax| %> - <% total_tax += tax.tax_amount.to_f %> - - - - - - - <% end %> - <% net = total - total_tax %> - - - - - - <% end %> - - <% end %> -
From Date : <%= params[:from] rescue '-'%> ,To Date : <%= params[:to] rescue '-'%>
Cashier StationCashier NameShift NameCash PaymentCredit PaymentOther PaymentGrand Total
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%>
+ <%= result.cashier_terminal.name rescue '-'%> + + <%= result.employee.name rescue '-'%> + <%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> - + <%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %> + <%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%><%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%><%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%><%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+ + <% grand_total = result.grand_total.to_f %> + <%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%> + + <% 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 %> + + + + + <%= sprintf("%.2f",cash) rescue '-'%> + <%= sprintf("%.2f",credit) rescue '-'%> + + + <%= sprintf("%.2f",card) rescue '-'%> + + + <%= sprintf("%.2f",g_total) rescue '-'%> + + +
\ No newline at end of file