diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 78a21c3b..d4071432 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -55,7 +55,7 @@ $(document).ready(function(){ var cashier=""; var receipt_date=""; - var sub_total=0; + var sub_total=0.0; var discount_amount=0; var tax_amount=0; var grand_total_amount=0; @@ -69,11 +69,11 @@ $(document).ready(function(){ type: "POST", url: "/origami/" + unique_id, data: { 'booking_id' : unique_id }, - success:function(result){ + success:function(result){ for (i = 0; i < result.length; i++) { var data = JSON.stringify(result[i]); var parse_data = JSON.parse(data); - var show_date = ""; + var show_date = ""; // Receipt Header receipt_no = result[i].receipt_no; @@ -81,36 +81,37 @@ $(document).ready(function(){ if(result[i].receipt_date != null){ receipt_date = new Date(result[i].receipt_date); show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes() - } - - $("#receipt_no").text(receipt_no); - $("#cashier").text(cashier == null ? "" : cashier); - $("#receipt_date").text(show_date); - + } //Receipt Charges - sub_total += (parse_data.qty*parse_data.price); + sub_total += parseFloat(parse_data.price); discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount; tax_amount = parse_data.tax_amount; - grand_total_amount = parse_data.grand_total_amount; - - $("#order-sub-total").text(sub_total); - // $("#order-food").text(''); - // $("#order-beverage").text(''); - $("#order-discount").text(discount_amount); - $("#order-Tax").text(tax_amount); - $("#order-grand-total").text(grand_total_amount); + grand_total_amount = parse_data.grand_total_amount; // Ordered Items var order_items_rows = "" + "" + parse_data.item_name + "" + "" + parse_data.qty + "" + - "" + parse_data.qty*parse_data.price + "" + + "" + parse_data.price + "" + ""; $("#order-items-table").children("tbody").append(order_items_rows); } + + // Cashier Info + $("#receipt_no").text(receipt_no); + $("#cashier").text(cashier == null ? "" : cashier); + $("#receipt_date").text(show_date); + + // Payment Info + $("#order-sub-total").text(sub_total); + // $("#order-food").text(''); + // $("#order-beverage").text(''); + $("#order-discount").text(discount_amount); + $("#order-Tax").text(tax_amount); + $("#order-grand-total").text(grand_total_amount); } }); // End AJAX Call diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index c1ae1a01..0ea51cf5 100644 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -23,55 +23,117 @@ class BaseReportController < ActionController::Base period = params[:period] from = params[:from] to = params[:to] - day_ref = Time.now - if period_type.to_i == 1 - if params[:from] && params[:to] - if params[:from] != "" && params[:to] !="" - from = DateTime.strptime(params[:from], "%m/%d/%Y") - to = DateTime.strptime(params[:to], "%m/%d/%Y") - else + day_ref = Time.now.utc.getlocal + + if params[:report_type] == "daily_sale" + + if from != "" && to != "" + + f_date = DateTime.parse(params[:from]) + t_date = DateTime.parse(params[:to]) + f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) + t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) + from = f_time.beginning_of_day.utc.getlocal + to = t_time.end_of_day.utc.getlocal + + else + + case period.to_i + when PERIOD["today"] + from = day_ref.beginning_of_day.utc to = day_ref.end_of_day.utc - end - end - else - case period.to_i - when PERIOD["today"] - from = day_ref.beginning_of_day.utc - to = day_ref.end_of_day.utc + when PERIOD["yesterday"] + from = (day_ref - 1.day).beginning_of_day.utc + to = (day_ref - 1.day).end_of_day.utc - when PERIOD["yesterday"] - from = (day_ref - 1.day).beginning_of_day.utc - to = (day_ref - 1.day).end_of_day.utc + when PERIOD["this_week"] + from = Time.now.beginning_of_week.utc + to = Time.now.utc + when PERIOD["last_week"] + from = (day_ref - 7.day).beginning_of_week.utc + to = (day_ref - 7.day).end_of_week.utc + when PERIOD["last_7"] + from = (day_ref - 7.day).utc + to = Time.now.utc + when PERIOD["this_month"] + from = Time.now.beginning_of_month.utc + to = Time.now.utc + when PERIOD["last_month"] + from = (day_ref - 1.month).beginning_of_month.utc + to = (day_ref - 1.month).end_of_month.utc + when PERIOD["last_30"] + from = (day_ref - 30.day).utc + to = Time.now.utc + when PERIOD["this_year"] + from = Time.now.beginning_of_year.utc + to = Time.now.utc + when PERIOD["last_year"] + from = (day_ref - 1.year).beginning_of_year.utc + to = (day_ref - 1.year).end_of_year.utc + end + end + else # end daily sale report + if period_type.to_i == 1 + + if params[:from] && params[:to] - when PERIOD["this_week"] - from = Time.now.beginning_of_week.utc - to = Time.now.utc - when PERIOD["last_week"] - from = (day_ref - 7.day).beginning_of_week.utc - to = (day_ref - 7.day).end_of_week.utc - when PERIOD["last_7"] - from = (day_ref - 7.day).utc - to = Time.now.utc - when PERIOD["this_month"] - from = Time.now.beginning_of_month.utc - to = Time.now.utc - when PERIOD["last_month"] - from = (day_ref - 1.month).beginning_of_month.utc - to = (day_ref - 1.month).end_of_month.utc - when PERIOD["last_30"] - from = (day_ref - 30.day).utc - to = Time.now.utc - when PERIOD["this_year"] - from = Time.now.beginning_of_year.utc - to = Time.now.utc - when PERIOD["last_year"] - from = (day_ref - 1.year).beginning_of_year.utc - to = (day_ref - 1.year).end_of_year.utc - end + if params[:from] != "" && params[:to] !="" + + f_date = DateTime.parse(params[:from]) + t_date = DateTime.parse(params[:to]) + f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) + t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) + from = f_time.beginning_of_day.utc.getlocal + to = t_time.end_of_day.utc.getlocal + else + from = day_ref.beginning_of_day.utc + to = day_ref.end_of_day.utc + end + end + else + case period.to_i + when PERIOD["today"] + + from = day_ref.beginning_of_day.utc + to = day_ref.end_of_day.utc + + when PERIOD["yesterday"] + from = (day_ref - 1.day).beginning_of_day.utc + to = (day_ref - 1.day).end_of_day.utc + + when PERIOD["this_week"] + from = Time.now.beginning_of_week.utc + to = Time.now.utc + when PERIOD["last_week"] + from = (day_ref - 7.day).beginning_of_week.utc + to = (day_ref - 7.day).end_of_week.utc + when PERIOD["last_7"] + from = (day_ref - 7.day).utc + to = Time.now.utc + when PERIOD["this_month"] + from = Time.now.beginning_of_month.utc + to = Time.now.utc + when PERIOD["last_month"] + from = (day_ref - 1.month).beginning_of_month.utc + to = (day_ref - 1.month).end_of_month.utc + when PERIOD["last_30"] + from = (day_ref - 30.day).utc + to = Time.now.utc + when PERIOD["this_year"] + from = Time.now.beginning_of_year.utc + to = Time.now.utc + when PERIOD["last_year"] + from = (day_ref - 1.year).beginning_of_year.utc + to = (day_ref - 1.year).end_of_year.utc + end + end end + return from, to + + end end diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_sale_controller.rb index b487c269..86e60702 100644 --- a/app/controllers/reports/daily_sale_controller.rb +++ b/app/controllers/reports/daily_sale_controller.rb @@ -1,9 +1,25 @@ class Reports::DailySaleController < BaseReportController def index - from, to = get_date_range_from_params - @sale_data = Sale.get_receipt_no_list(from,to) - @sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50) + from, to = get_date_range_from_params + @sale_data = Sale.daily_sales_list(from,to) + @tax = SaleTax.get_tax(from,to) + end + + # @locations = Location.all + + # branch,from, to, report_type = get_date_range_from_params + + # @location = Location.find_by_id(current_location) + # @sale_data = Sale.daily_sales_report(current_location,from,to) + # @tax = SaleT.get_tax(current_location,from,to) + + # if @sale_data.blank? && @tax.blank? && request.post? + # flash.now[:notice] = "No data available for selected filters" + # end + + def show + end end \ No newline at end of file diff --git a/app/models/order.rb b/app/models/order.rb index 96382c07..2ea76a98 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -231,7 +231,7 @@ class Order < ApplicationRecord .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') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") + .group("bookings.booking_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id @@ -262,7 +262,7 @@ class Order < ApplicationRecord .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') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") + .group("bookings.booking_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 0350049c..2df76af8 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -29,7 +29,9 @@ class OrderQueueStation < ApplicationRecord if oqs.id == oqpbz.order_queue_station_id #Same Order_items can appear in two location. AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - end + else + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + end end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 3714c21e..2ffb53ef 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -23,8 +23,7 @@ class Sale < ApplicationRecord if (booking) Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s #get all order attached to this booking and combine into 1 invoice - - puts booking.booking_orders.length + booking.booking_orders.each do |order| if booking.sale_id status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) @@ -90,6 +89,8 @@ class Sale < ApplicationRecord order.save booking.sale_id = self.id + booking.checkout_at = Time.now.utc + booking.checkout_by = requested_by.name booking.save return true, self.id @@ -190,9 +191,14 @@ class Sale < ApplicationRecord # Tax Calculate def apply_tax(total_taxable) + #if tax is not apply create new record + # self.sale_taxes.each do |existing_tax| + # #delete existing and create new + # existing_tax.delete + # end #if tax is not apply create new record - self.sale_taxes.each do |existing_tax| + SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax| #delete existing and create new existing_tax.delete end @@ -275,6 +281,59 @@ class Sale < ApplicationRecord end end + def self.daily_sales_list(from,to) + payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, + SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, + SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount, + SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount, + SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, + SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount, + SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, + SUM(case when (sale_payments.payment_method='credit') then sale_payments.payment_amount else 0 end) as credit_amount, + SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount") + .joins("join (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sale_payments on sale_payments.sale_id = sales.sale_id") + .where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0", 'completed', from, to) + .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')") + + daily_total = Array.new + + payments_total.each do |pay| + sale_date = pay.sale_date + diff_time = payments_total.first.sale_date.beginning_of_day.utc - from + diff = diff_time % 86400 + from_date = sale_date.beginning_of_day.utc - diff + to_date = sale_date.end_of_day.utc - diff + + total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total, + IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount, + IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount, + IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj") + .where("(sale_status = ? OR sale_status = ?) AND receipt_date between ? and ? AND total_amount != 0", 'completed', 'void', from_date, to_date) + + total_sale.each do |sale| + grand_total = sale.grand_total + total_discount = sale.total_discount + void_amount = sale.void_amount + total = {:sale_date => pay.sale_date, + :mpu_amount => pay.mpu_amount, + :master_amount => pay.master_amount, + :visa_amount => pay.visa_amount, + :jcb_amount => pay.jcb_amount, + :paypar_amount => pay.paypar_amount, + :cash_amount => pay.cash_amount, + :credit_amount => pay.credit_amount, + :foc_amount => pay.foc_amount, + :total_discount => total_discount, + :grand_total => grand_total, + :void_amount => void_amount, + :rounding_adj => sale.rounding_adj} + daily_total.push(total) + end + + end + return daily_total + end + private def generate_custom_id diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 71373f2d..a999b6a8 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -36,11 +36,13 @@ class SaleItem < ApplicationRecord beverage_prices=0 sale_items.each do |si| - food_price, beverage_price = self.get_price(si.sale_item_id) + food_price, beverage_price = self.get_price(si.sale_item_id) food_prices = food_prices + food_price beverage_prices = beverage_prices + beverage_price end + puts food_prices + puts beverage_prices return food_prices, beverage_prices end @@ -54,11 +56,22 @@ class SaleItem < ApplicationRecord .where("sale_items.sale_item_id=?", sale_item_id.to_s) if item[0].account_id == 1 food_price = item[0].price - else + else beverage_price = item[0].price end - return food_price, beverage_price + return food_price, beverage_price + end + + def self.get_overall_discount(sale_id) + price = 0.0 + item=SaleItem.where("product_code=?", sale_id) + + item.each do|i| + price += i.price + end + + return price end private diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 2b0035f3..856cd054 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -66,16 +66,20 @@ class SalePayment < ApplicationRecord end - def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token) + def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token) + # Control for Paypar Cloud + begin response = HTTParty.get(url, - :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - } - ) - return response; - + :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }, :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + end + return response; end def self.redeem(paypar_url,token,membership_id,received_amount,sale_id) @@ -87,13 +91,19 @@ class SalePayment < ApplicationRecord campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"] sale_data = Sale.find_by_sale_id(sale_id) if sale_data - response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - } - ) + # Control for Paypar Cloud + begin + response = HTTParty.post(url, + :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }, + :timeout => 10 + ) + rescue Net::OpenTimeout + response = false + end else response = false; end @@ -119,7 +129,6 @@ class SalePayment < ApplicationRecord end def creditnote_payment(customer_id) - payment_status = false self.payment_method = "creditnote" @@ -187,17 +196,16 @@ class SalePayment < ApplicationRecord payment_status = false #Next time - validate if the vochure number is valid - within - self.payment_method = "paypar" - self.payment_amount = self.received_amount - self.payment_reference = self.voucher_no - self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f - self.payment_status = "pending" - payment_method = self.save! - customer_data = Customer.find_by_customer_id(self.sale.customer_id) membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) if membership_data["status"]==true + self.payment_method = "paypar" + self.payment_amount = self.received_amount + self.payment_reference = self.voucher_no + self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f + self.payment_status = "pending" + payment_method = self.save! SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid') sale_update_payment_status(self.received_amount.to_f) @@ -251,7 +259,12 @@ class SalePayment < ApplicationRecord payparcost = payparcost + pp.payment_amount end end - total_amount = food_prices - payparcost + overall_dis = SaleItem.get_overall_discount(sObj.id) + total_amount = food_prices - payparcost + overall_dis + puts "total_amount" + puts food_prices + puts payparcost + puts total_amount if total_amount > 0 receipt_no = sObj.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") @@ -261,6 +274,7 @@ class SalePayment < ApplicationRecord auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + # Control for Paypar Cloud begin response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, @@ -272,7 +286,7 @@ class SalePayment < ApplicationRecord response = { status: false } end - puts response.to_json + # puts response.to_json end end end diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index 79de9134..7a42905a 100644 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -5,6 +5,10 @@ class SaleTax < ApplicationRecord before_create :generate_custom_id belongs_to :sale + def self.get_tax(from,to) + query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount").joins("join sales on sales.sale_id = sale_taxes.sale_id").where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0", 'completed', from, to).group("sale_taxes.tax_name") + end + private def generate_custom_id self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI") diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 6cacc391..c1ba4936 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -4,9 +4,9 @@ class ReceiptBillPdf < Prawn::Document self.page_width = 210 self.page_height = 2500 self.margin = 5 - self.price_width = 35 + self.price_width = 40 self.qty_width = 20 - self.total_width = 35 + self.total_width = 40 self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) self.item_height = 15 self.item_description_width = (self.page_width-20) / 2 @@ -53,29 +53,36 @@ class ReceiptBillPdf < Prawn::Document # move_down 2 y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "Receipt No:", :size => self.item_font_size,:align => :left + text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left end - - bounding_box([self.label_width, y_position], :width =>self.item_width) do - text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left + bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do + text "#{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right end move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "Customer:", :size => self.item_font_size,:align => :left + bounding_box([0, y_position], :width =>self.item_width) do + text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left end - bounding_box([self.label_width,y_position], :width =>self.item_width) do - text "#{customer_name}" , :size => self.item_font_size,:align => :left + move_down 5 + + y_position = cursor + bounding_box([0,y_position], :width =>self.item_width, :height => self.item_height) do + text "Cashier: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :left end move_down 5 + # bounding_box([self.label_width,y_position], :width =>self.item_width) do + # text "#{customer_name}" , :size => self.item_font_size,:align => :left + # end + # move_down 5 + y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "Date:", :size => self.item_font_size,:align => :left + text "Time In: #{ sale_data.bookings[0].checkin_at.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left end - bounding_box([self.label_width,y_position], :width => self.item_width) do - text "#{sale_data.receipt_date.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left + bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do + text "Time Out: #{ sale_data.bookings[0].checkout_at.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right end move_down 5 @@ -118,7 +125,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor pad_top(15) { - text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix @@ -163,7 +170,7 @@ class ReceiptBillPdf < Prawn::Document text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right end - if sale_data.sale_taxes.length > 1 + if sale_data.sale_taxes.length > 0 sale_data.sale_taxes.each do |st| move_down 5 y_position = cursor diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index a385806c..5cd426dc 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -36,7 +36,7 @@