From b3eead7aa23fd7bc312310dddc84cc51ce0f5e39 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Fri, 3 Jan 2020 15:16:12 +0630 Subject: [PATCH 1/5] bundle --- Gemfile.lock | 3 --- 1 file changed, 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bbcc1085..50647fba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -380,8 +380,5 @@ DEPENDENCIES web-console (>= 3.3.0) whenever -RUBY VERSION - ruby 2.4.1p111 - BUNDLED WITH 2.0.2 From 8b5478cf27428d81ef55c57b791d3eb2d666253b Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Fri, 3 Jan 2020 16:43:05 +0630 Subject: [PATCH 2/5] update receipt no detail report --- .../reports/receipt_no_detail/index.html.erb | 25 +++--- .../reports/receipt_no_detail/index.xls.erb | 82 +++++++++---------- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/app/views/reports/receipt_no_detail/index.html.erb b/app/views/reports/receipt_no_detail/index.html.erb index 9f5841a2..c766108b 100755 --- a/app/views/reports/receipt_no_detail/index.html.erb +++ b/app/views/reports/receipt_no_detail/index.html.erb @@ -136,23 +136,24 @@ <% sale_payments = result.sale_payments %> <% if sale_payments.length > 0%> <% sale_payments.each do |rec| %> - <% next if rec.payment_method == 'credit_note' && result.payments_for_credits_amount < rec.payment_amount %> - -   -   - Payment <%= rec.payment_method.upcase %> - <%= number_format(rec.payment_amount, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %> ( <%= rec.payment_status %> ) -   - - - <% if !rec.payment_reference.nil? %> + <% if rec.payment_amount > 0 %>     - Payment Ref. - <%= rec.payment_reference %> + Payment <%= rec.payment_method.upcase %> + <%= number_format(rec.payment_amount, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %> ( <%= rec.payment_status %> )   + + <% if !rec.payment_reference.nil? %> + +   +   + Payment Ref. + <%= rec.payment_reference %> +   + + <% end %> <% end %> <% end %> <% if result.amount_changed != 0 %> diff --git a/app/views/reports/receipt_no_detail/index.xls.erb b/app/views/reports/receipt_no_detail/index.xls.erb index 603d59e2..bd10e73b 100755 --- a/app/views/reports/receipt_no_detail/index.xls.erb +++ b/app/views/reports/receipt_no_detail/index.xls.erb @@ -9,7 +9,7 @@
-
+
@@ -18,9 +18,9 @@ <% if @shift_from %> - <% if @shift_data.employee %> + <% if @shift_data.employee %> <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> - <% end %> + <% end %> <% end %> @@ -28,9 +28,9 @@ - + - + @@ -47,7 +47,7 @@ - + @@ -66,8 +66,8 @@ <% if item.price.to_i < 0.to_i %> <% if item.qty.to_i < 0.to_i%> [PROMO QTY]<%= item.product_name rescue '-' %> - <% else %> - [PROMO PRICE]<%= item.product_name rescue '-' %> + <% else %> + [PROMO PRICE]<%= item.product_name rescue '-' %> <% end %> <% else %> <%= item.product_name rescue '-' %> @@ -76,71 +76,71 @@ - + <% end %> - + <%survey = Survey.find_by_receipt_no(result.receipt_no)%> <% if !survey.nil?%> - + - - - <% end %> - + + + <% end %> + <% if !result.total_amount.nil?%> - + - - + + <% end %> <% if result.total_discount.to_f > 0 %> - + - - + + <% end %> - + <% if !result.total_tax.nil? %> - + - + <% end %> - - <% sale_payments = SalePayment.get_sale_payments(result) %> - <% if sale_payments.length > 0%> + + <% sale_payments = result.sale_payments %> + <% if sale_payments.length > 0%> <% sale_payments.each do |rec| %> <%if rec.payment_amount.to_f > 0 %> - + - + - <% if !rec.payment_reference.nil? %> + <% if !rec.payment_reference.nil? %> - + @@ -148,10 +148,10 @@ <% end %> <% end %> <% end %> - <% if result.amount_changed != 0 && !result.amount_changed.nil? %> + <% if result.amount_changed != 0 && !result.amount_changed.nil? %> - + @@ -160,32 +160,32 @@ <% if !result.customer_id.nil?%> - + - <% end %> <% end %> - + <% end %> - + - +
<%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
<%= t("views.right_panel.detail.shift_name") %> <%= t("views.right_panel.detail.table") %> <%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %> <%= t("views.right_panel.detail.name") %><%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.revenue") %>  
<%= @shift_from %> - <%= @shift_to %> <%= table_type %> - <%= table_name %> <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= result.cashier_name rescue '-' %> <%=result.grand_total%>
<%= item.qty rescue '-' %> <%= item.unit_price rescue '-' %> <%= item.price rescue '-' %><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> <%=l item.created_at.utc.getlocal, :format => :short rescue '-' %>
 
    No. of Guest <%= survey.total_customer rescue '-' %> 
 
    <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> <%= result.total_amount %> 
 
    <%= t("views.right_panel.detail.total") %> - <%= t("views.right_panel.detail.discount") %> + <%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> - <%= result.total_discount %>  
 
    Tax Amount <%= result.total_tax %>   
    Payment <%= rec.payment_method.upcase %> <%= rec.payment_amount %> ( <%= rec.payment_status %> )  
    Payment Ref. <%= rec.payment_reference %>  
    <%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %> <%= result.amount_changed %>  
    Customer<%= result.customer.name rescue '-'%> + <%= result.customer.name rescue '-'%> (<%= result.customer.company rescue '-' %>)  
      Total Nett - <%= grand_total %>  
- +
- \ No newline at end of file + From eb65271d352798774f3e8739108e73bfc80f2a7c Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 7 Jan 2020 10:46:45 +0630 Subject: [PATCH 3/5] fix payment amount mismatch --- app/models/sale.rb | 6 +++--- app/models/sale_payment.rb | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 7213c55f..4da248df 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1404,7 +1404,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type if payment_type.present? sale_payment = sale_payment.where(payment_method: payment_type) end - + return payments_total, sale_payment end @@ -1438,10 +1438,10 @@ end cash = 0.0 self.sale_payments.each do |pay| if pay.payment_method == 'cash' - cash = pay.payment_amount-self.amount_changed + cash += pay.payment_amount end end - return cash + return cash - self.amount_changed end def get_credit_amount diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 389d1f25..b5c65b21 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -70,7 +70,7 @@ class SalePayment < ApplicationRecord self.sale = invoice self.received_amount = cash_amount self.payment_reference = remark - + self.action_by = action_by #get all payment for this invoices if payment_for @@ -637,15 +637,14 @@ class SalePayment < ApplicationRecord def sale_update_payment_status(paid_amount, check_foc = false) #update amount_outstanding sale = self.sale + total_payment_amount = sale.sale_payments.reload.sum(&:payment_amount) sale.amount_received = sale.amount_received.to_f + paid_amount.to_f - sale.amount_changed = sale.amount_received.to_f - sale.grand_total.to_f - - all_received_amount = sale.sale_payments.reload.sum(&:payment_amount) + sale.amount_changed = total_payment_amount - sale.grand_total.to_f is_credit = sale.sale_payments.any? { |x| x.payment_method == "creditnote" } is_foc = sale.sale_payments.any? { |x| x.payment_method == "foc" } - if sale.grand_total <= all_received_amount && sale.sale_status == "new" + if sale.grand_total <= total_payment_amount && sale.sale_status == "new" sale.payment_status = "paid" if is_credit sale.payment_status = "outstanding" From cf7d8c85d6f4ca94adc2463eb726628e6364ecaa Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 7 Jan 2020 13:06:29 +0630 Subject: [PATCH 4/5] fix seed generator length --- app/models/seed_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 6717eabd..482a65a1 100755 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -17,7 +17,7 @@ class SeedGenerator < ApplicationRecord end seed = self.update_seed(model_name) - length = 15 - prefix.length + length = 16 - prefix.length prefix + seed.to_s.rjust(length, '0') end @@ -39,7 +39,7 @@ class SeedGenerator < ApplicationRecord start = self.update_seed(model_name, count) stop = start + count - 1 - length = 15 - prefix.length + length = 16 - prefix.length (start..stop).map { |c| prefix + c.to_s.rjust(length, '0') } end From b742dfa2a012e830b31595412d76955aef8fd6ac Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Wed, 15 Jan 2020 13:12:00 +0630 Subject: [PATCH 5/5] fixed accept credit with multi payment --- app/controllers/origami/payments_controller.rb | 2 +- app/models/sale_payment.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 2138aeed..82e76119 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -242,7 +242,7 @@ class Origami::PaymentsController < BaseOrigamiController end if path.include? ("credit_payment") - @sale_payment = SalePayment.get_credit_amount_due_left(sale_id) + @sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount") end @member_discount = MembershipSetting.find_by_discount(1) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index b5c65b21..d489fdf5 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -956,7 +956,6 @@ class SalePayment < ApplicationRecord def self.get_sale_payment_for_credit(sale_data) sale_data.sale_payments .joins(:sale_audit) - .where(created_at: 1.days.ago.beginning_of_day..DateTime::Infinity.new) end def get_credit_payment_left