adding 1 invoice per TVA type
This commit is contained in:
parent
7508ae2e65
commit
e470f405a0
@ -236,6 +236,10 @@ class Admin::PCustomerSheetsController < ApplicationController
|
||||
|
||||
def generate_bc
|
||||
@p_customer_sheet = PCustomerSheet.find(params[:id])
|
||||
@p_customer_sheet.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1)
|
||||
@p_customer_sheet.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 2)
|
||||
|
||||
|
||||
@p_customer_sheet.generate_bc
|
||||
|
||||
redirect_back(fallback_location: admin_p_customer_sheets_path)
|
||||
|
@ -1,6 +1,7 @@
|
||||
class PArticle < ApplicationRecord
|
||||
belongs_to :p_grade
|
||||
belongs_to :p_product_ref
|
||||
belongs_to :tva_type
|
||||
has_one :p_product, through: :p_product_ref
|
||||
has_one :p_product_color, through: :p_product_ref
|
||||
has_one :s_brand, through: :p_product_ref
|
||||
|
@ -264,28 +264,73 @@ class PCustomerSheet < ApplicationRecord
|
||||
self.save
|
||||
end
|
||||
|
||||
|
||||
def generate_doc(label, state)
|
||||
self.archive_now if !self.archived
|
||||
self.block_price if !self.price_blocked
|
||||
self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1)
|
||||
|
||||
price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today)
|
||||
price_document.p_customer = self.p_customer
|
||||
price_document.price_line_block = self.price_line_block.dup
|
||||
price_document.tva_type = self.price_line_block.price_document.tva_type
|
||||
price_document.price_line_block.ac_block_type = nil
|
||||
if !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1).empty?
|
||||
price_document_standard_tva = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today, :tva_type_id => 1)
|
||||
price_document_standard_tva.p_customer = self.p_customer
|
||||
price_document_standard_tva.price_line_block = self.price_line_block.dup
|
||||
price_document_standard_tva.price_line_block.ac_block_type = nil
|
||||
|
||||
self.price_line_block.price_lines.each do |pl|
|
||||
if !pl.p_articles.where(tva_type_id: 1).empty?
|
||||
new_pl = pl.dup
|
||||
new_pl.ac_block_type = nil
|
||||
pl.p_articles.where(tva_type_id: 1).each { |p_article| new_pl.p_articles << p_article }
|
||||
price_document_standard_tva.price_line_block.price_lines << new_pl
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.price_line_block.price_lines.each do |pl|
|
||||
new_pl = pl.dup
|
||||
new_pl.ac_block_type = nil
|
||||
pl.p_articles.each { |p_article| new_pl.p_articles << p_article }
|
||||
price_document.price_line_block.price_lines << new_pl
|
||||
end
|
||||
|
||||
if price_document.save
|
||||
price_document.archive_now
|
||||
if price_document_standard_tva.save
|
||||
price_document_standard_tva.archive_now
|
||||
self.state = state
|
||||
self.save
|
||||
end
|
||||
|
||||
if !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 2).empty?
|
||||
price_document_sur_marge_tva = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today, :tva_type_id => 2)
|
||||
price_document_sur_marge_tva.p_customer = self.p_customer
|
||||
price_document_sur_marge_tva.price_line_block = self.price_line_block.dup
|
||||
price_document_sur_marge_tva.price_line_block.ac_block_type = nil
|
||||
|
||||
self.price_line_block.price_lines.each do |pl|
|
||||
if !pl.p_articles.where(tva_type_id: 2).empty?
|
||||
new_pl = pl.dup
|
||||
new_pl.ac_block_type = nil
|
||||
pl.p_articles.where(tva_type_id: 2).each { |p_article| new_pl.p_articles << p_article }
|
||||
price_document_sur_marge_tva.price_line_block.price_lines << new_pl
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if price_document_sur_marge_tva.save
|
||||
price_document_sur_marge_tva.archive_now
|
||||
self.state = state
|
||||
self.save
|
||||
end
|
||||
|
||||
# price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today)
|
||||
# price_document.p_customer = self.p_customer
|
||||
# price_document.price_line_block = self.price_line_block.dup
|
||||
# price_document.price_line_block.ac_block_type = nil
|
||||
|
||||
# self.price_line_block.price_lines.each do |pl|
|
||||
# new_pl = pl.dup
|
||||
# new_pl.ac_block_type = nil
|
||||
# pl.p_articles.each { |p_article| new_pl.p_articles << p_article }
|
||||
# price_document.price_line_block.price_lines << new_pl
|
||||
# end
|
||||
|
||||
# if price_document.save
|
||||
# price_document.archive_now
|
||||
# self.state = state
|
||||
# self.save
|
||||
# end
|
||||
end
|
||||
|
||||
def generate_d
|
||||
|
@ -343,7 +343,7 @@ class PriceDocument < ApplicationRecord
|
||||
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
QI_DYNAMICS = %w(solded_nbr_days solded_at cost_ht marge_ht weight_tot accounting_zone_id accounting_zone_name tot_amount_ht tot_amount_ttc tot_amount_tva label header footer payment_days payment_delais payment_month_end payment_end_at to_paid_ht to_paid_ttc to_paid_tva solded tva_type_name)
|
||||
QI_DYNAMICS = %w(solded_nbr_days solded_at cost_ht marge_ht weight_tot accounting_zone_id accounting_zone_name tot_amount_ht tot_amount_ttc tot_amount_tva label header footer payment_days payment_delais payment_month_end payment_end_at to_paid_ht to_paid_ttc to_paid_tva solded)# tva_type_name)
|
||||
|
||||
|
||||
def reset_for_update
|
||||
@ -644,7 +644,7 @@ class PriceDocument < ApplicationRecord
|
||||
if self.label != "Bon de livraison"
|
||||
#::POSIX::Spawn::Child.new 'pdftk', @final_file,"#{Rails.root}/pdf_stamp/cgv.pdf", 'cat', 'output', @final_file2 #AJOUT CGV
|
||||
#return @final_file2
|
||||
File.rename(@final_file, @final_file2)
|
||||
File.rename(@final_file, @final_file2) if File.exist?(@final_file)
|
||||
File.delete(@temp_file) if File.exist?(@temp_file)
|
||||
return @final_file2
|
||||
else
|
||||
|
@ -16,9 +16,13 @@
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
- elsif params[:controller] == "admin/price_lines"
|
||||
= form.inputs do
|
||||
|
||||
=@price_line.price_line_block.price_lineable.tva_type_id
|
||||
-if params[:p_product_ref_id]
|
||||
= form.input :p_product_ref_id, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => form.object.label_for(:p_product_ref), input_html: {disabled: true}
|
||||
= form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
|
||||
= form.hidden_field :tva_type_id, value: @price_line.price_line_block.price_lineable.tva_type_id
|
||||
|
||||
-else
|
||||
= form.input :p_product_ref_id, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => form.object.label_for(:p_product_ref), input_html: {disabled: true}
|
||||
= form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
|
||||
@ -29,4 +33,3 @@
|
||||
= form.semantic_fields_for :p_article_serial_nums do |form|
|
||||
=render :partial => "admin/p_article_serial_nums/form", :locals => {:form => form}
|
||||
%p= link_to_add_fields "Ajouter un numéro de série", form, :p_article_serial_nums, {:class => "btn btn-primary"}
|
||||
|
||||
|
@ -52,6 +52,11 @@
|
||||
}
|
||||
|
||||
-price_line_block = @price_document.price_line_block
|
||||
-p_custommer_sheet = @price_document.ref_element
|
||||
|
||||
|
||||
|
||||
|
||||
%body
|
||||
%table
|
||||
%thead
|
||||
@ -89,20 +94,16 @@
|
||||
%td{style: "line-height: 3px;"}
|
||||
=l @price_document.date, :format => :date
|
||||
%td
|
||||
%p{style: "line-height: 3px;"} Josef Falser
|
||||
%p{style: "line-height: 3px;"} zona produttiva Bodner 2
|
||||
%p{style: "line-height: 3px;"}
|
||||
39053 Prato Isarco, IT
|
||||
%p
|
||||
-if @price_document.label == "Bon de livraison"
|
||||
-@bl = true
|
||||
-particular_doc = price_line_block.particular_send
|
||||
-else
|
||||
-particular_doc = price_line_block.particular_bill
|
||||
-if particular_doc.organisation?
|
||||
%strong=particular_doc.organisation
|
||||
-if particular_doc.com_name?
|
||||
%br
|
||||
=particular_doc.com_name
|
||||
-# -if particular_doc.organisation?
|
||||
-# %strong=particular_doc.organisation
|
||||
-# -if particular_doc.com_name?
|
||||
-# %br=particular_doc.com_name
|
||||
%br
|
||||
-if particular_doc.firstname? or particular_doc.name?
|
||||
=particular_doc.civilite
|
||||
@ -115,9 +116,7 @@
|
||||
=particular_doc.address_3
|
||||
%br
|
||||
=particular_doc.cp
|
||||
=particular_doc.city
|
||||
%br
|
||||
=particular_doc.country
|
||||
="#{particular_doc.city}, #{particular_doc.country}"
|
||||
|
||||
|
||||
%table{style: "margin-top: 40px"}
|
||||
@ -128,419 +127,467 @@
|
||||
%th.border-left.border-top{:style => "width: 45%"} DESCRIPTION
|
||||
%th.border-left.border-top{:style => "width: 15%"} PRIX UNITAIRE
|
||||
%th.border-left.border-top.border-right{:style => "width: 15%"} TOTAL
|
||||
%tbody
|
||||
%tr.line-height-100
|
||||
%td.border-left.border-top 1
|
||||
%td.border-left.border-top SMARTPHONE RECONDITIONNE
|
||||
%td.border-left.border-top Samsung Galaxy Xcover 4 | SIM unique | schwarz
|
||||
%td.border-left.border-top 147,00 €
|
||||
%td.border-left.border-top.border-right 147,00 €
|
||||
%tr.line-height-100
|
||||
%td.border-left.border-top
|
||||
%td.border-left.border-top
|
||||
%td.border-left.border-top IMEI : Non renseigne
|
||||
%td.border-left.border-top
|
||||
%td.border-left.border-top.border-right
|
||||
%tr.line-height-20
|
||||
%td.border-top
|
||||
%td.border-top
|
||||
%td.border-top
|
||||
%td.border-left.border-top Total HT
|
||||
%td.border-top.border-left.border-right.bg-grey
|
||||
%strong 147,00 €
|
||||
%tr.line-height-20
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td.border-left Taux T.V.A.
|
||||
%td.border-left.border-right.bg-grey
|
||||
%strong TVA/MARGE
|
||||
%tr.line-height-20
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td.border-left.border-bottom
|
||||
%strong Total TTC
|
||||
%td.border-left.border-right.border-bottom.bg-grey
|
||||
%strong 147,00 €
|
||||
|
||||
|
||||
|
||||
|
||||
.clear
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%table.table{:style => "width:auto;"}
|
||||
%tr
|
||||
%td N° Client
|
||||
%td
|
||||
Date de commande
|
||||
%td Représentant
|
||||
-if @price_document.label != "Avoir"
|
||||
%td
|
||||
Semaine de livraison souhaitée
|
||||
%td
|
||||
Nombre de colis
|
||||
-elsif pd = PriceDocument.where(:id => @price_document.facture_id).first
|
||||
%td
|
||||
Réf. facture
|
||||
|
||||
%tr
|
||||
%td=@price_document.p_customer.code if @price_document.p_customer
|
||||
%td
|
||||
=l price_line_block.creation_date if price_line_block.creation_date
|
||||
%td
|
||||
=@price_document.p_commercial.long_name if @price_document.p_commercial
|
||||
-if @price_document.label != "Avoir"
|
||||
%td
|
||||
=l price_line_block.wish_date, :format => "%V"
|
||||
(du
|
||||
=l price_line_block.wish_date.beginning_of_week
|
||||
au
|
||||
=l price_line_block.wish_date.end_of_week
|
||||
)
|
||||
|
||||
%td
|
||||
=price_line_block.nbr_ship
|
||||
-elsif pd
|
||||
%td
|
||||
=pd.d_number
|
||||
|
||||
|
||||
|
||||
-if price_line_block.customer_ref?
|
||||
%p
|
||||
Référence commande personnalisée :
|
||||
=price_line_block.customer_ref
|
||||
|
||||
-if particular_doc
|
||||
-range_part = price_line_block.particular_send
|
||||
-range_part = range_part.particular_ref if range_part.particular_ref
|
||||
|
||||
-oras = []
|
||||
-OpenRange.where(:id => (OpenRange.all.ids - range_part.open_ranges.ids)).each do |ora|
|
||||
-oras << ora.name
|
||||
|
||||
-if oras.size > 0
|
||||
|
||||
%p
|
||||
Jour(s) de fermeture :
|
||||
=oras.join(", ")
|
||||
|
||||
|
||||
%br
|
||||
|
||||
%table.table
|
||||
%thead
|
||||
%tr
|
||||
%th Référence
|
||||
%th Désignation
|
||||
%th Qté [U]
|
||||
-if true or @price_document.label != "Avoir"
|
||||
%th Qté [Kg]
|
||||
-if !@bl
|
||||
-if @price_document.label != "Avoir"
|
||||
%th P.U. HT [Kg]
|
||||
%th TVA
|
||||
-if @price_document.label != "Avoir"
|
||||
-if !price_line_block.remise_ecole_ok
|
||||
%th
|
||||
Remise
|
||||
%br
|
||||
Marché
|
||||
%br
|
||||
annuel
|
||||
|
||||
-if price_line_block.ca_remise_qte_ok
|
||||
%th
|
||||
Remise
|
||||
%br
|
||||
Qté livrée
|
||||
%br
|
||||
="/cde"
|
||||
|
||||
-if price_line_block.remise_pre_order_ok
|
||||
%th
|
||||
Remise
|
||||
%br
|
||||
commande
|
||||
%br
|
||||
anticipée
|
||||
-if price_line_block.discount_comptant
|
||||
%th
|
||||
Remise
|
||||
%br
|
||||
comptant
|
||||
|
||||
-if price_line_block.remise_enrobage_ok
|
||||
%th
|
||||
Remise
|
||||
%br
|
||||
enrobage
|
||||
-else
|
||||
%th
|
||||
Remise
|
||||
%br
|
||||
école
|
||||
|
||||
-if @price_document.label != "Avoir"
|
||||
%th
|
||||
P.U. Net
|
||||
-else
|
||||
%th
|
||||
P.U.
|
||||
%th
|
||||
Montant HT
|
||||
%tbody
|
||||
-price_line_block.price_lines.each do |price_line|
|
||||
%tr
|
||||
%tr.line-height-100
|
||||
%td.border-left.border-top=price_line.id
|
||||
%td.border-left.border-top=price_line.ref
|
||||
%td.border-left.border-top=price_line.title
|
||||
-if @price_document.label != "Avoir"
|
||||
%td.border-left.border-top=number_to_currency price_line.ca_price_u_kg_net_ht
|
||||
-else
|
||||
%td.border-left.border-top=number_to_currency price_line.ca_price_u_ht
|
||||
%td.border-left.border-top.border-right=number_to_currency price_line.tot_amount_ht
|
||||
-sn_array = []
|
||||
-imei_array = []
|
||||
-price_line.p_articles.each do |p_article|
|
||||
-sn_array << p_article.p_article_serial_nums.map{ |sn| sn.value if sn.p_serial_num_type == PSerialNumType.find_by(name: "SN")}.reject(&:nil?)
|
||||
-imei_array << p_article.p_article_serial_nums.map{ |imei| imei.value if imei.p_serial_num_type == PSerialNumType.find_by(name: "IMEI")}.reject(&:nil?)
|
||||
|
||||
%tr.line-height-100
|
||||
%td.border-left.border-top
|
||||
%td.border-left.border-top
|
||||
%td.border-left.border-top
|
||||
%p{style: "line-height: 20px;"}="SN : " + sn_array.join(', ')
|
||||
%p{style: "line-height: 20px;"}="IMEI : " + imei_array.join(', ')
|
||||
%td.border-left.border-top
|
||||
%td.border-left.border-top.border-right
|
||||
|
||||
|
||||
-if price_line_block.price_lineable.tva_type_id == 1
|
||||
-# %tr.line-height-20
|
||||
-# %td
|
||||
-# %td
|
||||
-# %td
|
||||
-# %td.border-left Total HT Net
|
||||
-# %td.border-left.border-right.bg-grey
|
||||
-# %strong=number_to_currency price_line_block.tot_amount_ht
|
||||
%tr.line-height-20
|
||||
%td.border-top
|
||||
%td.border-top
|
||||
%td.border-top
|
||||
%td.border-left.border-top Montant HT
|
||||
%td.border-top.border-left.border-right.bg-grey
|
||||
%strong=number_to_currency price_line_block.tot_lines_ht
|
||||
%tr.line-height-20
|
||||
%td
|
||||
=price_line.ref
|
||||
-if price_line.p_product_ref and price_line.p_product_ref.assembled and @bl
|
||||
%br
|
||||
Contient les références primaires suivantes :
|
||||
-price_line.p_product_ref.p_product_assembleds.all.each do |ppa|
|
||||
%br
|
||||
|
||||
%strong
|
||||
=ppa.qte
|
||||
X
|
||||
=ppa.p_product_ref.p_product.code
|
||||
|
||||
%td
|
||||
=price_line.title
|
||||
%td.numeraire
|
||||
=price_line.qte
|
||||
-if true or @price_document.label != "Avoir"
|
||||
%td.numeraire
|
||||
=price_line.weight_qte.to_f.round(3)
|
||||
%td
|
||||
%td.border-left Montant T.V.A.
|
||||
%td.border-left.border-right.bg-grey
|
||||
%strong=number_to_currency price_line_block.tot_amount_tva
|
||||
%tr.line-height-20
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td.border-left Taux T.V.A.
|
||||
%td.border-left.border-right.bg-grey 20%
|
||||
%tr.line-height-20
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td.border-left.border-bottom
|
||||
%strong Total TTC
|
||||
%td.border-left.border-right.border-bottom.bg-grey
|
||||
%strong=number_to_currency price_line_block.tot_amount_ttc
|
||||
|
||||
|
||||
-if price_line_block.price_lineable.tva_type_id == 2
|
||||
%tr.line-height-20
|
||||
%td.border-top
|
||||
%td.border-top
|
||||
%td.border-top
|
||||
%td.border-left.border-top Total HT
|
||||
%td.border-top.border-left.border-right.bg-grey
|
||||
%strong=number_to_currency price_line_block.tot_lines_ht
|
||||
-# %tr.line-height-20
|
||||
-# %td
|
||||
-# %td
|
||||
-# %td
|
||||
-# %td.border-left Total HT Net
|
||||
-# %td.border-left.border-right.bg-grey
|
||||
-# %strong=number_to_currency price_line_block.tot_amount_ht
|
||||
%tr.line-height-20
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td.border-left Taux T.V.A.
|
||||
%td.border-left.border-right.bg-grey
|
||||
%strong TVA/MARGE
|
||||
-# %tr.line-height-20
|
||||
-# %td
|
||||
-# %td
|
||||
-# %td
|
||||
-# %td.border-left Total T.V.A.
|
||||
-# %td.border-left.border-right.bg-grey
|
||||
-# %strong=number_to_currency price_line_block.tot_amount_tva
|
||||
%tr.line-height-20
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td.border-left.border-bottom
|
||||
%strong Total TTC
|
||||
%td.border-left.border-right.border-bottom.bg-grey
|
||||
%strong=number_to_currency price_line_block.tot_amount_ttc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-# %table.table{:style => "width:auto;"}
|
||||
-# %tr
|
||||
-# %td N° Client
|
||||
-# %td
|
||||
-# Date de commande
|
||||
-# %td Représentant
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# %td
|
||||
-# Semaine de livraison souhaitée
|
||||
-# %td
|
||||
-# Nombre de colis
|
||||
-# -elsif pd = PriceDocument.where(:id => @price_document.facture_id).first
|
||||
-# %td
|
||||
-# Réf. facture
|
||||
|
||||
-# %tr
|
||||
-# %td=@price_document.p_customer.code if @price_document.p_customer
|
||||
-# %td
|
||||
-# =l price_line_block.creation_date if price_line_block.creation_date
|
||||
-# %td
|
||||
-# =@price_document.p_commercial.long_name if @price_document.p_commercial
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# %td
|
||||
-# =l price_line_block.wish_date, :format => "%V"
|
||||
-# (du
|
||||
-# =l price_line_block.wish_date.beginning_of_week
|
||||
-# au
|
||||
-# =l price_line_block.wish_date.end_of_week
|
||||
-# )
|
||||
|
||||
-# %td
|
||||
-# =price_line_block.nbr_ship
|
||||
-# -elsif pd
|
||||
-# %td
|
||||
-# =pd.d_number
|
||||
|
||||
|
||||
|
||||
-# -if price_line_block.customer_ref?
|
||||
-# %p
|
||||
-# Référence commande personnalisée :
|
||||
-# =price_line_block.customer_ref
|
||||
|
||||
-# -if particular_doc
|
||||
-# -range_part = price_line_block.particular_send
|
||||
-# -range_part = range_part.particular_ref if range_part.particular_ref
|
||||
|
||||
-# -oras = []
|
||||
-# -OpenRange.where(:id => (OpenRange.all.ids - range_part.open_ranges.ids)).each do |ora|
|
||||
-# -oras << ora.name
|
||||
|
||||
-# -if oras.size > 0
|
||||
|
||||
-# %p
|
||||
-# Jour(s) de fermeture :
|
||||
-# =oras.join(", ")
|
||||
|
||||
-if !@bl
|
||||
-if @price_document.label != "Avoir"
|
||||
%td.numeraire
|
||||
=number_to_currency price_line.ca_price_u_kg_ht
|
||||
%td.numeraire
|
||||
=price_line.tva_account_value.to_s+"%"
|
||||
|
||||
-if @price_document.label != "Avoir"
|
||||
-if !price_line_block.remise_ecole_ok
|
||||
%td.numeraire
|
||||
=price_line.discount_market_percent.to_s+"%"
|
||||
%br
|
||||
=number_to_currency price_line.ca_discount_market_ht
|
||||
-# %br
|
||||
|
||||
-# %table.table
|
||||
-# %thead
|
||||
-# %tr
|
||||
-# %th Référence
|
||||
-# %th Désignation
|
||||
-# %th Qté [U]
|
||||
-# -if true or @price_document.label != "Avoir"
|
||||
-# %th Qté [Kg]
|
||||
-# -if !@bl
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# %th P.U. HT [Kg]
|
||||
-# %th TVA
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# -if !price_line_block.remise_ecole_ok
|
||||
-# %th
|
||||
-# Remise
|
||||
-# %br
|
||||
-# Marché
|
||||
-# %br
|
||||
-# annuel
|
||||
|
||||
-# -if price_line_block.ca_remise_qte_ok
|
||||
-# %th
|
||||
-# Remise
|
||||
-# %br
|
||||
-# Qté livrée
|
||||
-# %br
|
||||
-# ="/cde"
|
||||
|
||||
-# -if price_line_block.remise_pre_order_ok
|
||||
-# %th
|
||||
-# Remise
|
||||
-# %br
|
||||
-# commande
|
||||
-# %br
|
||||
-# anticipée
|
||||
-# -if price_line_block.discount_comptant
|
||||
-# %th
|
||||
-# Remise
|
||||
-# %br
|
||||
-# comptant
|
||||
|
||||
-# -if price_line_block.remise_enrobage_ok
|
||||
-# %th
|
||||
-# Remise
|
||||
-# %br
|
||||
-# enrobage
|
||||
-# -else
|
||||
-# %th
|
||||
-# Remise
|
||||
-# %br
|
||||
-# école
|
||||
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# %th
|
||||
-# P.U. Net
|
||||
-# -else
|
||||
-# %th
|
||||
-# P.U.
|
||||
-# %th
|
||||
-# Montant HT
|
||||
-# %tbody
|
||||
-# -price_line_block.price_lines.each do |price_line|
|
||||
-# %tr
|
||||
-# %td
|
||||
-# =price_line.ref
|
||||
-# -if price_line.p_product_ref and price_line.p_product_ref.assembled and @bl
|
||||
-# %br
|
||||
-# Contient les références primaires suivantes :
|
||||
-# -price_line.p_product_ref.p_product_assembleds.all.each do |ppa|
|
||||
-# %br
|
||||
|
||||
-# %strong
|
||||
-# =ppa.qte
|
||||
-# X
|
||||
-# =ppa.p_product_ref.p_product.code
|
||||
|
||||
-# %td
|
||||
-# =price_line.title
|
||||
-# %td.numeraire
|
||||
-# =price_line.qte
|
||||
-# -if true or @price_document.label != "Avoir"
|
||||
-# %td.numeraire
|
||||
-# =price_line.weight_qte.to_f.round(3)
|
||||
|
||||
-# -if !@bl
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line.ca_price_u_kg_ht
|
||||
-# %td.numeraire
|
||||
-# =price_line.tva_account_value.to_s+"%"
|
||||
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# -if !price_line_block.remise_ecole_ok
|
||||
-# %td.numeraire
|
||||
-# =price_line.discount_market_percent.to_s+"%"
|
||||
-# %br
|
||||
-# =number_to_currency price_line.ca_discount_market_ht
|
||||
|
||||
-if price_line_block.ca_remise_qte_ok
|
||||
%td.numeraire
|
||||
=price_line.discount_qte_percent.to_s+"%"
|
||||
%br
|
||||
=number_to_currency price_line.ca_discount_qte_ht
|
||||
-if price_line_block.remise_pre_order_ok
|
||||
%td.numeraire
|
||||
-# -if price_line_block.ca_remise_qte_ok
|
||||
-# %td.numeraire
|
||||
-# =price_line.discount_qte_percent.to_s+"%"
|
||||
-# %br
|
||||
-# =number_to_currency price_line.ca_discount_qte_ht
|
||||
-# -if price_line_block.remise_pre_order_ok
|
||||
-# %td.numeraire
|
||||
|
||||
=price_line.discount_delay_percent.to_s+"%"
|
||||
%br
|
||||
=number_to_currency price_line.ca_discount_delay_ht
|
||||
-# =price_line.discount_delay_percent.to_s+"%"
|
||||
-# %br
|
||||
-# =number_to_currency price_line.ca_discount_delay_ht
|
||||
|
||||
-if price_line_block.discount_comptant
|
||||
%td.numeraire
|
||||
=price_line.discount_comptant_percent.to_s+"%"
|
||||
%br
|
||||
=number_to_currency price_line.ca_discount_comptant_ht
|
||||
-# -if price_line_block.discount_comptant
|
||||
-# %td.numeraire
|
||||
-# =price_line.discount_comptant_percent.to_s+"%"
|
||||
-# %br
|
||||
-# =number_to_currency price_line.ca_discount_comptant_ht
|
||||
|
||||
-if price_line_block.remise_enrobage_ok
|
||||
%td.numeraire
|
||||
=price_line.discount_enrobage_percent.to_s+"%"
|
||||
%br
|
||||
=number_to_currency price_line.ca_discount_enrobage_ht
|
||||
-else
|
||||
%td.numeraire
|
||||
=price_line.discount_ecole_percent.to_s+"%"
|
||||
%br
|
||||
=number_to_currency price_line.ca_discount_ecole_ht
|
||||
-# -if price_line_block.remise_enrobage_ok
|
||||
-# %td.numeraire
|
||||
-# =price_line.discount_enrobage_percent.to_s+"%"
|
||||
-# %br
|
||||
-# =number_to_currency price_line.ca_discount_enrobage_ht
|
||||
-# -else
|
||||
-# %td.numeraire
|
||||
-# =price_line.discount_ecole_percent.to_s+"%"
|
||||
-# %br
|
||||
-# =number_to_currency price_line.ca_discount_ecole_ht
|
||||
|
||||
-if @price_document.label != "Avoir"
|
||||
%td.numeraire
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# %td.numeraire
|
||||
|
||||
=number_to_currency price_line.ca_price_u_kg_net_ht
|
||||
-else
|
||||
%td.numeraire
|
||||
=number_to_currency price_line.ca_price_u_ht
|
||||
-# =number_to_currency price_line.ca_price_u_kg_net_ht
|
||||
-# -else
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line.ca_price_u_ht
|
||||
|
||||
|
||||
|
||||
%td.numeraire
|
||||
=number_to_currency price_line.tot_amount_ht
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line.tot_amount_ht
|
||||
|
||||
|
||||
-if !@bl
|
||||
%table.table{:style => "width:auto;float:right;border-top:0;"}
|
||||
-# -if !@bl
|
||||
-# %table.table{:style => "width:auto;float:right;border-top:0;"}
|
||||
|
||||
-if @price_document.label != "Avoir"
|
||||
%tr
|
||||
%th{:style => "border-top:0;"}
|
||||
Poids total :
|
||||
|
||||
%td.numeraire{:style => "border-top:0;"}
|
||||
="#{price_line_block.weight_tot}Kg"
|
||||
%tr
|
||||
%th Total remises U. HT :
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.cumul_discount_ht
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# %tr
|
||||
-# %th{:style => "border-top:0;"}
|
||||
-# Poids total :
|
||||
-#
|
||||
-# %td.numeraire{:style => "border-top:0;"}
|
||||
-# ="#{price_line_block.weight_tot}Kg"
|
||||
-# %tr
|
||||
-# %th Total remises U. HT :
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.cumul_discount_ht
|
||||
|
||||
%tr
|
||||
%th
|
||||
Total HT
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.tot_lines_ht
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Total HT
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.tot_lines_ht
|
||||
|
||||
-if @price_document.label != "Avoir"
|
||||
-if price_line_block.tot_discount_ht != 0.0
|
||||
%tr
|
||||
%th
|
||||
Remise commerciale exceptionnelle (HT
|
||||
="(#{price_line_block.ct_tot_discount_percent}%)"
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.tot_discount_ht
|
||||
-# -if @price_document.label != "Avoir"
|
||||
-# -if price_line_block.tot_discount_ht != 0.0
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Remise commerciale exceptionnelle (HT
|
||||
-# ="(#{price_line_block.ct_tot_discount_percent}%)"
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.tot_discount_ht
|
||||
|
||||
%tr
|
||||
%th
|
||||
Frais de port HT
|
||||
="(TVA #{price_line_block.fdp_tva_rate}%)"
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.tot_fdp_ht
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Frais de port HT
|
||||
-# ="(TVA #{price_line_block.fdp_tva_rate}%)"
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.tot_fdp_ht
|
||||
|
||||
%tr
|
||||
%th
|
||||
Total HT Net
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.tot_amount_ht
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Total HT Net
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.tot_amount_ht
|
||||
|
||||
%tr
|
||||
%th
|
||||
Total TVA
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.tot_amount_tva
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Total TVA
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.tot_amount_tva
|
||||
|
||||
%tr
|
||||
%th
|
||||
Total TTC
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.tot_amount_ttc
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Total TTC
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.tot_amount_ttc
|
||||
|
||||
%tr
|
||||
%th
|
||||
|
||||
%th
|
||||
-# %tr
|
||||
-# %th
|
||||
-#
|
||||
-# %th
|
||||
|
||||
%tr
|
||||
%th
|
||||
Net à payer
|
||||
%td.numeraire
|
||||
=number_to_currency price_line_block.tot_amount_ttc
|
||||
-else
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Net à payer
|
||||
-# %td.numeraire
|
||||
-# =number_to_currency price_line_block.tot_amount_ttc
|
||||
-# -else
|
||||
|
||||
|
||||
|
||||
%table.table{:style => "width:auto;float:right;border-top:0;"}
|
||||
-# %table.table{:style => "width:auto;float:right;border-top:0;"}
|
||||
|
||||
%tr
|
||||
%th{:style => "border-top:0;"}
|
||||
Poids total :
|
||||
|
||||
%td.numeraire{:style => "border-top:0;"}
|
||||
="#{price_line_block.weight_tot}Kg"
|
||||
-# %tr
|
||||
-# %th{:style => "border-top:0;"}
|
||||
-# Poids total :
|
||||
-#
|
||||
-# %td.numeraire{:style => "border-top:0;"}
|
||||
-# ="#{price_line_block.weight_tot}Kg"
|
||||
|
||||
|
||||
|
||||
-if !@bl
|
||||
%br
|
||||
%br
|
||||
%table.table{:style => "width:auto;"}
|
||||
%tr
|
||||
%th
|
||||
Taux
|
||||
%br
|
||||
TVA
|
||||
%th Montant HT Net
|
||||
%th Montant TVA
|
||||
-tva_rates = {}
|
||||
-# -if !@bl
|
||||
-# %br
|
||||
-# %br
|
||||
-# %table.table{:style => "width:auto;"}
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Taux
|
||||
-# %br
|
||||
-# TVA
|
||||
-# %th Montant HT Net
|
||||
-# %th Montant TVA
|
||||
-# -tva_rates = {}
|
||||
|
||||
-price_line_block.price_lines.each do |pl|
|
||||
-# -price_line_block.price_lines.each do |pl|
|
||||
|
||||
-tva_rates[pl.tva_account_value.to_s] = tva_rates[pl.tva_account_value.to_s] || {:montant => 0.0, :tva => 0.0}
|
||||
-# -tva_rates[pl.tva_account_value.to_s] = tva_rates[pl.tva_account_value.to_s] || {:montant => 0.0, :tva => 0.0}
|
||||
|
||||
-tva_rates[pl.tva_account_value.to_s][:montant] += pl.tot_amount_ht.to_f - (pl.tot_amount_ht.to_f * ((price_line_block.ct_tot_discount_percent and price_line_block.ct_tot_discount_percent != 0.0) ? (price_line_block.ct_tot_discount_percent.to_f/100) : 0.0))
|
||||
-# -tva_rates[pl.tva_account_value.to_s][:montant] += pl.tot_amount_ht.to_f - (pl.tot_amount_ht.to_f * ((price_line_block.ct_tot_discount_percent and price_line_block.ct_tot_discount_percent != 0.0) ? (price_line_block.ct_tot_discount_percent.to_f/100) : 0.0))
|
||||
|
||||
-tva_rates[pl.tva_account_value.to_s][:tva] += pl.tot_amount_tva.to_f - (pl.tot_amount_tva.to_f * ((price_line_block.ct_tot_discount_percent and price_line_block.ct_tot_discount_percent != 0.0) ? (price_line_block.ct_tot_discount_percent.to_f/100) : 0.0.to_f))
|
||||
-# -tva_rates[pl.tva_account_value.to_s][:tva] += pl.tot_amount_tva.to_f - (pl.tot_amount_tva.to_f * ((price_line_block.ct_tot_discount_percent and price_line_block.ct_tot_discount_percent != 0.0) ? (price_line_block.ct_tot_discount_percent.to_f/100) : 0.0.to_f))
|
||||
|
||||
|
||||
|
||||
-tva_rates[price_line_block.fdp_tva_rate.to_s] = tva_rates[price_line_block.fdp_tva_rate.to_s] || {:montant => 0.0, :tva => 0.0}
|
||||
-# -tva_rates[price_line_block.fdp_tva_rate.to_s] = tva_rates[price_line_block.fdp_tva_rate.to_s] || {:montant => 0.0, :tva => 0.0}
|
||||
|
||||
-tva_rates[price_line_block.fdp_tva_rate.to_s][:montant] += price_line_block.tot_fdp_ht
|
||||
-# -tva_rates[price_line_block.fdp_tva_rate.to_s][:montant] += price_line_block.tot_fdp_ht
|
||||
|
||||
-tva_rates[price_line_block.fdp_tva_rate.to_s][:tva] += price_line_block.tot_fdp_tva
|
||||
-# -tva_rates[price_line_block.fdp_tva_rate.to_s][:tva] += price_line_block.tot_fdp_tva
|
||||
|
||||
-tva_rates.each do |key, value|
|
||||
%tr
|
||||
%td
|
||||
="#{key}%"
|
||||
%td
|
||||
=number_to_currency value[:montant]
|
||||
-# -tva_rates.each do |key, value|
|
||||
-# %tr
|
||||
-# %td
|
||||
-# ="#{key}%"
|
||||
-# %td
|
||||
-# =number_to_currency value[:montant]
|
||||
|
||||
%td
|
||||
=number_to_currency value[:tva]
|
||||
-if @bl
|
||||
%div{:style => "width:60%;"}
|
||||
=simple_format price_line_block.bl_comment
|
||||
-# %td
|
||||
-# =number_to_currency value[:tva]
|
||||
-# -if @bl
|
||||
-# %div{:style => "width:60%;"}
|
||||
-# =simple_format price_line_block.bl_comment
|
||||
|
||||
|
||||
|
||||
|
||||
-if !@bl and @price_document.label != "Avoir"
|
||||
%br
|
||||
%br
|
||||
-# -if !@bl and @price_document.label != "Avoir"
|
||||
-# %br
|
||||
-# %br
|
||||
|
||||
%table.table{:style => "width:auto;"}
|
||||
%tr
|
||||
%th
|
||||
Échéance
|
||||
%th Mode de paiement
|
||||
%th
|
||||
Montant net
|
||||
%tr
|
||||
%td
|
||||
-if @price_document.label == "Facture"
|
||||
=l @price_document.payment_end_at
|
||||
-# %table.table{:style => "width:auto;"}
|
||||
-# %tr
|
||||
-# %th
|
||||
-# Échéance
|
||||
-# %th Mode de paiement
|
||||
-# %th
|
||||
-# Montant net
|
||||
-# %tr
|
||||
-# %td
|
||||
-# -if @price_document.label == "Facture"
|
||||
-# =l @price_document.payment_end_at
|
||||
|
||||
-else
|
||||
=price_line_block.payment_delais.to_i
|
||||
jours
|
||||
%td
|
||||
=price_line_block.p_payment_type.name if price_line_block.p_payment_type
|
||||
%td
|
||||
=number_to_currency price_line_block.tot_amount_ttc
|
||||
.clear
|
||||
-if @price_document.label == "Facture"
|
||||
%p.legals{:style => "text-align:center;font-size:10px;margin-top:10px;olwen_demo_app"}
|
||||
Pas d'escompte pour paiement anticipé, passée la date d'échéance, tout paiement différé entraine l'application d'une pénalité de 3 fois le taux d'intérêt légal.
|
||||
(loi 2008-776 du 04/08/2008) ainsi qu'une indemnité forfaitaire pour frais de recouvrement de 40 euros (Décret 2012-1115 du 02/10/2012).
|
||||
-# -else
|
||||
-# =price_line_block.payment_delais.to_i
|
||||
-# jours
|
||||
-# %td
|
||||
-# =price_line_block.p_payment_type.name if price_line_block.p_payment_type
|
||||
-# %td
|
||||
-# =number_to_currency price_line_block.tot_amount_ttc
|
||||
-# .clear
|
||||
-# -if @price_document.label == "Facture"
|
||||
-# %p.legals{:style => "text-align:center;font-size:10px;margin-top:10px;olwen_demo_app"}
|
||||
-# Pas d'escompte pour paiement anticipé, passée la date d'échéance, tout paiement différé entraine l'application d'une pénalité de 3 fois le taux d'intérêt légal.
|
||||
-# (loi 2008-776 du 04/08/2008) ainsi qu'une indemnité forfaitaire pour frais de recouvrement de 40 euros (Décret 2012-1115 du 02/10/2012).
|
||||
|
||||
.clear
|
||||
-# .clear
|
@ -67,8 +67,10 @@
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding.row
|
||||
-if !@avoir
|
||||
= f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :"#, :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"}
|
||||
= f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :"
|
||||
.col-3
|
||||
= f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :"#, :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"}
|
||||
.col-3
|
||||
= f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :"
|
||||
|
||||
|
||||
-if current_admin.has_permission?("payments")
|
||||
@ -94,5 +96,5 @@
|
||||
:javascript
|
||||
$('.p_product_ref_select').select2();
|
||||
$('.add_lines').click(function() {
|
||||
$('.p_product_ref_select').last().select2(});
|
||||
$('.p_product_ref_select').last().select2();
|
||||
});
|
5
db/migrate/20211112130721_add_tva_type_to_p_article.rb
Normal file
5
db/migrate/20211112130721_add_tva_type_to_p_article.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddTvaTypeToPArticle < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_reference :p_articles, :tva_type, index: true
|
||||
end
|
||||
end
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_11_03_085623) do
|
||||
ActiveRecord::Schema.define(version: 2021_11_12_130721) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -999,8 +999,10 @@ ActiveRecord::Schema.define(version: 2021_11_03_085623) do
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.bigint "p_grade_id"
|
||||
t.bigint "tva_type_id"
|
||||
t.index ["p_grade_id"], name: "index_p_articles_on_p_grade_id"
|
||||
t.index ["p_product_ref_id"], name: "index_p_articles_on_p_product_ref_id"
|
||||
t.index ["tva_type_id"], name: "index_p_articles_on_tva_type_id"
|
||||
end
|
||||
|
||||
create_table "p_bank_accounts", force: :cascade do |t|
|
||||
|
Reference in New Issue
Block a user