class PFournisseurOrder < ApplicationRecord
belongs_to :p_fournisseur
has_one :price_line_block, :as => :price_lineable
accepts_nested_attributes_for :price_line_block
has_many :price_documents, :as => :ref_element
has_many :p_fournisseur_docs
has_many :stock_blocks, :as => :stockable
has_many :stock_lines, :through => :stock_blocks
STATES = ["Brouillon", "Demande chiffrage", "Commande", "Commande validée", "Livrée", "Facturée", "Terminée"]
PAYMENT_STATES = ["RAS","Paiement avant envoi ok", "Action requise", "A payer", "Autorisation de payer","Paiement OK"]
def state_html
if self.state == "brouillon"
'Demande de commande'
elsif self.state == "offre"
'Offre'
elsif self.state == "commande"
'Commande'
elsif self.state == "livraison-en-cours"
'Livr. en cours'
elsif self.state == "livrée"
'livrée'
elsif self.state =="facturée"
'Facturée'
elsif self.state == "annulée"
'Annulée'
elsif self.state == "refusée"
'Refusée'
elsif self.state == "remboursée"
'Remboursée'
end
end
before_save do
end
def accounting_zone_name
self.p_fournisseur.accounting_zone.name if self.p_fournisseur and self.p_fournisseur.accounting_zone
end
def accounting_zone_id
self.p_fournisseur.accounting_zone_id
end
end