From 2adbdc876513204610e30357e62e0fa00bc79b04 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 31 Mar 2023 00:25:51 +0200 Subject: [PATCH] fix login bugs --- Controller/ApiBillController.php | 30 ++++++++++++++++++++++++++++-- Controller/ApiTaxController.php | 10 ++++++++++ Controller/CliController.php | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Controller/ApiBillController.php b/Controller/ApiBillController.php index f491fa5..4ae2e9a 100755 --- a/Controller/ApiBillController.php +++ b/Controller/ApiBillController.php @@ -154,6 +154,16 @@ final class ApiBillController extends Controller $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Bill', 'Bill successfully created.', $bill); } + /** + * Create a new database entry for a Bill object and update its bill number + * + * @param Bill $bill The Bill object to create a database entry for and update its bill number + * @param RequestAbstract $request The request object that contains the header account and origin + * + * @return void + * + * @since 1.0.0 + */ public function createBillDatabaseEntry(Bill $bill, RequestAbstract $request) : void { $this->createModel($request->header->account, $bill, BillMapper::class, 'bill', $request->getOrigin()); @@ -163,6 +173,22 @@ final class ApiBillController extends Controller $this->updateModel($request->header->account, $bill, $new, BillMapper::class, 'bill', $request->getOrigin()); } + /** + * Create a base Bill object with default values + * + * @param Client $client The client object for whom the bill is being created + * @param RequestAbstract $request The request object that contains the header account + * + * @return Bill The new Bill object with default values + * + * @todo Validate VAT before creation + * @todo Set the correct date of payment + * @todo Use bill and shipping address instead of main address if available + * @todo Implement allowed invoice languages and a default invoice language if none match + * @todo Implement client invoice language (allowing for different invoice languages than invoice address) + * + * @since 1.0.0 + */ public function createBaseBill(Client $client, RequestAbstract $request) : Bill { // @todo: validate vat before creation @@ -177,7 +203,7 @@ final class ApiBillController extends Controller $bill->payment = 0; $bill->paymentText = ''; - + // @todo: use bill and shipping address instead of main address if available $bill->client = $client; $bill->billTo = $client->account->name1; @@ -192,7 +218,7 @@ final class ApiBillController extends Controller // @todo implement client invoice langage (this would allow invoice langauges which are different from the invoice address) $bill->setLanguage( !\in_array( - $client->mainAddress->getCountry(), + $client->mainAddress->getCountry(), [ISO3166TwoEnum::_DEU, ISO3166TwoEnum::_AUT] ) ? ISO639x1Enum::_EN diff --git a/Controller/ApiTaxController.php b/Controller/ApiTaxController.php index 5ebea00..6ee1acb 100755 --- a/Controller/ApiTaxController.php +++ b/Controller/ApiTaxController.php @@ -105,6 +105,16 @@ final class ApiTaxController extends Controller return []; } + /** + * Get the client's tax code based on their country and tax office address + * + * @param Client $client The client to get the tax code for + * @param Address $taxOfficeAddress The tax office address used to determine the tax code + * + * @return ClientAttributeValue The client's tax code + * + * @since 1.0.0 + */ public function getClientTaxCode(Client $client, Address $taxOfficeAddress) : ClientAttributeValue { /** @var \Modules\ClientManagement\Models\ClientAttributeType $codes */ diff --git a/Controller/CliController.php b/Controller/CliController.php index 9f8188f..3a0123f 100755 --- a/Controller/CliController.php +++ b/Controller/CliController.php @@ -18,6 +18,7 @@ use Modules\Billing\Models\BillMapper; use Modules\Billing\Models\BillTypeMapper; use Modules\Billing\Models\NullBillType; use Modules\Billing\Models\SettingsEnum; +use Modules\Payment\Models\PaymentType; use Modules\SupplierManagement\Models\NullSupplier; use Modules\SupplierManagement\Models\Supplier; use Modules\SupplierManagement\Models\SupplierMapper;