Merge pull request #18562 from vincentjdc/bill-supplier-validate

Bill supplier validate
This commit is contained in:
Laurent Destailleur 2021-09-01 16:04:50 +02:00 committed by GitHub
commit 46a38506a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -206,10 +206,12 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
foreach ($object->linkedObjects['order_supplier'] as $element) {
$ret = $element->classifyBilled($user);
if ($ret < 0) {
return $ret;
}
}
}
}
return $ret;
}
// Second classify billed the proposal.
@ -226,11 +228,34 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
foreach ($object->linkedObjects['supplier_proposal'] as $element) {
$ret = $element->classifyBilled($user);
if ($ret < 0) {
return $ret;
}
}
}
}
return $ret;
}
// classify billed reception
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();
if ($ret < 0) {
return $ret;
}
}
}
}
}
return $ret;
}
// Invoice classify billed order
@ -325,30 +350,6 @@ 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->setBilled();
}
}
}
return $ret;
}
}
return 0;
}