From e6cef8ef937ab82830ad8283b75e83b0083b95ac Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 18 Jun 2017 11:57:14 +0630 Subject: [PATCH 1/6] Redeem amount not cut bug Fix --- app/models/sale_payment.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 731fa321..465a8e5b 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -187,17 +187,17 @@ 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 +251,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") @@ -266,7 +271,7 @@ class SalePayment < ApplicationRecord 'Content-Type' => 'application/json', 'Accept' => 'application/json' }) - + puts "haha" puts response.to_json end end From 3a1fba2c6f2f1a3fb96e5e130c5513b3aec622c0 Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 18 Jun 2017 13:18:23 +0630 Subject: [PATCH 2/6] Other Payments Bug fix --- app/views/origami/jcb/index.html.erb | 8 +++++++- app/views/origami/master/index.html.erb | 8 +++++++- app/views/origami/mpu/index.html.erb | 8 +++++++- app/views/origami/visa/index.html.erb | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index 6d08b25a..9c239931 100644 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -96,6 +96,12 @@ \ No newline at end of file diff --git a/app/views/reports/daily_sale/index.html.erb b/app/views/reports/daily_sale/index.html.erb new file mode 100644 index 00000000..4aa0c841 --- /dev/null +++ b/app/views/reports/daily_sale/index.html.erb @@ -0,0 +1,190 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sale_index_path} %> +
+
+ +
+
+ +
+
+ +
+
+
+ + + <% 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 %> + + + + + + + + + + + + + + + + + + <% total_tax = 0 %> + <% unless @tax.empty? %> + <% @tax.each do |tax| %> + <% total_tax += tax.tax_amount.to_f %> + + + + + + + <% end %> + <% net = total - total_tax %> + + + + + + <% end %> + + <% end %> +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateDaily Void AmountDaily mpu SalesDaily master SalesDaily visa SalesDaily jcb SalesDaily paypar SalesDaily Cash SalesDaily Credit SalesDaily FOC Sales(Daily 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 '-'%>
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 '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+
+
+
+ + + \ No newline at end of file diff --git a/app/views/reports/daily_sale/index.xls.erb b/app/views/reports/daily_sale/index.xls.erb new file mode 100644 index 00000000..dfcc18d4 --- /dev/null +++ b/app/views/reports/daily_sale/index.xls.erb @@ -0,0 +1,116 @@ +
+
+ + + <% 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 %> + + + + + + + + + + + + + + + + + + <% total_tax = 0 %> + <% unless @tax.empty? %> + <% @tax.each do |tax| %> + <% total_tax += tax.tax_amount.to_f %> + + + + + + + <% end %> + <% net = total - total_tax %> + + + + + + <% end %> + + <% end %> +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateDaily Void AmountDaily mpu SalesDaily master SalesDaily visa SalesDaily jcb SalesDaily paypar SalesDaily Cash SalesDaily Credit SalesDaily FOC Sales(Daily 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 '-'%>
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 '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+
+
\ No newline at end of file diff --git a/app/views/reports/daily_sale_report.html.erb b/app/views/reports/daily_sale_report.html.erb index e69de29b..786951f5 100644 --- a/app/views/reports/daily_sale_report.html.erb +++ b/app/views/reports/daily_sale_report.html.erb @@ -0,0 +1,20 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %> +
+
+ +
+
+ +
+
diff --git a/config/routes.rb b/config/routes.rb index b5f944b5..22a042bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -210,6 +210,7 @@ Rails.application.routes.draw do #--------- Reports Controller Sections ------------# namespace :reports do resources :receipt_no, :only => [:index, :show] + resources :daily_sale, :only => [:index, :show] # resources :sales, :only => [:index, :show] # resources :orders, :only => [:index, :show] # resources :customers, :only => [:index, :show] From b65d127fd0463c266cca2dc01852104229f3eb59 Mon Sep 17 00:00:00 2001 From: Yan Date: Sun, 18 Jun 2017 20:07:28 +0630 Subject: [PATCH 5/6] bill print format and tax fix --- app/assets/javascripts/origami.js | 39 ++++++++++++++------------- app/models/order.rb | 4 +-- app/models/sale.rb | 12 ++++++--- app/pdf/receipt_bill_pdf.rb | 37 ++++++++++++++----------- app/views/origami/home/index.html.erb | 6 ++--- 5 files changed, 56 insertions(+), 42 deletions(-) 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/models/order.rb b/app/models/order.rb index 14fd8cda..a4328d76 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/sale.rb b/app/models/sale.rb index 3714c21e..ccd2a96a 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 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/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index ff83dad4..ce2b3a94 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -306,12 +306,12 @@ sub_total = 0 if @selected_item_type == "Sale" @selected_item.sale_items.each do |sale_item| - sub_total += (sale_item.qty*sale_item.unit_price) + sub_total = sub_total + sale_item.price %> <%= sale_item.product_name %> <%= sale_item.qty %> - <%= sale_item.qty*sale_item.price %> + <%= sale_item.price %> <% end @@ -322,7 +322,7 @@ # For Order Items if @selected_item_type == "Order" @selected_item.order_items.each do |order_item| - sub_total += (order_item.qty*order_item.unit_price) + sub_total = sub_total + (order_item.qty*order_item.price) %> <%= order_item.item_name %> From dd3c429301389f684d9413e46e0ee7092a198683 Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 19 Jun 2017 11:56:26 +0630 Subject: [PATCH 6/6] control paypar url and oqs fix --- app/models/order_queue_station.rb | 4 ++- app/models/sale_payment.rb | 50 +++++++++++++++++-------------- 2 files changed, 31 insertions(+), 23 deletions(-) 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_payment.rb b/app/models/sale_payment.rb index 3b67648c..856cd054 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -66,19 +66,20 @@ class SalePayment < ApplicationRecord end - def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token) - 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' - }, :timeout => 10 - ) - rescue Net::OpenTimeout - response = { status: false } - end - return response; + 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' + }, :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + end + return response; end def self.redeem(paypar_url,token,membership_id,received_amount,sale_id) @@ -90,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 @@ -122,7 +129,6 @@ class SalePayment < ApplicationRecord end def creditnote_payment(customer_id) - payment_status = false self.payment_method = "creditnote" @@ -190,7 +196,6 @@ class SalePayment < ApplicationRecord payment_status = false #Next time - validate if the vochure number is valid - within - 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) @@ -269,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,