This commit is contained in:
Nicolas Bally 2019-01-27 17:27:40 +01:00
parent 10af706d0b
commit 00f8af0808
3 changed files with 32 additions and 3 deletions

View File

@ -193,12 +193,13 @@ class PDocument < ActiveRecord::Base
self.name = self.p_document_type.name self.name = self.p_document_type.name
last_number = 0 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 last_number = last_dt.d_index if last_dt
self.d_index = last_number+1 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 self.save

View File

@ -288,7 +288,29 @@ class PSheetLine < ActiveRecord::Base
end end
def tva 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 end
def price_tot_ttc def price_tot_ttc

View File

@ -110,6 +110,12 @@
%td{:style => "text-align:right;padding-right:10px;", :colspan =>3} %td{:style => "text-align:right;padding-right:10px;", :colspan =>3}
%strong %strong
=total[:label] =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 %td
=number_to_currency total[:value] =number_to_currency total[:value]