From 00f8af0808ade9459377f960e64f4f6c06e00b25 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Sun, 27 Jan 2019 17:27:40 +0100 Subject: [PATCH] suite --- app/models/p_document.rb | 5 ++-- app/models/p_sheet_line.rb | 24 ++++++++++++++++++- .../_print_p_sheet_lines.html.haml | 6 +++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/models/p_document.rb b/app/models/p_document.rb index f3d4e3f..9315115 100644 --- a/app/models/p_document.rb +++ b/app/models/p_document.rb @@ -193,12 +193,13 @@ class PDocument < ActiveRecord::Base self.name = self.p_document_type.name last_number = 0 - last_dt = PDocument.where("d_number is not null").where(:d_year => self.d_year,:p_document_type_id => self.p_document_type_id).order("d_index DESC").first + last_dt = PDocument.where("d_number is not null").where(:p_document_type_id => self.p_document_type_id).order("d_index DESC").first + #:d_year => self.d_year, last_number = last_dt.d_index if last_dt self.d_index = last_number+1 - self.d_number = self.d_prefix+self.d_year.to_s+('%05d' % self.d_index) + self.d_number = self.d_prefix+('%05d' % self.d_index) #self.d_year.to_s self.save diff --git a/app/models/p_sheet_line.rb b/app/models/p_sheet_line.rb index a55c0ac..1702040 100644 --- a/app/models/p_sheet_line.rb +++ b/app/models/p_sheet_line.rb @@ -288,7 +288,29 @@ class PSheetLine < ActiveRecord::Base end def tva - 0.2 + t = 0.2 + + t = 0.0 if self.to_export? + + return t + end + + def to_export? + t = false + + if self.p_customer_sheet and self.p_customer_sheet.particular_bill + if self.p_customer_sheet.particular_bill.country != "FR" + t = true + end + + + elsif self.p_document + if self.p_document.particular_bill.country != "FR" + t = true + end + end + + return t end def price_tot_ttc diff --git a/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml b/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml index e4fab0d..41f76dc 100644 --- a/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml +++ b/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml @@ -110,6 +110,12 @@ %td{:style => "text-align:right;padding-right:10px;", :colspan =>3} %strong =total[:label] + - if total[:label] == "TVA" + -if @p_document and @p_document.p_sheet_lines.first + -if @p_document.p_sheet_lines.first.to_export? + ="(0%)" + -else + ="(20%)" %td =number_to_currency total[:value]