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,6 +13,7 @@
|
||||
|
||||
%th
|
||||
Qte
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
%th
|
||||
Prix U.
|
||||
%th
|
||||
@ -65,6 +66,7 @@
|
||||
|
||||
%td{}
|
||||
=qte_tot.to_i
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
%td
|
||||
=number_to_currency sheet_line.price.to_f
|
||||
%td
|
||||
@ -86,6 +88,7 @@
|
||||
%td
|
||||
=sheet_line.qte
|
||||
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
%td
|
||||
=number_to_currency sheet_line.price if sheet_line.price
|
||||
|
||||
@ -98,6 +101,7 @@
|
||||
|
||||
-total_with_labels = PSheetLine.total_with_labels(sheet_lines)
|
||||
|
||||
-if @p_document and @p_document.label != "Bon de livraison"
|
||||
-total_with_labels.each do |index, total|
|
||||
|
||||
|
||||
|
@ -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