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

TypeError when creating a PurchaseTransaction when the suppliers due days are set to 0 #193

Closed edwin-easytrans closed 3 years ago

edwin-easytrans commented 3 years ago

When the due days for a supplier in Twinfield are set to 0 and you create a new purchase transaction, the following error appears: TypeError: Argument 1 passed to PhpTwinfield\PurchaseTransaction::setDueDateFromString() must be of the type string, null given.

willemstuursma commented 3 years ago

@edwin-easytrans can you post the entire stack trace or an example of your code?

edwin-easytrans commented 3 years ago

Hi Willem, Below is the stack trace:

TypeError: Argument 1 passed to PhpTwinfield\PurchaseTransaction::setDueDateFromString() must be of the type string, null given, called in /.../php-twinfield/twinfield/src/Mappers/TransactionMapper.php on line 106 and defined in /.../php-twinfield/twinfield/src/Transactions/TransactionFields/DueDateField.php:43
Stack trace:
#0 /.../php-twinfield/twinfield/src/Mappers/TransactionMapper.php(106): PhpTwinfield\PurchaseTransaction->setDueDateFromString(NULL)
#1 /.../php-twinfield/twinfield/src/ApiConnectors/TransactionApiConnector.php(100): PhpTwinfield\Mappers\TransactionMapper::map('PhpTwinfield\\Pu...', Object(PhpTwinfield\Response\Response))
#2 /.../php-twinfield/twinfield/src/Response/IndividualMappedResponse.php(62): PhpTwinfield\ApiConnectors\TransactionApiConnector->PhpTwinfield\ApiConnectors\{closure}(Object(PhpTwinfield\Response\Response))
#3 /.../php-twinfield/twinfield/src/Response/IndividualMappedResponse.php(42): PhpTwinfield\Response\IndividualMappedResponse->mapResponse()
#4 /.../php-twinfield/twinfield/src/Response/IndividualMappedResponse.php(52): PhpTwinfield\Response\IndividualMappedResponse->assertSuccessful()
#5 /.../php-twinfield/twinfield/src/ApiConnectors/TransactionApiConnector.php(62): PhpTwinfield\Response\IndividualMappedResponse->unwrap()
#6 /.../export_twinfield.php(643): PhpTwinfield\ApiConnectors\TransactionApiConnector->send(Object(PhpTwinfield\PurchaseTransaction))
#7 {main}

I'm not sending any due date or due days with the transaction. Therefore Twinfield takes the due days from the supplier. The problem occurs when this is set at 0.

Hope that helps.