From 58c889cba230ab4398e12d2905205e03162d97b2 Mon Sep 17 00:00:00 2001 From: Erawat Chamanont Date: Fri, 22 Sep 2023 13:07:54 +0100 Subject: [PATCH] BTHAB-186: Update case opportunity details Update case opportunity statuses, and total amounts when: * Create or update sales order contribution * Create or update sales order * Create a payment --- .../AbstractBaseSalesOrderCalculator.php | 21 ++++++++++++++++++- .../CaseSalesOrderContributionCalculator.php | 2 +- .../CaseSalesOrderOpportunityCalculator.php | 16 +++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CRM/Civicase/Service/AbstractBaseSalesOrderCalculator.php b/CRM/Civicase/Service/AbstractBaseSalesOrderCalculator.php index b1de9106c..1e9b74b2c 100644 --- a/CRM/Civicase/Service/AbstractBaseSalesOrderCalculator.php +++ b/CRM/Civicase/Service/AbstractBaseSalesOrderCalculator.php @@ -1,9 +1,11 @@ totalInvoicedAmount > 0)) { - return $this->getValueFromOptionValues(parent::INVOICING_STATUS_NO_INVOICES, $this->invoicingStatusOptionValues); + return $this->getLabelFromOptionValues(parent::INVOICING_STATUS_NO_INVOICES, $this->invoicingStatusOptionValues); } if ($this->totalInvoicedAmount < $this->totalQuotedAmount) { - return $this->getValueFromOptionValues(parent::INVOICING_STATUS_PARTIALLY_INVOICED, $this->invoicingStatusOptionValues); + return $this->getLabelFromOptionValues(parent::INVOICING_STATUS_PARTIALLY_INVOICED, $this->invoicingStatusOptionValues); } - return $this->getValueFromOptionValues(parent::INVOICING_STATUS_FULLY_INVOICED, $this->invoicingStatusOptionValues); + return $this->getLabelFromOptionValues(parent::INVOICING_STATUS_FULLY_INVOICED, $this->invoicingStatusOptionValues); } /** @@ -101,19 +101,19 @@ public function calculateInvoicingStatus() { */ public function calculatePaymentStatus() { if (!($this->totalPaidAmount > 0)) { - return $this->getValueFromOptionValues(parent::PAYMENT_STATUS_NO_PAYMENTS, $this->paymentStatusOptionValues); + return $this->getLabelFromOptionValues(parent::PAYMENT_STATUS_NO_PAYMENTS, $this->paymentStatusOptionValues); } if ($this->totalPaidAmount < $this->totalInvoicedAmount) { - return $this->getValueFromOptionValues(parent::PAYMENT_STATUS_PARTIALLY_PAID, $this->paymentStatusOptionValues); + return $this->getLabelFromOptionValues(parent::PAYMENT_STATUS_PARTIALLY_PAID, $this->paymentStatusOptionValues); } if ($this->totalPaidAmount > $this->totalInvoicedAmount) { - return $this->getValueFromOptionValues(parent::PAYMENT_STATUS_OVERPAID, $this->paymentStatusOptionValues); + return $this->getLabelFromOptionValues(parent::PAYMENT_STATUS_OVERPAID, $this->paymentStatusOptionValues); } - return $this->getValueFromOptionValues(parent::PAYMENT_STATUS_FULLY_PAID, $this->paymentStatusOptionValues); + return $this->getLabelFromOptionValues(parent::PAYMENT_STATUS_FULLY_PAID, $this->paymentStatusOptionValues); } /**