NEW workflow set reception billed on validate supplier bill

This commit is contained in:
atm-quentin 2018-10-11 14:49:19 +02:00
parent 1c33714091
commit 4b23b46e48
3 changed files with 30 additions and 0 deletions

View File

@ -83,6 +83,8 @@ $workflowcodes=array(
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>50, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>''),
'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>40, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>''),
'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->reception->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'bill'),
);
if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))

View File

@ -254,6 +254,33 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
}
// classify billed reception
if ($action == 'BILL_SUPPLIER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG);
if (! empty($conf->reception->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_RECEPTION))
{
$object->fetchObjectLinked('','reception',$object->id,$object->element);
if (! empty($object->linkedObjects))
{
$totalonlinkedelements=0;
foreach($object->linkedObjects['reception'] as $element)
{
if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht;
}
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
if ($totalonlinkedelements == $object->total_ht)
{
foreach($object->linkedObjects['reception'] as $element)
{
$ret=$element->set_billed();
}
}
}
return $ret;
}
}
return 0;
}

View File

@ -13,5 +13,6 @@ descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classer la/les proposition(s) commer
descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classer la/les commande(s) client(s) source(s) facturée à la validation de la facture client (et si le montant des deux documents est le même)
descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classer la/les commande(s) client(s) source(s) facturée au classement payé de la facture client (et si le montant des deux documents est le même)
descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classer la commande source expédiée à la validation d'une expédition (si les quantité des documents sont les mêmes)
descWORKFLOW_BILL_ON_RECEPTION=Classer la/les réception(s) facturée(s) à la validation d'une facture fournisseur (si la facture est du même montant que la commande)
AutomaticCreation=Création automatique
AutomaticClassification=Classification automatique