This commit is contained in:
Nicolas Bally 2018-12-26 11:32:22 +01:00
parent 4a3a65e4bf
commit 5230857960
4 changed files with 77 additions and 44 deletions

View File

@ -24,7 +24,7 @@ class Admin::PDocumentsController < ApplicationController
@p_document = PDocument.find_by_token(params[:id]) @p_document = PDocument.find_by_token(params[:id])
@element = @p_document.element @element = @p_document.element
params[:inline] = true params[:inline] = true
if false if true
@temp_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}_temp.pdf" @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" @final_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}.pdf"

View File

@ -266,6 +266,7 @@ class PCustomerSheet < ActiveRecord::Base
if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Bon de commande")) if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Bon de commande"))
self.state = "commande" self.state = "commande"
self.save self.save
self.unstock_th
end end
end end
@ -287,6 +288,8 @@ class PCustomerSheet < ActiveRecord::Base
self.fige self.fige
self.unstock
end end
end end
@ -315,6 +318,32 @@ class PCustomerSheet < ActiveRecord::Base
end 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"] STATES = ["panier", "brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"]

View File

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

View File

@ -34,7 +34,7 @@
%body %body
#header #header
.right .right{:style => "text-align:right;"}
-if current_p_customer -if current_p_customer
=link_to ic(:user)+" Mon compte", public_my_account_path =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() =link_to ic(:"power-off")+" Déconnexion", logout_public_p_customer_auths_path()
%br %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() =link_to ic(:"shopping-cart")+" commande en cours ("+current_p_customer_sheet.qte.to_i.to_s+" articles)", cart_public_p_orders_path()