Jacek Kowalski
2026-03-17 67e4ab9dfca8a5cf647b4204c6534546d029706a
Rename attribute "KSeF QR Code" to "QR Code Generator URL"
2 files modified
33 ■■■■ changed files
src/InvoiceQrCodeSynchronizer.php 29 ●●●●● patch | view | raw | blame | history
src/UcrmAttributes.php 4 ●●●● patch | view | raw | blame | history
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,
                    ],
                ],
            ]);
src/UcrmAttributes.php
@@ -23,8 +23,8 @@
            'code' => 'ksef-url',
            'type' => 'invoice',
        ],
        'KSeF QR Code' => [
            'code' => 'ksef-qr-code',
        'QR Code Generator URL' => [
            'code' => 'qr-code-gen-url',
            'type' => 'invoice',
        ],
        'wFirma Payment ID' => [