diff --git a/.github/user_feature_request.md b/.github/user_feature_request.md index 6eb8ddc..c9595e8 100755 --- a/.github/user_feature_request.md +++ b/.github/user_feature_request.md @@ -8,11 +8,14 @@ assignees: '' --- # What is the feature you request + * A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] * A clear and concise description of what you want to happen. # Alternatives + A clear and concise description of any alternative solutions or features you've considered. # Additional Information + Add any other context or screenshots about the feature request here. diff --git a/Admin/Installer.php b/Admin/Installer.php index fa144ce..0ab6dde 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -63,7 +63,12 @@ final class Installer extends InstallerAbstract return; } + /** @var array $types */ $types = \json_decode($fileContent, true); + if ($types === false) { + return; + } + self::createBillTypes($app, $types, $defaultTemplate); /* Tax types */ @@ -72,7 +77,12 @@ final class Installer extends InstallerAbstract return; } + /** @var array $taxes */ $taxes = \json_decode($fileContent, true); + if ($taxes === false) { + return; + } + self::createTaxCombination($app, $taxes); /* Attributes */ @@ -81,7 +91,12 @@ final class Installer extends InstallerAbstract return; } + /** @var array $attributes */ $attributes = \json_decode($fileContent, true); + if ($attributes === false) { + return; + } + $attrTypes = self::createBillAttributeTypes($app, $attributes); $attrValues = self::createBillAttributeValues($app, $attrTypes, $attributes); } diff --git a/Controller/ApiBillController.php b/Controller/ApiBillController.php index 4f9c799..3ea2e0f 100755 --- a/Controller/ApiBillController.php +++ b/Controller/ApiBillController.php @@ -205,7 +205,6 @@ final class ApiBillController extends Controller $bill->payment = 0; $bill->paymentText = ''; - /** @var \Modules\Billing\Modles\BillType */ $bill->type = BillTypeMapper::get() ->where('name', 'sales_invoice') ->execute(); @@ -245,9 +244,9 @@ final class ApiBillController extends Controller ]; } - $billLanguage = $validLanguages[0]; + $billLanguage = $validLanguages[0] ?? ISO639x1Enum::_EN; - $clientBillLanguage = $client->getAttribute('bill_language')?->value->getValue(); + $clientBillLanguage = $client->getAttribute('bill_language')?->value->valueStr; if (!empty($clientBillLanguage) && \in_array($clientBillLanguage, $validLanguages)) { $billLanguage = $clientBillLanguage; } else { @@ -330,18 +329,16 @@ final class ApiBillController extends Controller $bill = new Bill(); $bill->createdBy = new NullAccount($request->header->account); $bill->type = $billType; - $bill->billTo = (string) ($request->getDataString('billto') - ?? ($account->account->name1 . (!empty($account->account->name2) + $bill->billTo = $request->getDataString('billto') ?? ( + $account->account->name1 . (!empty($account->account->name2) ? ', ' . $account->account->name2 : '' - ))); + )); $bill->billAddress = (string) ($request->getDataString('billaddress') ?? $account->mainAddress->address); $bill->billZip = (string) ($request->getDataString('billtopostal') ?? $account->mainAddress->postal); $bill->billCity = (string) ($request->getDataString('billtocity') ?? $account->mainAddress->city); - $bill->billCountry = (string) ( - $request->getDataString('billtocountry') ?? ( - ($country = $account->mainAddress->getCountry()) === ISO3166TwoEnum::_XXX ? '' : $country) - ); + $bill->billCountry = $request->getDataString('billtocountry') ?? ( + ($country = $account->mainAddress->getCountry()) === ISO3166TwoEnum::_XXX ? '' : $country); $bill->client = !$request->hasData('client') ? null : $account; $bill->supplier = !$request->hasData('supplier') ? null : $account; $bill->performanceDate = $request->getDataDateTime('performancedate') ?? new \DateTime('now'); @@ -933,7 +930,7 @@ final class ApiBillController extends Controller } $model = $response->get($request->uri->__toString())['response']; - $this->createModelRelation($request->header->account, $request->getData('id'), $model->getId(), BillMapper::class, 'bill_note', '', $request->getOrigin()); + $this->createModelRelation($request->header->account, $request->getDataInt('id'), $model->getId(), BillMapper::class, 'bill_note', '', $request->getOrigin()); } /** diff --git a/Controller/ApiPriceController.php b/Controller/ApiPriceController.php index 87b1193..52c10d3 100755 --- a/Controller/ApiPriceController.php +++ b/Controller/ApiPriceController.php @@ -84,7 +84,7 @@ final class ApiPriceController extends Controller $supplier = null; if ($request->hasData('price_client')) { - /** @var null|\Modules\ClientManagement\Models\Client $client */ + /** @var \Modules\ClientManagement\Models\Client $client */ $client = ClientMapper::get() ->with('attributes') ->with('attributes/type') @@ -92,10 +92,10 @@ final class ApiPriceController extends Controller ->where('id', (int) $request->getData('price_client')) ->execute(); - /** @var null|\Modules\ClientManagement\Models\Client|\Modules\SupplierManagement\Models\Supplier $account */ + /** @var \Modules\ClientManagement\Models\Client */ $account = $client; } else { - /** @var null|\Modules\SupplierManagement\Models\Supplier $supplier */ + /** @var \Modules\SupplierManagement\Models\Supplier $supplier */ $supplier = SupplierMapper::get() ->with('attributes') ->with('attributes/type') @@ -103,7 +103,7 @@ final class ApiPriceController extends Controller ->where('id', (int) $request->getData('price_supplier')) ->execute(); - /** @var null|\Modules\ClientManagement\Models\Client|\Modules\SupplierManagement\Models\Supplier $account */ + /** @var \Modules\SupplierManagement\Models\Supplier $account */ $account = $supplier; } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 3abcdd3..1121c3d 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -126,13 +126,15 @@ final class BackendController extends Controller $view->setData('bill', $bill); + /** @var \Modules\Auditor\Models\Auditor[] $logsBill */ $logsBill = AuditMapper::getAll() - ->with('createdBy') - ->where('module', 'Billing') - ->where('type', StringUtils::intHash(BillMapper::class)) - ->where('ref', $bill->getId()) - ->execute(); + ->with('createdBy') + ->where('module', 'Billing') + ->where('type', StringUtils::intHash(BillMapper::class)) + ->where('ref', $bill->getId()) + ->execute(); + /** @var \Modules\Auditor\Models\Auditor[] $logsElements */ $logsElements = AuditMapper::getAll() ->with('createdBy') ->where('module', 'Billing') diff --git a/Models/Attribute/BillAttributeMapper.php b/Models/Attribute/BillAttributeMapper.php index 09fd5c4..519ef42 100755 --- a/Models/Attribute/BillAttributeMapper.php +++ b/Models/Attribute/BillAttributeMapper.php @@ -24,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Attribute + * @extends DataMapperFactory */ final class BillAttributeMapper extends DataMapperFactory { @@ -60,7 +63,7 @@ final class BillAttributeMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = Attribute::class; diff --git a/Models/Attribute/BillAttributeTypeL11nMapper.php b/Models/Attribute/BillAttributeTypeL11nMapper.php index daa4aed..f2e9761 100755 --- a/Models/Attribute/BillAttributeTypeL11nMapper.php +++ b/Models/Attribute/BillAttributeTypeL11nMapper.php @@ -24,6 +24,9 @@ use phpOMS\Localization\BaseStringL11n; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of BaseStringL11n + * @extends DataMapperFactory */ final class BillAttributeTypeL11nMapper extends DataMapperFactory { @@ -59,7 +62,7 @@ final class BillAttributeTypeL11nMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = BaseStringL11n::class; diff --git a/Models/Attribute/BillAttributeTypeMapper.php b/Models/Attribute/BillAttributeTypeMapper.php index 64761ed..a1e71fb 100755 --- a/Models/Attribute/BillAttributeTypeMapper.php +++ b/Models/Attribute/BillAttributeTypeMapper.php @@ -24,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of AttributeType + * @extends DataMapperFactory */ final class BillAttributeTypeMapper extends DataMapperFactory { @@ -68,7 +71,7 @@ final class BillAttributeTypeMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = AttributeType::class; diff --git a/Models/Attribute/BillAttributeValueL11nMapper.php b/Models/Attribute/BillAttributeValueL11nMapper.php index a0748a4..515dc7d 100755 --- a/Models/Attribute/BillAttributeValueL11nMapper.php +++ b/Models/Attribute/BillAttributeValueL11nMapper.php @@ -24,6 +24,9 @@ use phpOMS\Localization\BaseStringL11n; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of BaseStringL11n + * @extends DataMapperFactory */ final class BillAttributeValueL11nMapper extends DataMapperFactory { @@ -59,7 +62,7 @@ final class BillAttributeValueL11nMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = BaseStringL11n::class; diff --git a/Models/Attribute/BillAttributeValueMapper.php b/Models/Attribute/BillAttributeValueMapper.php index 1fe664e..1dc9a9f 100755 --- a/Models/Attribute/BillAttributeValueMapper.php +++ b/Models/Attribute/BillAttributeValueMapper.php @@ -24,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of AttributeValue + * @extends DataMapperFactory */ final class BillAttributeValueMapper extends DataMapperFactory { @@ -63,7 +66,7 @@ final class BillAttributeValueMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = AttributeValue::class; diff --git a/Models/Bill.php b/Models/Bill.php index 77fd1c8..daff05d 100755 --- a/Models/Bill.php +++ b/Models/Bill.php @@ -86,10 +86,10 @@ class Bill implements \JsonSerializable /** * Bill created at. * - * @var null|\DateTime + * @var \DateTime * @since 1.0.0 */ - public ?\DateTime $billDate = null; + public \DateTime $billDate; /** * Bill created at. @@ -463,6 +463,7 @@ class Bill implements \JsonSerializable $this->netDiscount = new Money(0); $this->grossDiscount = new Money(0); + $this->billDate = new \DateTime('now'); $this->createdAt = new \DateTimeImmutable(); $this->createdBy = new NullAccount(); $this->referral = new NullAccount(); diff --git a/Models/BillElementMapper.php b/Models/BillElementMapper.php index 6e3ab4f..0e8a691 100755 --- a/Models/BillElementMapper.php +++ b/Models/BillElementMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of BillElement + * @extends DataMapperFactory */ final class BillElementMapper extends DataMapperFactory { diff --git a/Models/BillMapper.php b/Models/BillMapper.php index 55b5ef2..4bdc3c7 100755 --- a/Models/BillMapper.php +++ b/Models/BillMapper.php @@ -30,6 +30,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Bill + * @extends DataMapperFactory */ class BillMapper extends DataMapperFactory { diff --git a/Models/BillTypeL11nMapper.php b/Models/BillTypeL11nMapper.php index b7c6b73..fda1bc2 100755 --- a/Models/BillTypeL11nMapper.php +++ b/Models/BillTypeL11nMapper.php @@ -24,6 +24,9 @@ use phpOMS\Localization\BaseStringL11n; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of BaseStringL11n + * @extends DataMapperFactory */ final class BillTypeL11nMapper extends DataMapperFactory { @@ -59,7 +62,7 @@ final class BillTypeL11nMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = BaseStringL11n::class; diff --git a/Models/BillTypeMapper.php b/Models/BillTypeMapper.php index 5735b7b..1b9d4ad 100755 --- a/Models/BillTypeMapper.php +++ b/Models/BillTypeMapper.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Modules\Billing\Models; use Modules\Media\Models\CollectionMapper; -use Modules\Media\Models\MediaMapper; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; /** @@ -25,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of BillType + * @extends DataMapperFactory */ final class BillTypeMapper extends DataMapperFactory { @@ -97,7 +99,7 @@ final class BillTypeMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = BillType::class; diff --git a/Models/Price/PriceMapper.php b/Models/Price/PriceMapper.php index a9ebd83..bda26bc 100755 --- a/Models/Price/PriceMapper.php +++ b/Models/Price/PriceMapper.php @@ -14,9 +14,9 @@ declare(strict_types=1); namespace Modules\Billing\Models\Price; +use Modules\Attribute\Models\AttributeValueMapper; use Modules\ClientManagement\Models\ClientAttributeValueMapper; use Modules\ClientManagement\Models\ClientMapper; -use Modules\Attribute\Models\AttributeValueMapper; use Modules\ItemManagement\Models\ItemMapper; use Modules\SupplierManagement\Models\SupplierMapper; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; @@ -29,6 +29,9 @@ use phpOMS\Localization\Defaults\CountryMapper; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Price + * @extends DataMapperFactory */ final class PriceMapper extends DataMapperFactory { @@ -131,7 +134,7 @@ final class PriceMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = Price::class; diff --git a/Models/PurchaseBillMapper.php b/Models/PurchaseBillMapper.php index 28cda96..9c6ac7a 100755 --- a/Models/PurchaseBillMapper.php +++ b/Models/PurchaseBillMapper.php @@ -32,7 +32,7 @@ final class PurchaseBillMapper extends BillMapper /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = Bill::class; diff --git a/Models/SalesBillMapper.php b/Models/SalesBillMapper.php index bdd9bb4..3dc464e 100755 --- a/Models/SalesBillMapper.php +++ b/Models/SalesBillMapper.php @@ -32,7 +32,7 @@ final class SalesBillMapper extends BillMapper /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = Bill::class; diff --git a/Models/StockBillMapper.php b/Models/StockBillMapper.php index 1e50e47..b9ec218 100755 --- a/Models/StockBillMapper.php +++ b/Models/StockBillMapper.php @@ -29,7 +29,7 @@ final class StockBillMapper extends BillMapper /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = Bill::class; diff --git a/Models/Tax/TaxCombinationMapper.php b/Models/Tax/TaxCombinationMapper.php index dbf1c99..8494057 100755 --- a/Models/Tax/TaxCombinationMapper.php +++ b/Models/Tax/TaxCombinationMapper.php @@ -14,8 +14,8 @@ declare(strict_types=1); namespace Modules\Billing\Models\Tax; -use Modules\ClientManagement\Models\ClientAttributeValueMapper; use Modules\Attribute\Models\AttributeValueMapper; +use Modules\ClientManagement\Models\ClientAttributeValueMapper; use Modules\SupplierManagement\Models\SupplierAttributeValueMapper; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; @@ -26,6 +26,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of TaxCombination + * @extends DataMapperFactory */ final class TaxCombinationMapper extends DataMapperFactory { @@ -75,7 +78,7 @@ final class TaxCombinationMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = TaxCombination::class;