Payment Credit
++
| Payment Reference + | ++ |
| Remark + | ++ |
| Payment Method + | ++ + + + + | +
+
+
Payment Debit
+| Payment Reference + | ++ |
| Remark + | ++ |
| Amount + | ++ |
+
diff --git a/Gemfile b/Gemfile index 227cfa72..4c544ad6 100644 --- a/Gemfile +++ b/Gemfile @@ -9,10 +9,13 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record + +#gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'pg' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' + # redis server for cable # gem 'redis', '~> 3.0' diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 3cb03b0b..cb3b9cc2 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -25,25 +25,30 @@ class Api::BillController < Api::ApiController @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) end - @sale_data = Sale.find_by_sale_id(@sale_id) - @sale_items = SaleItem.where("sale_id=?",@sale_id) +# Not Use for these printed bill cannot give customer + # @sale_data = Sale.find_by_sale_id(@sale_id) + # @sale_items = SaleItem.where("sale_id=?",@sale_id) - unique_code = "ReceiptBillPdf" - #shop detail - shop_details = Shop.find(1) + # unique_code = "ReceiptBillPdf" + # #shop detail + # shop_details = Shop.find(1) - customer= Customer.find(@sale_data.customer_id) - # get member information - member_info = Customer.get_member_account(customer) + # customer= Customer.find(@sale_data.customer_id) + # # get member information + # member_info = Customer.get_member_account(customer) - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) - # Calculate Price by accounts - item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) + + # # Calculate Price by accounts + # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + + + # printer = Printer::ReceiptPrinter.new(print_settings) + # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details) + - printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts) end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 2fb61b1f..e3184ecc 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -68,8 +68,10 @@ class Api::OrdersController < Api::ApiController if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved' if !booking.sale_id.nil? sale_status = check_order_with_booking(booking) + puts "WWwwWWWWWWww" + puts sale_status if sale_status - return false + return false , @message = "bill requested" end else @order.new_booking = false @@ -77,22 +79,38 @@ class Api::OrdersController < Api::ApiController end else sale_status = check_order_with_table(params[:table_id]) + puts "OOOOOOOOO" + puts sale_status if sale_status - return false + return false , @message = "bill requested" end end end #booking exists else - check_order_with_table(params[:table_id]) - end + sale_status = check_order_with_table(params[:table_id]) + puts "MMMMMMMM" + puts sale_status + if sale_status + return false , @message = "bill requested" + end + end @status, @booking = @order.generate end + # render json for http status code 202 + def return_json_status_with_code(code, msg, booking_id) + render status: code, json: { + message: msg, + booking_id: booking_id + }.to_json + end + def check_order_with_table(table_id) table = DiningFacility.find(table_id) if table booking = table.get_current_booking + puts booking if booking if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" @order.new_booking = true diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index e7e960ee..3136417f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,7 +2,7 @@ class HomeController < ApplicationController skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy] def index - @employees = Employee.all.order("name asc") + @employees = Employee.all_emp_except_waiter.order("name asc") @login_form = LoginForm.new() end @@ -20,7 +20,6 @@ class HomeController < ApplicationController if @employee != nil session[:session_token] = @employee.token_session route_by_role(@employee) - else render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!" end @@ -38,7 +37,7 @@ class HomeController < ApplicationController redirect_to dashboard_path elsif @employee.role == "cashier" session[:session_token] = @employee.token_session - redirect_to origami_root_path + route_by_role(@employee) elsif @employee.role == "manager" session[:session_token] = @employee.token_session redirect_to dashboard_path @@ -81,13 +80,13 @@ class HomeController < ApplicationController redirect_to dashboard_path elsif employee.role == "cashier" #check if cashier has existing open cashier - - # if !ShiftSale.current_open_shift(employee).nil? - # redirect_to origami_root_path - # else + shift = ShiftSale.current_open_shift(employee.id) + if !shift.nil? + redirect_to origami_root_path + else redirect_to new_origami_shift_path - # end - elsif employee.role == "checker" + end + elsif employee.role == "manager" redirect_to oqs_root_path elsif employee.role == "waiter" redirect_to oqs_root_path diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb new file mode 100644 index 00000000..dd78bc1b --- /dev/null +++ b/app/controllers/origami/cash_ins_controller.rb @@ -0,0 +1,15 @@ +class Origami::CashInsController < BaseOrigamiController + + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + payment_method = params[:payment_method] + payment_method_reference = params[:payment_method_reference] + p_jour = PaymentJournal.new + p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id) + end +end diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb new file mode 100644 index 00000000..ac079a39 --- /dev/null +++ b/app/controllers/origami/cash_outs_controller.rb @@ -0,0 +1,13 @@ +class Origami::CashOutsController < BaseOrigamiController + + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + p_jour = PaymentJournal.new + p_jour.cash_out(reference, remark, amount, current_user.id) + end +end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 1b0aa491..32f4ab12 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -6,6 +6,7 @@ class Origami::HomeController < BaseOrigamiController @rooms = Room.all.active.order('status desc') @complete = Sale.all @orders = Order.all.order('date desc') + # @shift = ShiftSale.current_open_shift(current_user.id) end # origami table detail diff --git a/app/controllers/origami/home_controller_bk.rb b/app/controllers/origami/home_controller_bk.rb index 1aca9b2d..5496cca5 100644 --- a/app/controllers/origami/home_controller_bk.rb +++ b/app/controllers/origami/home_controller_bk.rb @@ -19,9 +19,9 @@ class Origami::HomeController < BaseOrigamiController @orders = Order.get_orders() end - def item_show - selection(params[:booking_id],1) - end + # def item_show + # selection(params[:booking_id],1) + # end def selection(selected_id, is_ajax) str = [] @@ -37,8 +37,8 @@ class Origami::HomeController < BaseOrigamiController @order_details = OrderItem.get_order_items_details(params[:booking_id]) @order_details.each do |ord_detail| str.push(ord_detail) - end - end + end + end if is_ajax == 1 render :json => str.to_json diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index f5a0023e..1d26438e 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -4,6 +4,34 @@ class Origami::PaymentsController < BaseOrigamiController def index end + def first_bill + sale_id = params[:sale_id] # sale_id + sale_data = Sale.find_by_sale_id(sale_id) + sale_items = SaleItem.where("sale_id=?",sale_id) + + # Print for First Bill to Customer + unique_code = "ReceiptBillPdf" + #shop detail + shop_details = Shop.find(1) + # customer= Customer.where('customer_id=' +.customer_id) + customer= Customer.find(sale_data.customer_id) + # get member information + member_info = Customer.get_member_account(customer) + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # find order id by sale id + # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + + printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details) + end + def create cash = params[:cash] sale_id = params[:sale_id] @@ -26,9 +54,10 @@ class Origami::PaymentsController < BaseOrigamiController print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) end end @@ -104,10 +133,9 @@ class Origami::PaymentsController < BaseOrigamiController # Calculate price_by_accounts item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) end - - end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index bd548253..cfea9d37 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -10,8 +10,8 @@ class Origami::RequestBillsController < BaseOrigamiController check_booking = Booking.find_by_booking_id(bk_order.booking_id) if check_booking.sale_id.nil? # Create Sale if it doesn't exist - puts "current_login_employee" - puts current_login_employee.name + # puts "current_login_employee" + # puts current_login_employee.name @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) @@ -20,26 +20,26 @@ class Origami::RequestBillsController < BaseOrigamiController @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id) end - unique_code = "ReceiptBillPdf" - #shop detail - shop_details = Shop.find(1) - # customer= Customer.where('customer_id=' +.customer_id) - customer= Customer.find(@sale_data.customer_id) - # get member information - member_info = Customer.get_member_account(customer) - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) +# Not Use for these printed bill cannot give customer + # unique_code = "ReceiptBillPdf" + # #shop detail + # shop_details = Shop.find(1) + # # customer= Customer.where('customer_id=' +.customer_id) + # customer= Customer.find(@sale_data.customer_id) + # # get member information + # member_info = Customer.get_member_account(customer) + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) - # find order id by sale id - # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + # # find order id by sale id + # # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) - # Calculate price_by_accounts - item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + # # Calculate price_by_accounts + # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) + # printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) - # redirect_to origami_path(@sale_data.sale_id) + # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index fc8c3167..d4fba302 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -18,6 +18,7 @@ class Origami::SaleEditController < BaseOrigamiController @newsaleitem.save @newsaleitem.qty = saleitemObj.qty * -1 @newsaleitem.price = saleitemObj.price * -1 + @newsaleitem.is_taxable = 0 @newsaleitem.product_name = saleitemObj.product_name + " - void" @newsaleitem.save end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 4cd17cce..1a7a5289 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -1,11 +1,28 @@ -class Origami::ShiftsController < ApplicationController +class Origami::ShiftsController < BaseOrigamiController + def index end def show + @shift = ShiftSale.current_open_shift(current_user.id) end def new + @float = Lookup.where('lookup_type=?','float_value') + end + + def create + opening_balance = params[:opening_balance] + @shift = ShiftSale.new + @shift.create(opening_balance,current_user) + end + + def update_shift + @shift = ShiftSale.current_open_shift(current_user.id) + if @shift + @shift.shift_closed_at = DateTime.now.utc + @shift.save + end end def edit diff --git a/app/models/employee.rb b/app/models/employee.rb index 69eb3fae..2d70768d 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -1,11 +1,16 @@ class Employee < ApplicationRecord has_secure_password + has_many :shit_sales validates_presence_of :name, :role validates_presence_of :password, :on => [:create] validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true validates :password, numericality: true, length: {in: 3..9}, allow_blank: true + def self.all_emp_except_waiter + Employee.where('role!=?','waiter') + end + def self.collection Employee.select("id, name").map { |e| [e.name, e.id] } end diff --git a/app/models/order.rb b/app/models/order.rb index b3a70f37..29267965 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -25,9 +25,8 @@ class Order < ApplicationRecord booking = nil if self.new_booking - booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", - :checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name, + :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) table = DiningFacility.find(self.table_id) table.status = "occupied" @@ -55,7 +54,7 @@ class Order < ApplicationRecord end - return false + return false, @message = "booking fail" end @@ -301,7 +300,7 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("(orders.status = 'new' or orders.status = 'billed')") + .where("(orders.status = 'new' or orders.status = 'billed') AND orders.date between #{ from } and #{ to }") # orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status, # orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id diff --git a/app/models/payment_journal.rb b/app/models/payment_journal.rb index 237f9cd4..6105a574 100644 --- a/app/models/payment_journal.rb +++ b/app/models/payment_journal.rb @@ -1,2 +1,22 @@ class PaymentJournal < ApplicationRecord + + def cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user) + self.payment_references = reference + self.remark = remark + self.credit_amount = amount + self.payment_method = payment_method + self.payment_status = 'paid' + self.payment_method_references = payment_method_reference + self.created_by = current_user + self.save + end + + def cash_out(payment_reference, remark, amount, current_user) + self.payment_references = payment_reference + self.remark = remark + self.debit_amount = amount + self.payment_status = 'paid' + self.created_by = current_user + self.save + end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 6aed3ebe..f8eb46d6 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) # print as print copies in printer setting count = printer_settings.print_copies diff --git a/app/models/sale.rb b/app/models/sale.rb index 677dabe4..bf3bc216 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -270,7 +270,6 @@ class Sale < ApplicationRecord end - private def product_get_unit_price(item_code) diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 8881efea..3cc0eb43 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -30,15 +30,17 @@ class SaleItem < ApplicationRecord # end end + # Get Prices for each accounts (eg: food, beverage) def self.calculate_price_by_accounts(sale_items) price_accounts = [] Account.all.each do |a| account_price = {:name => a.title, :price => 0} + # Check for actual sale items sale_items.each do |si| if si.account_id == a.id - account_price[:price] = account_price[:price] + si.price - end + account_price[:price] = account_price[:price] + si.price + end end price_accounts.push(account_price) end @@ -46,6 +48,24 @@ class SaleItem < ApplicationRecord return price_accounts end + # Get discount Prices for each accounts (eg: food, beverage) + def self.get_discount_price_by_accounts(sale_items) + discount_accounts = [] + Account.all.each do |a| + discount_account = {:name => a.title, :price => 0} + + # Check for actual sale items + sale_items.where("is_taxable = false AND remark = 'Discount'").find_each do |si| + if si.account_id == a.id + discount_account[:price] = (discount_account[:price] + si.price) * -1 + end + end + discount_accounts.push(discount_account) + end + + return discount_accounts + end + # Calculate rebate_by_account def self.calculate_rebate_by_account(sale_items) rebateacc = Account.where("rebate=?",true) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 8b28c946..7a835618 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -249,6 +249,12 @@ class SalePayment < ApplicationRecord self.sale.save! table_update_status(sObj) rebat(sObj) + shift = ShiftSale.current_open_shift(self.sale.cashier_id) + puts shift + if !shift.nil? + puts ">>>> shift >>>>>>" + shift.update(self.sale) + end end end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 97d7ab0e..2d6b795e 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -14,12 +14,39 @@ class ShiftSale < ApplicationRecord belongs_to :cashier_terminal - belongs_to :employee + belongs_to :employee, :foreign_key => 'employee_id' def self.current_open_shift(current_user) #if current_user #find open shift where is open today and is not closed and login by current cashier - @shift = ShiftSale.where("cast(shift_started_at as date) = #{DateTime.now.to_date} and shift_started_at is null and employee_id = #{current_user.id}").limit(1) + today_date = DateTime.now.strftime("%Y-%m-%d") + puts today_date + shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take + + return shift #end end + + def create(opening_balance,current_user) + self.cashier_terminal_id = CashierTerminal.first.id + self.shift_started_at = DateTime.now + self.employee_id = current_user.id + self.opening_balance = opening_balance + self.save + end + + def update(sale) + saleobj = Sale.find_by_sale_id(sale) + self.total_revenue = self.total_revenue + saleobj.total_amount + self.total_discounts = self.total_discounts + saleobj.total_discount + self.total_taxes = self.total_taxes + saleobj.total_tax + self.grand_total = self.grand_total + saleobj.grand_total + # self.nett_sales = + # self.cash_sales = + # self.credit_sales = + # self.other_sales = + # self.commercial_taxes = + self.save + + end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index a32c54f5..3817c509 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,7 +1,7 @@ class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details) self.page_width = 210 self.page_height = 7000 self.margin = 5 @@ -46,7 +46,12 @@ class ReceiptBillPdf < Prawn::Document customer(customer_name) + if discount_price_by_accounts.length > 0 + discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) + end + items_account(item_price_by_accounts,printer_settings.precision,delimiter) + footer end @@ -165,7 +170,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Discount", :size => self.item_font_size,:align => :left + text "Overall Discount", :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(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right @@ -308,6 +313,21 @@ class ReceiptBillPdf < Prawn::Document text "#{ customer_name }" , :size => self.item_font_size,:align => :right end end + def discount_account(discount_price_by_accounts,precision,delimiter) + move_down 5 + stroke_horizontal_rule + move_down 5 + y_position = cursor + discount_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :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(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right + end + end + end def items_account(item_price_by_accounts,precision,delimiter) move_down 5 diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb index 84b6f199..b9418d22 100644 --- a/app/views/home/show.html.erb +++ b/app/views/home/show.html.erb @@ -1,14 +1,24 @@ @@ -23,21 +33,29 @@ <%= f.input :password, label: "Access PIN", required: false, class: "form-control" %> -
| Payment Reference + | ++ |
| Remark + | ++ |
| Payment Method + | ++ + + + + | +
| Payment Reference + | ++ |
| Remark + | ++ |
| Amount + | ++ |