From ca616aa9c2b595f61aceb26b60584c53016d0949 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Thu, 19 Mar 2026 12:28:47 +0000
Subject: [PATCH] Release version 5.0

---
 src/InvoiceQrCodeSynchronizer.php |   29 +++++++++++++----------------
 1 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/InvoiceQrCodeSynchronizer.php b/src/InvoiceQrCodeSynchronizer.php
index a782c2c..4d6ec9d 100644
--- a/src/InvoiceQrCodeSynchronizer.php
+++ b/src/InvoiceQrCodeSynchronizer.php
@@ -11,35 +11,32 @@
 
 	public function synchronize(string $ucrmInvoiceId, array $previousEntity = []): void {
 		$ksefUrlAttribute = $this->helper->getAttributes()->getIdForCode('ksef-url');
-		$ksefQrCodeAttribute = $this->helper->getAttributes()->getIdForCode('ksef-qr-code');
+		$qrCodeGenUrlAttribute = $this->helper->getAttributes()->getIdForCode('qr-code-gen-url');
 
 		$invoice = $this->helper->getApi()->get('/invoices/' . $ucrmInvoiceId);
-		$currentUrl = '';
-		$currentQrCode = '';
+		$currentKsefUrl = '';
+		$currentQrCodeGenUrl = '';
 		foreach ($invoice['attributes'] ?? [] as $attribute) {
 			if ($attribute['customAttributeId'] == $ksefUrlAttribute) {
-				$currentUrl = $attribute['value'];
+				$currentKsefUrl = $attribute['value'];
 			}
-			if ($attribute['customAttributeId'] == $ksefQrCodeAttribute) {
-				$currentQrCode = $attribute['value'];
+			if ($attribute['customAttributeId'] == $qrCodeGenUrlAttribute) {
+				$currentQrCodeGenUrl = $attribute['value'];
 			}
 		}
 
-		$newQrCode = null;
-		$expectedQrCodeUrl = $this->helper->getSelfUrl() . '_plugins/wfirma/public.php?barcode=';
-		if ($currentUrl == '' && $currentQrCode != '') {
-			$newQrCode = '';
-		}
-		if ($currentUrl != '' && $currentQrCode != $expectedQrCodeUrl) {
-			$newQrCode = $expectedQrCodeUrl;
+		$newQrCodeGenUrl = null;
+		$expectedQrCodeGenUrl = $this->helper->getSelfUrl() . '_plugins/wfirma/public.php?barcode=';
+		if ($currentQrCodeGenUrl != $expectedQrCodeGenUrl) {
+			$newQrCodeGenUrl = $expectedQrCodeGenUrl;
 		}
 
-		if ($newQrCode != null) {
+		if ($newQrCodeGenUrl != null) {
 			$this->helper->getApi()->patch('/invoices/' . $ucrmInvoiceId, [
 				'attributes' => [
 					[
-						'customAttributeId' => $ksefQrCodeAttribute,
-						'value' => $newQrCode,
+						'customAttributeId' => $qrCodeGenUrlAttribute,
+						'value' => $newQrCodeGenUrl,
 					],
 				],
 			]);

--
Gitblit v1.10.0