suite
This commit is contained in:
parent
4a3a65e4bf
commit
5230857960
@ -24,7 +24,7 @@ class Admin::PDocumentsController < ApplicationController
|
||||
@p_document = PDocument.find_by_token(params[:id])
|
||||
@element = @p_document.element
|
||||
params[:inline] = true
|
||||
if false
|
||||
if true
|
||||
|
||||
@temp_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}_temp.pdf"
|
||||
@final_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}.pdf"
|
||||
|
@ -266,6 +266,7 @@ class PCustomerSheet < ActiveRecord::Base
|
||||
if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Bon de commande"))
|
||||
self.state = "commande"
|
||||
self.save
|
||||
self.unstock_th
|
||||
end
|
||||
|
||||
end
|
||||
@ -287,6 +288,8 @@ class PCustomerSheet < ActiveRecord::Base
|
||||
|
||||
self.fige
|
||||
|
||||
self.unstock
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -315,6 +318,32 @@ class PCustomerSheet < ActiveRecord::Base
|
||||
|
||||
end
|
||||
|
||||
def unstock_th
|
||||
self.p_sheet_lines.each do |sheet_line|
|
||||
p_sheet_line_lines = sheet_line.p_sheet_line_lines.where("qte > 0")
|
||||
p_sheet_line_lines.each do |p_sheet_line_line|
|
||||
if p_sheet_line_line.p_product_stock
|
||||
p_sheet_line_line.p_product_stock.stock_th_ok = p_sheet_line_line.p_product_stock.stock_th_ok - p_sheet_line_line.qte
|
||||
p_sheet_line_line.p_product_stock.save
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def unstock
|
||||
self.p_sheet_lines.each do |sheet_line|
|
||||
p_sheet_line_lines = sheet_line.p_sheet_line_lines.where("qte > 0")
|
||||
p_sheet_line_lines.each do |p_sheet_line_line|
|
||||
if p_sheet_line_line.p_product_stock
|
||||
p_sheet_line_line.p_product_stock.stock_ok = p_sheet_line_line.p_product_stock.stock_ok - p_sheet_line_line.qte
|
||||
p_sheet_line_line.p_product_stock.save
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
STATES = ["panier", "brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"]
|
||||
|
||||
|
@ -13,12 +13,13 @@
|
||||
|
||||
%th
|
||||
Qte
|
||||
%th
|
||||
Prix U.
|
||||
%th
|
||||
Prix Tot.
|
||||
%th
|
||||
Prix TTC
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
%th
|
||||
Prix U.
|
||||
%th
|
||||
Prix Tot.
|
||||
%th
|
||||
Prix TTC
|
||||
|
||||
|
||||
-sheet_lines.each do |sheet_line|
|
||||
@ -65,13 +66,14 @@
|
||||
|
||||
%td{}
|
||||
=qte_tot.to_i
|
||||
%td
|
||||
=number_to_currency sheet_line.price.to_f
|
||||
%td
|
||||
=number_to_currency sheet_line.price.to_f * qte_tot.to_i
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
%td
|
||||
=number_to_currency sheet_line.price.to_f
|
||||
%td
|
||||
=number_to_currency sheet_line.price.to_f * qte_tot.to_i
|
||||
|
||||
%td
|
||||
=number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i
|
||||
%td
|
||||
=number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i
|
||||
|
||||
%tr.tr_sheet_line_head
|
||||
|
||||
@ -86,45 +88,47 @@
|
||||
%td
|
||||
=sheet_line.qte
|
||||
|
||||
%td
|
||||
=number_to_currency sheet_line.price if sheet_line.price
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
%td
|
||||
=number_to_currency sheet_line.price if sheet_line.price
|
||||
|
||||
%td
|
||||
=number_to_currency sheet_line.price_tot if sheet_line.price_tot
|
||||
%td
|
||||
=number_to_currency sheet_line.price_tot if sheet_line.price_tot
|
||||
|
||||
%td
|
||||
=number_to_currency sheet_line.price_tot_ttc if sheet_line.price_tot_ttc
|
||||
%td
|
||||
=number_to_currency sheet_line.price_tot_ttc if sheet_line.price_tot_ttc
|
||||
|
||||
|
||||
-total_with_labels = PSheetLine.total_with_labels(sheet_lines)
|
||||
|
||||
-total_with_labels.each do |index, total|
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
-total_with_labels.each do |index, total|
|
||||
|
||||
|
||||
%tr.sheet_line_head
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%strong
|
||||
=total[:label]
|
||||
%td
|
||||
=number_to_currency total[:value]
|
||||
%tr.sheet_line_head
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%strong
|
||||
=total[:label]
|
||||
%td
|
||||
=number_to_currency total[:value]
|
||||
|
||||
-if @p_document and @p_document.label == "Facture Acompte"
|
||||
%tr
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
Pourcentage d'acompte :
|
||||
%td
|
||||
=@p_document.acompte_percent.to_s+"%"
|
||||
%tr
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
Acompte HT :
|
||||
%td
|
||||
=number_to_currency @p_document.total_with_labels_table[:total][:value] * (@p_document.acompte_percent.to_f/100)
|
||||
-if @p_document and @p_document.label == "Facture Acompte"
|
||||
%tr
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
Pourcentage d'acompte :
|
||||
%td
|
||||
=@p_document.acompte_percent.to_s+"%"
|
||||
%tr
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
Acompte HT :
|
||||
%td
|
||||
=number_to_currency @p_document.total_with_labels_table[:total][:value] * (@p_document.acompte_percent.to_f/100)
|
||||
|
||||
%tr.sheet_line_head
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%strong Acompte TTC :
|
||||
%td
|
||||
%strong=number_to_currency @p_document.total_with_labels_table[:total_ttc][:value] * (@p_document.acompte_percent.to_f/100)
|
||||
%tr.sheet_line_head
|
||||
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
|
||||
%strong Acompte TTC :
|
||||
%td
|
||||
%strong=number_to_currency @p_document.total_with_labels_table[:total_ttc][:value] * (@p_document.acompte_percent.to_f/100)
|
||||
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
%body
|
||||
#header
|
||||
.right
|
||||
.right{:style => "text-align:right;"}
|
||||
-if current_p_customer
|
||||
=link_to ic(:user)+" Mon compte", public_my_account_path
|
||||
="-"
|
||||
@ -42,7 +42,7 @@
|
||||
="-"
|
||||
=link_to ic(:"power-off")+" Déconnexion", logout_public_p_customer_auths_path()
|
||||
%br
|
||||
=link_to "Mes commandes", public_p_customer_sheets_path()
|
||||
=link_to "Mes commandes / factures", public_p_customer_sheets_path()
|
||||
="-"
|
||||
|
||||
=link_to ic(:"shopping-cart")+" commande en cours ("+current_p_customer_sheet.qte.to_i.to_s+" articles)", cart_public_p_orders_path()
|
||||
|
Loading…
x
Reference in New Issue
Block a user