regroup BILL_SUPPLIER_VALIDATE actions
Conflicts: htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
This commit is contained in:
parent
65ccbb6249
commit
59e917cd5f
@ -191,7 +191,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
|||||||
if ($action == 'BILL_SUPPLIER_VALIDATE') {
|
if ($action == 'BILL_SUPPLIER_VALIDATE') {
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
// First classify billed the order to allow the proposal classify process
|
// Firstly, we set to purchase order to "Billed" if WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER is set.
|
||||||
|
// After we will set proposals
|
||||||
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) {
|
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) {
|
||||||
$object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element);
|
$object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element);
|
||||||
if (!empty($object->linkedObjects)) {
|
if (!empty($object->linkedObjects)) {
|
||||||
@ -205,12 +206,15 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
|||||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||||
foreach ($object->linkedObjects['order_supplier'] as $element) {
|
foreach ($object->linkedObjects['order_supplier'] as $element) {
|
||||||
$ret = $element->classifyBilled($user);
|
$ret = $element->classifyBilled($user);
|
||||||
|
if ($ret < 0) {
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second classify billed the proposal.
|
// Secondly, we set to linked Proposal to "Billed" if WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL is set.
|
||||||
if (!empty($conf->supplier_proposal->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) {
|
if (!empty($conf->supplier_proposal->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) {
|
||||||
$object->fetchObjectLinked('', 'supplier_proposal', $object->id, $object->element);
|
$object->fetchObjectLinked('', 'supplier_proposal', $object->id, $object->element);
|
||||||
if (!empty($object->linkedObjects)) {
|
if (!empty($object->linkedObjects)) {
|
||||||
@ -224,11 +228,35 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
|||||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||||
foreach ($object->linkedObjects['supplier_proposal'] as $element) {
|
foreach ($object->linkedObjects['supplier_proposal'] as $element) {
|
||||||
$ret = $element->classifyBilled($user);
|
$ret = $element->classifyBilled($user);
|
||||||
|
if ($ret < 0) {
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Then set reception to "Billed" if WORKFLOW_BILL_ON_RECEPTION is set
|
||||||
|
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
|
// Invoice classify billed order
|
||||||
@ -317,29 +345,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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user