From 14d3eeddc827c7d822ecbc7b371b13cb3e9ac108 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Wed, 14 Jun 2023 10:56:01 +0000
Subject: [PATCH] Fixes for UCRM 4.0
---
src/PaymentSynchronizer.php | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/src/PaymentSynchronizer.php b/src/PaymentSynchronizer.php
index 5ee347f..f6f190a 100644
--- a/src/PaymentSynchronizer.php
+++ b/src/PaymentSynchronizer.php
@@ -170,4 +170,37 @@
return $changed;
}
+
+ function delete(array $paymentData) {
+ $wFirmaPaymentsApi = $this->wfirma->paymentsApi();
+ $paymentAttributeId = $this->helper->getAttributes()->getIdForCode('payment');
+
+ $wFirmaIds = '';
+ foreach ($paymentData['attributes'] as $attribute) {
+ if ($attribute['customAttributeId'] === $paymentAttributeId) {
+ $wFirmaIds = $attribute['value'];
+ }
+ }
+ if (strlen($wFirmaIds) > 0) {
+ $wFirmaIds = explode(',', $wFirmaIds);
+ } else {
+ $wFirmaIds = [];
+ }
+
+ $changed = FALSE;
+
+ foreach($wFirmaIds as $wFirmaId) {
+ try {
+ $payment = $wFirmaPaymentsApi->get(
+ Payments\PaymentId::create($wFirmaId)
+ );
+ $wFirmaPaymentsApi->delete($payment->id());
+ $changed = TRUE;
+ } catch(\Webit\WFirmaSDK\Entity\Exception\NotFoundException $e) {
+ // do nothing
+ }
+ }
+
+ return $changed;
+ }
}
--
Gitblit v1.10.0