70 lines
1.8 KiB
Ruby
70 lines
1.8 KiB
Ruby
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"
|
|
'<span class="badge badge-pill badge-warning">Demande de commande</span>'
|
|
elsif self.state == "offre"
|
|
'<span class="badge badge-warning">Offre</span>'
|
|
elsif self.state == "commande"
|
|
'<span class="badge badge-success">Commande</span>'
|
|
elsif self.state == "livraison-en-cours"
|
|
'<span class="badge badge-success" style="background:#036516;">Livr. en cours</span>'
|
|
elsif self.state == "livrée"
|
|
'<span class="badge badge-info">livrée</span>'
|
|
elsif self.state =="facturée"
|
|
'<span class="badge badge-primary">Facturée</span>'
|
|
elsif self.state == "annulée"
|
|
'<span class="badge badge-dark">Annulée</span>'
|
|
elsif self.state == "refusée"
|
|
'<span class="badge badge-danger">Refusée</span>'
|
|
elsif self.state == "remboursée"
|
|
'<span class="badge badge-danger" style="background:#865F7C;">Remboursée</span>'
|
|
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
|