php-twinfield / twinfield

PHP 7.3+ Library for using the Twinfield API.
https://accounting.twinfield.com/webservices/documentation/#/
Other
33 stars 78 forks source link

Dimension 1 must always be entered when creating invoice. #204

Closed stefanvandekaa closed 2 years ago

stefanvandekaa commented 2 years ago

I'm trying to create an invoice in Twinfield. My test code is the following.

                    $line = new \PhpTwinfield\InvoiceLine();
                    $line
                        ->setArticle(0)
                        ->setQuantity(1)
                        ->setValueExcl(100)
                        ->setUnits(1)
                        ->setVatCode('VH')
                        ->setUnitsPriceExcl(100)
                        ->setDescription("Test invoice")
                        ->setAllowDiscountOrPremium(false);
                    //class invoice object
                    $invoice = new \PhpTwinfield\Invoice();
                    $invoice
                        ->setCustomer($customer)
                        ->setBank('BNK')
                        ->setPeriod('2021/11')
                        ->setCurrency('EUR')
                        ->setStatus('concept')
                        ->setInvoiceDate('20211129')
                        ->addLine($line)
                        ->setPaymentMethod('bank')
                        ->setInvoiceType('FACTUUR');

                    $return = $connector->send($invoice);

When i try this i get the error: Dimension 1 must always be entered When i add the part: ->setDim1(8020) to the invoiceLine, the error changes to:

Dimension 1 is read-only and must be

I guess there is something wrong in the configuration of twinfield, or i am missing something obvious. How can help me?

Jeroenwv commented 2 years ago

Hi Stefan, you are trying to create an invoice with type 'FACTUUR'. If you go to Verkoop > Facturen > Typen within Twinfield, you should see the FACTUUR type. There you should check Eenmalige artikelen [] Kan de grootboekrekening aanpassen.

I believe this should get you past the error. I'm not an accountant though, so you should check what the impact of changing this value is for you.

stefanvandekaa commented 2 years ago

Unfortunately this didn't resolve my problem. I can close the issue however. Support advised me to use the "Sales Transactions" instead of the "Sales Invoices" which is working for me now.

Thanks for the reply though 👍