From 03864e04d3aac06cbe42f36a55793077ec5b8aa7 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Sun, 27 Jan 2019 17:45:20 +0100 Subject: [PATCH] suite --- app/models/p_sheet_line.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/p_sheet_line.rb b/app/models/p_sheet_line.rb index 1702040..3122917 100644 --- a/app/models/p_sheet_line.rb +++ b/app/models/p_sheet_line.rb @@ -359,14 +359,16 @@ class PSheetLine < ActiveRecord::Base end + + def self.total_with_labels(sheet_lines, sheet_line_container=nil) total = 0.0 total_ttc = 0.0 r = {} - + tva = 0.0 sheet_lines.each do |sheet_line| - + tva = sheet_line.tva total += sheet_line.price_tot total_ttc += sheet_line.price_tot_ttc @@ -380,7 +382,7 @@ class PSheetLine < ActiveRecord::Base total = total +fdp.to_f - total_ttc = total_ttc + (fdp.to_f*1.2) + total_ttc = total_ttc + (fdp.to_f*(1+tva)) r[:total] = {:label =>"Total HT",:value => total} r[:tva] = {:label =>"TVA",:value => total_ttc - total} r[:total_ttc] = {:label =>"Total TTC",:value => total_ttc} @@ -393,6 +395,7 @@ class PSheetLine < ActiveRecord::Base + def self.frais_de_port(p_sheet_lines) if p_sheet_lines[0] and ((p_sheet_lines[0].p_customer_sheet and p_sheet_lines[0].p_customer_sheet.fdp_force_price) or (p_sheet_lines[0].p_document and p_sheet_lines[0].p_document.fdp_force_price))