From 67e4ab9dfca8a5cf647b4204c6534546d029706a Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Tue, 17 Mar 2026 09:29:49 +0000
Subject: [PATCH] Rename attribute "KSeF QR Code" to "QR Code Generator URL"
---
src/PaymentSynchronizer.php | 55 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 39 insertions(+), 16 deletions(-)
diff --git a/src/PaymentSynchronizer.php b/src/PaymentSynchronizer.php
index c924d27..6351e70 100644
--- a/src/PaymentSynchronizer.php
+++ b/src/PaymentSynchronizer.php
@@ -2,32 +2,22 @@
namespace SIPL\UCRM\wFirma;
-use \Webit\WFirmaSDK\Invoices as Invoices;
-use \Webit\WFirmaSDK\Payments as Payments;
+use Webit\WFirmaSDK\Invoices as Invoices;
+use Webit\WFirmaSDK\Payments as Payments;
-class PaymentSynchronizer {
- protected $wfirma;
- protected $helper;
- protected $ucrmMainDir;
-
+class PaymentSynchronizer extends Synchronizer {
function __construct(\Webit\WFirmaSDK\Entity\ModuleApiFactory $wFirmaApi, UcrmHelper $ucrmHelper) {
- $this->wfirma = $wFirmaApi;
- $this->helper = $ucrmHelper;
-
- $backtrace = debug_backtrace();
- $backtrace = end($backtrace);
- // (...)/web/_plugins/wfirma/public.php
- $this->ucrmMainDir = dirname(dirname(dirname(dirname($backtrace['file']))));
+ parent::__construct($wFirmaApi, $ucrmHelper);
}
- function comparePayment(Payments\Payment $p1, Payments\Payment $p2) {
+ function comparePayment(Payments\Payment $p1, Payments\Payment $p2): int {
return
[$p1->objectName(), $p1->objectId(), $p1->amount()->value(), $p1->date()->format('Y-m-d'), $p1->paymentMethod()]
<=>
[$p2->objectName(), $p2->objectId(), $p2->amount()->value(), $p2->date()->format('Y-m-d'), $p2->paymentMethod()];
}
- function synchronize($ucrmPaymentId) {
+ function synchronize(int $ucrmPaymentId): bool {
$crm = $this->helper->getApi();
$wFirmaPaymentsApi = $this->wfirma->paymentsApi();
@@ -173,4 +163,37 @@
return $changed;
}
+
+ function delete(array $paymentData): bool {
+ $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