From 88ee85212f2faba01c77caeda47fc6be613e6640 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 6 May 2023 11:42:05 +0000 Subject: [PATCH] make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ... --- Admin/Install/Media/bill.pdf.php | 18 +++- Admin/Install/db.json | 5 ++ Admin/Installer.php | 6 +- Controller/ApiAttributeController.php | 2 +- Controller/ApiBillController.php | 38 ++++---- Controller/ApiPriceController.php | 45 +++++----- Controller/ApiPurchaseController.php | 4 +- Controller/ApiTaxController.php | 12 +-- Controller/BackendController.php | 2 +- Controller/CliController.php | 14 +-- Models/Bill.php | 66 +++++++------- Models/BillElement.php | 87 +++++++++---------- Models/BillType.php | 4 +- Models/BillTypeMapper.php | 1 + Models/Price/Price.php | 7 +- Models/Price/PriceMapper.php | 2 +- Models/PurchaseBillMapper.php | 18 ++-- Models/SalesBillMapper.php | 18 ++-- Models/Subscription.php | 2 +- Models/Tax/TaxCombination.php | 2 +- Theme/Backend/bill-create.tpl.php | 16 ++-- Theme/Backend/purchase-bill-list.tpl.php | 4 +- Theme/Backend/purchase-bill.tpl.php | 16 ++-- Theme/Backend/sales-bill-list.tpl.php | 8 +- .../user-purchase-bill-dashboard.tpl.php | 4 +- Theme/Backend/user-purchase-bill.tpl.php | 16 ++-- tests/Controller/ApiControllerTest.php | 12 +-- tests/Models/BillElementTest.php | 2 +- tests/Models/BillTest.php | 6 +- tests/Models/BillTypeTest.php | 2 +- tests/Models/NullBillElementTest.php | 2 +- tests/Models/NullBillTest.php | 2 +- tests/Models/NullBillTypeTest.php | 2 +- 33 files changed, 232 insertions(+), 213 deletions(-) diff --git a/Admin/Install/Media/bill.pdf.php b/Admin/Install/Media/bill.pdf.php index 4b29464..41e4829 100755 --- a/Admin/Install/Media/bill.pdf.php +++ b/Admin/Install/Media/bill.pdf.php @@ -14,6 +14,7 @@ declare(strict_types=1); use Modules\Billing\Models\NullBill; use phpOMS\Localization\ISO3166NameEnum; +use phpOMS\Localization\Money; /** @var \phpOMS\Views\View $this */ require_once $this->getData('defaultTemplates') @@ -202,9 +203,12 @@ foreach($lines as $line) { $pdf->writeHTMLCell($w[0], 10, null, null, $line->itemNumber . ' ' . $line->itemName, 0, 2, $fill); $height = $pdf->getY() - $tempY; + $singleSalesPriceNet = Money::fromFloatInt($line->singleSalesPriceNet); + $totalSalesPriceNet = Money::fromFloatInt($line->totalSalesPriceNet); + $pdf->MultiCell($w[1], $height, $line->getQuantity(), 0, 'L', $fill, 0, 15 + $w[0], $tempY, true, 0, false, true, 0, 'M', true); - $pdf->MultiCell($w[2], $height, $line->singleSalesPriceNet->getCurrency(2, symbol: ''), 0, 'L', $fill, 0, 15 + $w[0] + $w[1], $tempY, true, 0, false, true, 0, 'M', true); - $pdf->MultiCell($w[3], $height, $line->totalSalesPriceNet->getCurrency(2, symbol: ''), 0, 'L', $fill, 1, 15 + $w[0] + $w[1] + $w[2], $tempY, true, 0, false, true, 0, 'M', true); + $pdf->MultiCell($w[2], $height, $singleSalesPriceNet->getCurrency(2, symbol: ''), 0, 'L', $fill, 0, 15 + $w[0] + $w[1], $tempY, true, 0, false, true, 0, 'M', true); + $pdf->MultiCell($w[3], $height, $totalSalesPriceNet->getCurrency(2, symbol: ''), 0, 'L', $fill, 1, 15 + $w[0] + $w[1] + $w[2], $tempY, true, 0, false, true, 0, 'M', true); $fill = !$fill; @@ -230,12 +234,16 @@ $pdf->setFont('helvetica', 'B', 8); $tempY = $pdf->getY(); +$netSales = Money::fromFloatInt($bill->netSales); + $pdf->setX($w[0] + $w[1] + 15); $pdf->Cell($w[2], 7, $lang[$pdf->language]['Subtotal'], 0, 0, 'L', false); -$pdf->Cell($w[3], 7, $bill->netSales->getCurrency(2, symbol: ''), 0, 0, 'L', false); +$pdf->Cell($w[3], 7, $netSales->getCurrency(2, symbol: ''), 0, 0, 'L', false); $pdf->Ln(); foreach ($taxes as $rate => $tax) { + $tax = Money::fromFloatInt($tax); + $pdf->setX($w[0] + $w[1] + 15); $pdf->Cell($w[2], 7, $lang[$pdf->language]['Taxes'] . ' (' . $rate . '%)', 0, 0, 'L', false); $pdf->Cell($w[3], 7, $tax->getCurrency(2, symbol: ''), 0, 0, 'L', false); @@ -249,9 +257,11 @@ $pdf->setTextColor(255); $pdf->setDrawColor(255, 162, 7); $pdf->setFont('helvetica', 'B', 8); +$grossSales = Money::fromFloatInt($bill->grossSales); + $pdf->setX($w[0] + $w[1] + 15); $pdf->Cell($w[2], 7, \strtoupper($lang[$pdf->language]['Total']), 1, 0, 'L', true); -$pdf->Cell($w[3], 7, $bill->grossSales->getCurrency(2, symbol: ''), 1, 0, 'L', true); +$pdf->Cell($w[3], 7, $grossSales->getCurrency(2, symbol: ''), 1, 0, 'L', true); $pdf->Ln(); $tempY2 = $pdf->getY(); diff --git a/Admin/Install/db.json b/Admin/Install/db.json index b30421e..71460d9 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -312,6 +312,11 @@ "type": "TINYINT(1)", "null": false }, + "billing_type_account_format": { + "name": "billing_type_account_format", + "type": "VARCHAR(255)", + "null": false + }, "billing_type_is_template": { "description": "What kind of bill is it?", "name": "billing_type_is_template", diff --git a/Admin/Installer.php b/Admin/Installer.php index c830b2a..6d8145b 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -130,7 +130,7 @@ final class Installer extends InstallerAbstract $request->setData('title', \reset($attribute['l11n'])); $request->setData('language', \array_keys($attribute['l11n'])[0] ?? 'en'); $request->setData('is_required', $attribute['is_required'] ?? false); - $request->setData('is_custom_allowed', $attribute['is_custom_allowed'] ?? false); + $request->setData('custom', $attribute['is_custom_allowed'] ?? false); $request->setData('validation_pattern', $attribute['validation_pattern'] ?? ''); $request->setData('datatype', (int) $attribute['value_type']); @@ -289,8 +289,8 @@ final class Installer extends InstallerAbstract $request->header->account = 1; $request->setData('tax_type', $tax['type']); $request->setData('tax_code', $tax['tax_code']); - $request->setData('item_code', $itemValue->getId()); - $request->setData('account_code', $accountValue->getId()); + $request->setData('item_code', $itemValue->id); + $request->setData('account_code', $accountValue->id); $module->apiTaxCombinationCreate($request, $response); diff --git a/Controller/ApiAttributeController.php b/Controller/ApiAttributeController.php index e2f4395..3a11691 100755 --- a/Controller/ApiAttributeController.php +++ b/Controller/ApiAttributeController.php @@ -290,7 +290,7 @@ final class ApiAttributeController extends Controller $this->createModelRelation( $request->header->account, (int) $request->getData('type'), - $attrValue->getId(), + $attrValue->id, BillAttributeTypeMapper::class, 'defaults', '', $request->getOrigin() ); } diff --git a/Controller/ApiBillController.php b/Controller/ApiBillController.php index 51e2345..5e6d4e1 100755 --- a/Controller/ApiBillController.php +++ b/Controller/ApiBillController.php @@ -172,7 +172,7 @@ final class ApiBillController extends Controller // @todo: consider to remove the trigger and select the latest bill here and add + 1 to the new sequence since we have to tdo an update anyways /** @var Bill $bill */ $tmp = BillMapper::get() - ->where('id', $bill->getId()) + ->where('id', $bill->id) ->execute(); $bill->sequence = $tmp->sequence; @@ -256,7 +256,7 @@ final class ApiBillController extends Controller $billLanguage = $validLanguages[0] ?? ISO639x1Enum::_EN; - $clientBillLanguage = $client->getAttribute('bill_language')?->value->valueStr; + $clientBillLanguage = $client->getAttribute('bill_language')->value->valueStr; if (!empty($clientBillLanguage) && \in_array($clientBillLanguage, $validLanguages)) { $billLanguage = $clientBillLanguage; } else { @@ -293,7 +293,7 @@ final class ApiBillController extends Controller $item, $taxCode, $request->getDataInt('quantity') ?? 1, - $bill->getId() + $bill->id ); return $element; @@ -430,8 +430,8 @@ final class ApiBillController extends Controller foreach ($uploaded as $media) { $this->createModelRelation( $request->header->account, - $bill->getId(), - $media->getId(), + $bill->id, + $media->id, BillMapper::class, 'media', '', @@ -441,7 +441,7 @@ final class ApiBillController extends Controller if ($request->hasData('type')) { $this->createModelRelation( $request->header->account, - $media->getId(), + $media->id, $request->getDataInt('type'), MediaMapper::class, 'types', @@ -453,7 +453,7 @@ final class ApiBillController extends Controller if ($collection === null) { $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); - if ($collection instanceof NullCollection) { + if ($collection->id === 0) { $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( $path, $request->header->account, @@ -464,8 +464,8 @@ final class ApiBillController extends Controller $this->createModelRelation( $request->header->account, - $collection->getId(), - $media->getId(), + $collection->id, + $media->id, CollectionMapper::class, 'sources', '', @@ -478,7 +478,7 @@ final class ApiBillController extends Controller foreach ($mediaFiles as $media) { $this->createModelRelation( $request->header->account, - $bill->getId(), + $bill->id, (int) $media, BillMapper::class, 'media', @@ -510,7 +510,7 @@ final class ApiBillController extends Controller . $bill->createdAt->format('Y') . '/' . $bill->createdAt->format('m') . '/' . $bill->createdAt->format('d') . '/' - . $bill->getId(); + . $bill->id; } /** @@ -602,7 +602,7 @@ final class ApiBillController extends Controller ->execute(); $element = $this->createBaseBillElement($bill->client, $item, $bill, $request); - $element->bill = $bill->getId(); + $element->bill = $bill->id; // discounts if ($request->getData('discount_percentage') !== null) { @@ -661,7 +661,7 @@ final class ApiBillController extends Controller $billTypeId = $request->getData('bill_type', 'int'); if (empty($billTypeId)) { - $billTypeId = $bill->type->getId(); + $billTypeId = $bill->type->id; } if (empty($billTypeId)) { @@ -674,7 +674,7 @@ final class ApiBillController extends Controller ->where('id', $billTypeId) ->execute(); - $templateId = $billType->defaultTemplate?->getId(); + $templateId = $billType->defaultTemplate?->id; } /** @var \Modules\Media\Models\Collection $template */ @@ -799,14 +799,14 @@ final class ApiBillController extends Controller $templateId = $request->getDataInt('bill_template'); if ($templateId === null) { - $billTypeId = $bill->type->getId(); + $billTypeId = $bill->type->id; /** @var \Modules\Billing\Models\BillType $billType */ $billType = BillTypeMapper::get() ->where('id', $billTypeId) ->execute(); - $templateId = $billType->defaultTemplate?->getId(); + $templateId = $billType->defaultTemplate?->id; } /** @var \Modules\Media\Models\Collection $template */ @@ -903,8 +903,8 @@ final class ApiBillController extends Controller $this->createModelRelation( $request->header->account, - $bill->getId(), - $media->getId(), + $bill->id, + $media->id, BillMapper::class, 'media', '', @@ -954,7 +954,7 @@ final class ApiBillController extends Controller } $model = $response->get($request->uri->__toString())['response']; - $this->createModelRelation($request->header->account, $request->getDataInt('id'), $model->getId(), BillMapper::class, 'bill_note', '', $request->getOrigin()); + $this->createModelRelation($request->header->account, $request->getDataInt('id'), $model->id, BillMapper::class, 'bill_note', '', $request->getOrigin()); } /** diff --git a/Controller/ApiPriceController.php b/Controller/ApiPriceController.php index 52c10d3..e828dcc 100755 --- a/Controller/ApiPriceController.php +++ b/Controller/ApiPriceController.php @@ -33,6 +33,7 @@ use phpOMS\Message\NotificationLevel; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Model\Message\FormValidation; +use phpOMS\Stdlib\Base\FloatInt; use phpOMS\System\MimeType; /** @@ -118,16 +119,16 @@ final class ApiPriceController extends Controller $queryMapper->where('promocode', \array_unique([$request->getData('price_promocode'), null]), 'IN'); $queryMapper->where('item', \array_unique([$request->getData('price_item', 'int'), null]), 'IN'); - $queryMapper->where('itemgroup', \array_unique([$request->getData('price_itemgroup', 'int'), $item?->getAttribute('itemgroup')?->getId(), null]), 'IN'); - $queryMapper->where('itemsegment', \array_unique([$request->getData('price_itemsegment', 'int'), $item?->getAttribute('itemsegment')?->getId(), null]), 'IN'); - $queryMapper->where('itemsection', \array_unique([$request->getData('price_itemsection', 'int'), $item?->getAttribute('itemsection')?->getId(), null]), 'IN'); - $queryMapper->where('itemtype', \array_unique([$request->getData('price_itemtype', 'int'), $item?->getAttribute('itemtype')?->getId(), null]), 'IN'); + $queryMapper->where('itemgroup', \array_unique([$request->getData('price_itemgroup', 'int'), $item?->getAttribute('itemgroup')->id, null]), 'IN'); + $queryMapper->where('itemsegment', \array_unique([$request->getData('price_itemsegment', 'int'), $item?->getAttribute('itemsegment')->id, null]), 'IN'); + $queryMapper->where('itemsection', \array_unique([$request->getData('price_itemsection', 'int'), $item?->getAttribute('itemsection')->id, null]), 'IN'); + $queryMapper->where('itemtype', \array_unique([$request->getData('price_itemtype', 'int'), $item?->getAttribute('itemtype')->id, null]), 'IN'); $queryMapper->where('client', \array_unique([$request->getData('price_client', 'int'), null]), 'IN'); - $queryMapper->where('clientgroup', \array_unique([$request->getData('price_clientgroup', 'int'), $client?->getAttribute('clientgroup')?->getId(), null]), 'IN'); - $queryMapper->where('clientsegment', \array_unique([$request->getData('price_clientsegment', 'int'), $client?->getAttribute('clientsegment')?->getId(), null]), 'IN'); - $queryMapper->where('clientsection', \array_unique([$request->getData('price_clientsection', 'int'), $client?->getAttribute('clientsection')?->getId(), null]), 'IN'); - $queryMapper->where('clienttype', \array_unique([$request->getData('price_clienttype', 'int'), $client?->getAttribute('clienttype')?->getId(), null]), 'IN'); + $queryMapper->where('clientgroup', \array_unique([$request->getData('price_clientgroup', 'int'), $client?->getAttribute('clientgroup')->id, null]), 'IN'); + $queryMapper->where('clientsegment', \array_unique([$request->getData('price_clientsegment', 'int'), $client?->getAttribute('clientsegment')->id, null]), 'IN'); + $queryMapper->where('clientsection', \array_unique([$request->getData('price_clientsection', 'int'), $client?->getAttribute('clientsection')->id, null]), 'IN'); + $queryMapper->where('clienttype', \array_unique([$request->getData('price_clienttype', 'int'), $client?->getAttribute('clienttype')->id, null]), 'IN'); $queryMapper->where('clientcountry', \array_unique([$request->getData('price_clientcountry'), $client?->mainAddress->getCountry(), null]), 'IN'); $queryMapper->where('supplier', \array_unique([$request->getData('price_supplier', 'int'), null]), 'IN'); @@ -155,16 +156,16 @@ final class ApiPriceController extends Controller $bestBasePrice = null; foreach ($prices as $price) { if ($price->price !== 0 && $price->priceNew === 0 - && $price->item->getId() !== 0 - && $price->itemgroup->getId() === 0 - && $price->itemsegment->getId() === 0 - && $price->itemsection->getId() === 0 - && $price->itemtype->getId() === 0 - && $price->client->getId() === 0 - && $price->clientgroup->getId() === 0 - && $price->clientsegment->getId() === 0 - && $price->clientsection->getId() === 0 - && $price->clienttype->getId() === 0 + && $price->item->id !== 0 + && $price->itemgroup->id === 0 + && $price->itemsegment->id === 0 + && $price->itemsection->id === 0 + && $price->itemtype->id === 0 + && $price->client->id === 0 + && $price->clientgroup->id === 0 + && $price->clientsegment->id === 0 + && $price->clientsection->id === 0 + && $price->clienttype->id === 0 && $price->promocode === '' ) { if ($price->price < ($bestBasePrice?->price ?? \PHP_INT_MAX)) { @@ -208,11 +209,11 @@ final class ApiPriceController extends Controller $tax = ($request->getDataInt('price_type') ?? PriceType::SALES) === PriceType::SALES ? TaxCombinationMapper::get() ->where('itemCode', $request->getDataInt('price_item')) - ->where('clientCode', $account->getAttribute('client_code')?->value->getId()) + ->where('clientCode', $account->getAttribute('client_code')->value->id) ->execute() : TaxCombinationMapper::get() ->where('itemCode', $request->getDataInt('price_item')) - ->where('supplierCode', $account->getAttribute('supplier_code')?->value->getId()) + ->where('supplierCode', $account->getAttribute('supplier_code')->value->id) ->execute(); $response->header->set('Content-Type', MimeType::M_JSON, true); @@ -281,8 +282,8 @@ final class ApiPriceController extends Controller $price->unit = (int) $request->getData('unit'); $price->type = $request->getDataInt('type') ?? PriceType::SALES; $price->quantity = (int) $request->getData('quantity'); - $price->price = (int) $request->getData('price'); - $price->priceNew = (int) $request->getData('price_name'); + $price->price = new FloatInt((int) $request->getData('price')); + $price->priceNew = (int) $request->getData('price_new'); $price->discount = (int) $request->getData('discount'); $price->discountPercentage = (int) $request->getData('discountPercentage'); $price->bonus = (int) $request->getData('bonus'); diff --git a/Controller/ApiPurchaseController.php b/Controller/ApiPurchaseController.php index 1c70c98..69df96f 100755 --- a/Controller/ApiPurchaseController.php +++ b/Controller/ApiPurchaseController.php @@ -73,14 +73,14 @@ final class ApiPurchaseController extends Controller $billRequest->header->l11n = $request->header->l11n; $billRequest->setData('supplier', 0); $billRequest->setData('status', BillStatus::UNPARSED); - $billRequest->setData('type', $purchaseTransferType->getId()); + $billRequest->setData('type', $purchaseTransferType->id); $billResponse = new HttpResponse(); $billResponse->header->l11n = $response->header->l11n; $this->app->moduleManager->get('Billing', 'Api')->apiBillCreate($billRequest, $billResponse, $data); - $billId = $billResponse->get('')['response']->getId(); + $billId = $billResponse->get('')['response']->id; // Upload and assign document to bill $mediaRequest = new HttpRequest(); diff --git a/Controller/ApiTaxController.php b/Controller/ApiTaxController.php index d029c2a..2bff250 100755 --- a/Controller/ApiTaxController.php +++ b/Controller/ApiTaxController.php @@ -62,8 +62,8 @@ final class ApiTaxController extends Controller // @todo: consider to actually use a ownsOne reference instead of only a string, this way the next line with the TaxCodeMapper can be removed /** @var \Modules\Billing\Models\Tax\TaxCombination $taxCombination */ $taxCombination = TaxCombinationMapper::get() - ->where('itemCode', $item->getAttribute('sales_tax_code')?->value->getId()) - ->where('clientCode', $client->getAttribute('sales_tax_code')?->value->getId()) + ->where('itemCode', $item->getAttribute('sales_tax_code')->value->id) + ->where('clientCode', $client->getAttribute('sales_tax_code')->value->id) ->execute(); /** @var \Modules\Finance\Models\TaxCode $taxCode */ @@ -72,7 +72,7 @@ final class ApiTaxController extends Controller ->execute(); // If now tax code could be found, the local tax code should be used. - if ($taxCode instanceof NullTaxCode) { + if ($taxCode->id === 0) { /** @var \Modules\Organization\Models\Unit $unit */ $unit = UnitMapper::get() ->with('mainAddress') @@ -91,8 +91,8 @@ final class ApiTaxController extends Controller /** @var \Modules\Billing\Models\Tax\TaxCombination $taxCombination */ $taxCombination = TaxCombinationMapper::get() - ->where('itemCode', $item->getAttribute('sales_tax_code')?->value->getId()) - ->where('clientCode', $taxCodeAttribute->getId()) + ->where('itemCode', $item->getAttribute('sales_tax_code')->value->id) + ->where('clientCode', $taxCodeAttribute->id) ->execute(); /** @var \Modules\Finance\Models\TaxCode $taxCode */ @@ -203,7 +203,7 @@ final class ApiTaxController extends Controller } elseif (\in_array($taxOfficeAddress->getCountry(), ISO3166CharEnum::getRegion('eu')) && \in_array($client->mainAddress->getCountry(), ISO3166CharEnum::getRegion('eu')) ) { - if (!empty($client->getAttribute('vat_id')?->value->getValue())) { + if (!empty($client->getAttribute('vat_id')->value->getValue())) { // Is EU company $taxCode = $codes->getDefaultByValue('EU'); } else { diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 9c09a0c..e06864c 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -131,7 +131,7 @@ final class BackendController extends Controller ->with('createdBy') ->where('module', 'Billing') ->where('type', StringUtils::intHash(BillMapper::class)) - ->where('ref', $bill->getId()) + ->where('ref', $bill->id) ->execute(); /** @var \Modules\Auditor\Models\Auditor[] $logsElements */ diff --git a/Controller/CliController.php b/Controller/CliController.php index 881ed0e..b837701 100755 --- a/Controller/CliController.php +++ b/Controller/CliController.php @@ -111,7 +111,7 @@ final class CliController extends Controller ->where('name', $type) ->execute(); - $bill->type = new NullBillType($billType->getId()); + $bill->type = new NullBillType($billType->id); /* Number */ $billNumber = $this->findBillNumber($lines, $identifiers['bill_no'][$language]); @@ -125,7 +125,7 @@ final class CliController extends Controller /* Total Gross */ $totalGross = $this->findBillGross($lines, $identifiers['total_gross'][$language]); - $bill->grossCosts = new Money($totalGross); + $bill->grossCosts = new FloatInt($totalGross); $this->updateModel($request->header->account, $old, $bill, BillMapper::class, 'bill_parsing', $request->getOrigin()); @@ -354,7 +354,7 @@ final class CliController extends Controller if ((!empty($supplier->getAttribute('bill_match_pattern')->value->valueStr) && \stripos($content, $supplier->getAttribute('bill_match_pattern')->value->valueStr) !== false) ) { - return $supplier->getId(); + return $supplier->id; } } @@ -364,7 +364,7 @@ final class CliController extends Controller $ibans = $supplier->getPaymentsByType(PaymentType::SWIFT); foreach ($ibans as $iban) { if (\stripos($content, $iban->content2) !== false) { - return $supplier->getId(); + return $supplier->id; } } } @@ -378,7 +378,7 @@ final class CliController extends Controller || (!empty( $supplier->mainAddress->address) && \stripos($content, $supplier->mainAddress->address) !== false) ) { - return $supplier->getId(); + return $supplier->id; } } } @@ -386,7 +386,7 @@ final class CliController extends Controller // name1 foreach ($suppliers as $supplier) { if (\stripos($content, $supplier->account->name1) !== false) { - return $supplier->getId(); + return $supplier->id; } } @@ -408,7 +408,7 @@ final class CliController extends Controller { if ((!empty($supplier->getAttribute('bill_date_format')->value->valueStr))) { return \DateTime::createFromFormat( - $supplier->getAttribute('bill_date_format')?->value->valueStr ?? '', + $supplier->getAttribute('bill_date_format')->value->valueStr ?? '', $date ); } diff --git a/Models/Bill.php b/Models/Bill.php index 6e26a2e..9775a5a 100755 --- a/Models/Bill.php +++ b/Models/Bill.php @@ -24,7 +24,7 @@ use Modules\Media\Models\NullMedia; use Modules\SupplierManagement\Models\Supplier; use phpOMS\Localization\ISO4217CharEnum; use phpOMS\Localization\ISO639x1Enum; -use phpOMS\Localization\Money; +use phpOMS\Stdlib\Base\FloatInt; /** * Bill class. @@ -42,7 +42,7 @@ class Bill implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Sequence. @@ -85,7 +85,7 @@ class Bill implements \JsonSerializable * @var int * @since 1.0.0 */ - private int $status = BillStatus::DRAFT; + public int $status = BillStatus::DRAFT; private int $paymentStatus = BillPaymentStatus::UNPAID; @@ -256,82 +256,82 @@ class Bill implements \JsonSerializable /** * Net amount. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $netProfit; + public FloatInt $netProfit; /** * Gross amount. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $grossProfit; + public FloatInt $grossProfit; /** * Costs in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $netCosts; + public FloatInt $netCosts; /** * Profit in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $grossCosts; + public FloatInt $grossCosts; /** * Costs in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $netSales; + public FloatInt $netSales; /** * Profit in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $grossSales; + public FloatInt $grossSales; /** * Costs in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $netDiscount; + public FloatInt $netDiscount; /** * Profit in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $grossDiscount; + public FloatInt $grossDiscount; /** * Insurance fees in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $insurance; + public FloatInt $insurance; /** * Freight in net. * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $freight; + public FloatInt $freight; /** * Currency. @@ -468,14 +468,14 @@ class Bill implements \JsonSerializable */ public function __construct() { - $this->netProfit = new Money(0); - $this->grossProfit = new Money(0); - $this->netCosts = new Money(0); - $this->grossCosts = new Money(0); - $this->netSales = new Money(0); - $this->grossSales = new Money(0); - $this->netDiscount = new Money(0); - $this->grossDiscount = new Money(0); + $this->netProfit = new FloatInt(0); + $this->grossProfit = new FloatInt(0); + $this->netCosts = new FloatInt(0); + $this->grossCosts = new FloatInt(0); + $this->netSales = new FloatInt(0); + $this->grossSales = new FloatInt(0); + $this->netDiscount = new FloatInt(0); + $this->grossDiscount = new FloatInt(0); $this->billDate = new \DateTime('now'); $this->createdAt = new \DateTimeImmutable(); @@ -520,7 +520,7 @@ class Bill implements \JsonSerializable $this->createdAt->format('d'), $this->id, $this->sequence, - $this->type->getId(), + $this->type->id, ], $this->type->numberFormat ); @@ -804,7 +804,7 @@ class Bill implements \JsonSerializable $files = []; foreach ($this->media as $file) { - if ($file->type !== null && $file->type->getId() === $type) { + if ($file->type !== null && $file->type->id === $type) { $files[] = $file; } } diff --git a/Models/BillElement.php b/Models/BillElement.php index 89ef0f8..d97fc53 100755 --- a/Models/BillElement.php +++ b/Models/BillElement.php @@ -16,7 +16,6 @@ namespace Modules\Billing\Models; use Modules\Finance\Models\TaxCode; use Modules\ItemManagement\Models\Item; -use phpOMS\Localization\Money; use phpOMS\Stdlib\Base\FloatInt; /** @@ -35,7 +34,7 @@ class BillElement implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; public int $order = 0; @@ -52,53 +51,53 @@ class BillElement implements \JsonSerializable public ?Subscription $subscription = null; - public Money $singleSalesPriceNet; + public FloatInt $singleSalesPriceNet; - public Money $singleSalesPriceGross; + public FloatInt $singleSalesPriceGross; - public Money $totalSalesPriceNet; + public FloatInt $totalSalesPriceNet; - public Money $totalSalesPriceGross; + public FloatInt $totalSalesPriceGross; - public Money $singleDiscountP; + public FloatInt $singleDiscountP; - public Money $totalDiscountP; + public FloatInt $totalDiscountP; public ?FloatInt $singleDiscountR = null; public ?FloatInt $discountQ = null; - public Money $singleListPriceNet; + public FloatInt $singleListPriceNet; - public Money $singleListPriceGross; + public FloatInt $singleListPriceGross; - public Money $totalListPriceNet; + public FloatInt $totalListPriceNet; - public Money $totalListPriceGross; + public FloatInt $totalListPriceGross; - public Money $singlePurchasePriceNet; + public FloatInt $singlePurchasePriceNet; - public Money $singlePurchasePriceGross; + public FloatInt $singlePurchasePriceGross; - public Money $totalPurchasePriceNet; + public FloatInt $totalPurchasePriceNet; - public Money $totalPurchasePriceGross; + public FloatInt $totalPurchasePriceGross; - public Money $singleProfitNet; + public FloatInt $singleProfitNet; - public Money $singleProfitGross; + public FloatInt $singleProfitGross; - public Money $totalProfitNet; + public FloatInt $totalProfitNet; - public Money $totalProfitGross; + public FloatInt $totalProfitGross; /** * Tax amount * - * @var Money + * @var FloatInt * @since 1.0.0 */ - public Money $taxP; + public FloatInt $taxP; /** * Tax percentage @@ -135,34 +134,34 @@ class BillElement implements \JsonSerializable */ public function __construct() { - $this->singleListPriceNet = new Money(); - $this->singleListPriceGross = new Money(); + $this->singleListPriceNet = new FloatInt(); + $this->singleListPriceGross = new FloatInt(); - $this->totalListPriceNet = new Money(); - $this->totalListPriceGross = new Money(); + $this->totalListPriceNet = new FloatInt(); + $this->totalListPriceGross = new FloatInt(); - $this->singleSalesPriceNet = new Money(); - $this->singleSalesPriceGross = new Money(); + $this->singleSalesPriceNet = new FloatInt(); + $this->singleSalesPriceGross = new FloatInt(); - $this->totalSalesPriceNet = new Money(); - $this->totalSalesPriceGross = new Money(); + $this->totalSalesPriceNet = new FloatInt(); + $this->totalSalesPriceGross = new FloatInt(); - $this->singlePurchasePriceNet = new Money(); - $this->singlePurchasePriceGross = new Money(); + $this->singlePurchasePriceNet = new FloatInt(); + $this->singlePurchasePriceGross = new FloatInt(); - $this->totalPurchasePriceNet = new Money(); - $this->totalPurchasePriceGross = new Money(); + $this->totalPurchasePriceNet = new FloatInt(); + $this->totalPurchasePriceGross = new FloatInt(); - $this->singleProfitNet = new Money(); - $this->singleProfitGross = new Money(); + $this->singleProfitNet = new FloatInt(); + $this->singleProfitGross = new FloatInt(); - $this->totalProfitNet = new Money(); - $this->totalProfitGross = new Money(); + $this->totalProfitNet = new FloatInt(); + $this->totalProfitGross = new FloatInt(); - $this->singleDiscountP = new Money(); - $this->totalDiscountP = new Money(); + $this->singleDiscountP = new FloatInt(); + $this->totalDiscountP = new FloatInt(); - $this->taxP = new Money(); + $this->taxP = new FloatInt(); $this->taxR = new FloatInt(); } @@ -239,7 +238,7 @@ class BillElement implements \JsonSerializable { $element = new self(); $element->bill = $bill; - $element->item = empty($item->getId()) ? null : $item->getId(); + $element->item = empty($item->id) ? null : $item->id; $element->itemNumber = $item->number; $element->itemName = $item->getL11n('name1')->description; $element->itemDescription = $item->getL11n('description_short')->description; @@ -257,7 +256,7 @@ class BillElement implements \JsonSerializable $element->singleProfitNet->setInt($element->singleSalesPriceNet->getInt() - $element->singlePurchasePriceNet->getInt()); $element->totalProfitNet->setInt($element->quantity * ($element->totalSalesPriceNet->getInt() - $element->totalPurchasePriceNet->getInt())); - $element->taxP = new Money((int) (($code->percentageInvoice * $element->totalSalesPriceNet->getInt()) / 10000)); + $element->taxP = new FloatInt((int) (($code->percentageInvoice * $element->totalSalesPriceNet->getInt()) / 10000)); $element->taxR = new FloatInt($code->percentageInvoice); $element->taxCode = $code->abbr; @@ -272,7 +271,7 @@ class BillElement implements \JsonSerializable $element->totalProfitGross->setInt($element->quantity * ($element->totalSalesPriceGross->getInt() - $element->totalPurchasePriceGross->getInt())); if (!empty($element->bill) - && $item->getAttribute('subscription')?->value->getValue() === 1 + && $item->getAttribute('subscription')->value->getValue() === 1 ) { $element->subscription = new Subscription(); $element->subscription->bill = $element->bill; diff --git a/Models/BillType.php b/Models/BillType.php index 6c91103..1df4959 100755 --- a/Models/BillType.php +++ b/Models/BillType.php @@ -34,7 +34,7 @@ class BillType implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; public string $name = ''; @@ -44,6 +44,8 @@ class BillType implements \JsonSerializable public string $numberFormat = ''; + public string $accountFormat = ''; + public int $transferType = BillTransferType::SALES; public bool $transferStock = true; diff --git a/Models/BillTypeMapper.php b/Models/BillTypeMapper.php index 1b9d4ad..0aa9f36 100755 --- a/Models/BillTypeMapper.php +++ b/Models/BillTypeMapper.php @@ -40,6 +40,7 @@ final class BillTypeMapper extends DataMapperFactory 'billing_type_id' => ['name' => 'billing_type_id', 'type' => 'int', 'internal' => 'id'], 'billing_type_name' => ['name' => 'billing_type_name', 'type' => 'string', 'internal' => 'name'], 'billing_type_number_format' => ['name' => 'billing_type_number_format', 'type' => 'string', 'internal' => 'numberFormat'], + 'billing_type_account_format' => ['name' => 'billing_type_account_format', 'type' => 'string', 'internal' => 'accountFormat'], 'billing_type_transfer_type' => ['name' => 'billing_type_transfer_type', 'type' => 'int', 'internal' => 'transferType'], 'billing_type_default_template' => ['name' => 'billing_type_default_template', 'type' => 'int', 'internal' => 'defaultTemplate'], 'billing_type_transfer_stock' => ['name' => 'billing_type_transfer_stock', 'type' => 'bool', 'internal' => 'transferStock'], diff --git a/Models/Price/Price.php b/Models/Price/Price.php index 4129810..3aee495 100755 --- a/Models/Price/Price.php +++ b/Models/Price/Price.php @@ -23,6 +23,7 @@ use Modules\ItemManagement\Models\NullItem; use Modules\SupplierManagement\Models\NullSupplier; use Modules\SupplierManagement\Models\Supplier; use phpOMS\Localization\ISO4217CharEnum; +use phpOMS\Stdlib\Base\FloatInt; /** * Bill class. @@ -40,7 +41,7 @@ class Price implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; public string $name = ''; @@ -76,7 +77,7 @@ class Price implements \JsonSerializable public int $quantity = 0; - public int $price = 0; + public FloatInt $price; public int $priceNew = 0; @@ -109,6 +110,8 @@ class Price implements \JsonSerializable $this->clienttype = new NullAttributeValue(); $this->supplier = new NullSupplier(); + + $this->price = new FloatInt(); } /** diff --git a/Models/Price/PriceMapper.php b/Models/Price/PriceMapper.php index 907b860..d19fc97 100755 --- a/Models/Price/PriceMapper.php +++ b/Models/Price/PriceMapper.php @@ -60,7 +60,7 @@ final class PriceMapper extends DataMapperFactory 'billing_price_unit' => ['name' => 'billing_price_unit', 'type' => 'int', 'internal' => 'unit'], 'billing_price_type' => ['name' => 'billing_price_type', 'type' => 'int', 'internal' => 'type'], 'billing_price_quantity' => ['name' => 'billing_price_quantity', 'type' => 'int', 'internal' => 'quantity'], - 'billing_price_price' => ['name' => 'billing_price_price', 'type' => 'int', 'internal' => 'price'], + 'billing_price_price' => ['name' => 'billing_price_price', 'type' => 'Serializable', 'internal' => 'price'], 'billing_price_price_new' => ['name' => 'billing_price_price_new', 'type' => 'int', 'internal' => 'priceNew'], 'billing_price_discount' => ['name' => 'billing_price_discount', 'type' => 'int', 'internal' => 'discount'], 'billing_price_discountp' => ['name' => 'billing_price_discountp', 'type' => 'int', 'internal' => 'discountPercentage'], diff --git a/Models/PurchaseBillMapper.php b/Models/PurchaseBillMapper.php index 9c6ac7a..ac6db33 100755 --- a/Models/PurchaseBillMapper.php +++ b/Models/PurchaseBillMapper.php @@ -17,7 +17,7 @@ namespace Modules\Billing\Models; use Modules\SupplierManagement\Models\SupplierMapper; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Localization\Defaults\CountryMapper; -use phpOMS\Localization\Money; +use phpOMS\Stdlib\Base\FloatInt; /** * Mapper class. @@ -78,7 +78,7 @@ final class PurchaseBillMapper extends BillMapper /** * Placeholder */ - public static function getPurchaseByItemId(int $id, \DateTime $start, \DateTime $end) : Money + public static function getPurchaseByItemId(int $id, \DateTime $start, \DateTime $end) : FloatInt { $query = new Builder(self::$db); $result = $query->select('SUM(billing_bill_element_total_netpurchaseprice)') @@ -91,13 +91,13 @@ final class PurchaseBillMapper extends BillMapper ->execute() ?->fetch(); - return new Money((int) $result[0]); + return new FloatInt((int) $result[0]); } /** * Placeholder */ - public static function getPurchaseBySupplierId(int $id, \DateTime $start, \DateTime $end) : Money + public static function getPurchaseBySupplierId(int $id, \DateTime $start, \DateTime $end) : FloatInt { $query = new Builder(self::$db); $result = $query->select('SUM(billing_bill_netcosts)') @@ -108,13 +108,13 @@ final class PurchaseBillMapper extends BillMapper ->execute() ?->fetch(); - return new Money((int) $result[0]); + return new FloatInt((int) $result[0]); } /** * Placeholder */ - public static function getAvgPurchasePriceByItemId(int $id, \DateTime $start, \DateTime $end) : Money + public static function getAvgPurchasePriceByItemId(int $id, \DateTime $start, \DateTime $end) : FloatInt { $query = new Builder(self::$db); $result = $query->select('SUM(billing_bill_element_single_netpurchaseprice)', 'COUNT(billing_bill_element_total_netpurchaseprice)') @@ -127,7 +127,7 @@ final class PurchaseBillMapper extends BillMapper ->execute() ?->fetch(); - return new Money($result === false || $result[1] == 0 ? 0 : (int) (((int) $result[0]) / ((int) $result[1]))); + return new FloatInt($result === false || $result[1] == 0 ? 0 : (int) (((int) $result[0]) / ((int) $result[1]))); } /** @@ -179,9 +179,9 @@ final class PurchaseBillMapper extends BillMapper /** * Placeholder */ - public static function getItemLivetimeValue(int $id, \DateTime $start, \DateTime $end) : Money + public static function getItemLivetimeValue(int $id, \DateTime $start, \DateTime $end) : FloatInt { - return new Money(); + return new FloatInt(); } /** diff --git a/Models/SalesBillMapper.php b/Models/SalesBillMapper.php index c6ca7b2..112b207 100755 --- a/Models/SalesBillMapper.php +++ b/Models/SalesBillMapper.php @@ -17,7 +17,7 @@ namespace Modules\Billing\Models; use Modules\ClientManagement\Models\ClientMapper; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Localization\Defaults\CountryMapper; -use phpOMS\Localization\Money; +use phpOMS\Stdlib\Base\FloatInt; /** * Mapper class. @@ -78,7 +78,7 @@ final class SalesBillMapper extends BillMapper /** * Placeholder */ - public static function getSalesByItemId(int $id, \DateTime $start, \DateTime $end) : Money + public static function getSalesByItemId(int $id, \DateTime $start, \DateTime $end) : FloatInt { $query = new Builder(self::$db); $result = $query->select('SUM(billing_bill_element_total_netsalesprice)') @@ -91,13 +91,13 @@ final class SalesBillMapper extends BillMapper ->execute() ?->fetch(); - return new Money((int) $result[0] ?? 0); + return new FloatInt((int) $result[0] ?? 0); } /** * Placeholder */ - public static function getSalesByClientId(int $id, \DateTime $start, \DateTime $end) : Money + public static function getSalesByClientId(int $id, \DateTime $start, \DateTime $end) : FloatInt { $query = new Builder(self::$db); $result = $query->select('SUM(billing_bill_netsales)') @@ -108,13 +108,13 @@ final class SalesBillMapper extends BillMapper ->execute() ?->fetch(); - return new Money((int) $result[0] ?? 0); + return new FloatInt((int) $result[0] ?? 0); } /** * Placeholder */ - public static function getAvgSalesPriceByItemId(int $id, \DateTime $start, \DateTime $end) : Money + public static function getAvgSalesPriceByItemId(int $id, \DateTime $start, \DateTime $end) : FloatInt { $query = new Builder(self::$db); $result = $query->select('SUM(billing_bill_element_single_netsalesprice)', 'COUNT(billing_bill_element_total_netsalesprice)') @@ -127,7 +127,7 @@ final class SalesBillMapper extends BillMapper ->execute() ?->fetch(); - return new Money($result === false || ((int) ($result[1] ?? 0)) === 0 ? 0 : (int) (((int) $result[0] ?? 0) / ((int) $result[1]))); + return new FloatInt($result === false || ((int) ($result[1] ?? 0)) === 0 ? 0 : (int) (((int) $result[0] ?? 0) / ((int) $result[1]))); } /** @@ -179,9 +179,9 @@ final class SalesBillMapper extends BillMapper /** * Placeholder */ - public static function getItemLivetimeValue(int $id, \DateTime $start, \DateTime $end) : Money + public static function getItemLivetimeValue(int $id, \DateTime $start, \DateTime $end) : FloatInt { - return new Money(); + return new FloatInt(); } /** diff --git a/Models/Subscription.php b/Models/Subscription.php index a07897b..6fb39fa 100755 --- a/Models/Subscription.php +++ b/Models/Subscription.php @@ -32,7 +32,7 @@ class Subscription implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; public int $status = 0; diff --git a/Models/Tax/TaxCombination.php b/Models/Tax/TaxCombination.php index 333392c..97937a2 100755 --- a/Models/Tax/TaxCombination.php +++ b/Models/Tax/TaxCombination.php @@ -33,7 +33,7 @@ class TaxCombination implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; public ?AttributeValue $clientCode = null; diff --git a/Theme/Backend/bill-create.tpl.php b/Theme/Backend/bill-create.tpl.php index 80badc0..d9c97bc 100755 --- a/Theme/Backend/bill-create.tpl.php +++ b/Theme/Backend/bill-create.tpl.php @@ -39,7 +39,7 @@ $billTypes = $this->getData('billtypes') ?? []; /** @var \Modules\Auditor\Models\Audit */ $logs = $this->getData('logs') ?? []; -$editable = $bill instanceof NullBill || \in_array($bill->getStatus(), [BillStatus::DRAFT, BillStatus::UNPARSED]); +$editable = $bill->id === 0 || \in_array($bill->getStatus(), [BillStatus::DRAFT, BillStatus::UNPARSED]); $disabled = !$editable ? ' disabled' : ''; echo $this->getData('nav')->render(); ?> @@ -96,7 +96,7 @@ echo $this->getData('nav')->render(); ?> @@ -306,12 +306,12 @@ echo $this->getData('nav')->render(); ?> > > - > + > > > > > - totalSalesPriceNet->getCurrency(); ?> + getCurrency($element->totalSalesPriceNet); ?> @@ -345,7 +345,7 @@ echo $this->getData('nav')->render(); ?>
@@ -512,10 +512,10 @@ echo $this->getData('nav')->render(); ?> getId()); + $url = UriFactory::build('{/base}/admin/audit/single?id=' . $audit->id); ?> - getId(); ?> + id; ?> trigger; ?> old === null) : echo $this->getHtml('CREATE', 'Auditor', 'Backend'); ?> old !== null && $audit->new !== null) : echo $this->getHtml('UPDATE', 'Auditor', 'Backend'); ?> @@ -523,7 +523,7 @@ echo $this->getData('nav')->render(); ?> getHtml('UNKNOWN', 'Auditor', 'Backend'); ?> printHtml( + href="createdBy->id); ?>">printHtml( $this->renderUserName('%3$s %2$s %1$s', [$audit->createdBy->name1, $audit->createdBy->name2, $audit->createdBy->name3, $audit->createdBy->login]) ); ?> createdAt->format('Y-m-d'); ?> diff --git a/Theme/Backend/purchase-bill-list.tpl.php b/Theme/Backend/purchase-bill-list.tpl.php index 3967dc3..1149844 100755 --- a/Theme/Backend/purchase-bill-list.tpl.php +++ b/Theme/Backend/purchase-bill-list.tpl.php @@ -154,7 +154,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$count; - $url = UriFactory::build('{/base}/purchase/bill?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/base}/purchase/bill?{?}&id=' . $value->id); ?> getNumber(); ?> type->getL11n(); ?> - supplier->number; ?> + supplier->number; ?> printHtml($value->billTo); ?> billAddress; ?> diff --git a/Theme/Backend/purchase-bill.tpl.php b/Theme/Backend/purchase-bill.tpl.php index da1d877..4aa7237 100755 --- a/Theme/Backend/purchase-bill.tpl.php +++ b/Theme/Backend/purchase-bill.tpl.php @@ -169,12 +169,12 @@ echo $this->getData('nav')->render(); ?> - + - totalSalesPriceNet->getCurrency(); ?> + getCurrency($element->totalSalesPriceNet); ?> @@ -191,9 +191,9 @@ echo $this->getData('nav')->render(); ?>
getHtml('Freightage'); ?>: 0.00 - - getHtml('Net'); ?>: netSales->getCurrency(); ?> - + getHtml('Net'); ?>: getCurrency($bill->netSales); ?> - getHtml('Tax'); ?>: 0.00 - - getHtml('Total'); ?>: grossSales->getCurrency(); ?> + getHtml('Total'); ?>: getCurrency($bill->grossSales); ?>
@@ -205,7 +205,7 @@ echo $this->getData('nav')->render(); ?>
- + id > 0) : ?>
@@ -219,7 +219,7 @@ echo $this->getData('nav')->render(); ?>
- + id > 0) : ?>
@@ -301,9 +301,9 @@ echo $this->getData('nav')->render(); ?> extension === 'collection' ? UriFactory::build('{/base}/media/list?path=' . \rtrim($file->getVirtualPath(), '/') . '/' . $file->name) - : UriFactory::build('{/base}/media/single?id=' . $file->getId() + : UriFactory::build('{/base}/media/single?id=' . $file->id . '&path={?path}' . ( - $file->getId() === 0 + $file->id === 0 ? '/' . $file->name : '' ) diff --git a/Theme/Backend/sales-bill-list.tpl.php b/Theme/Backend/sales-bill-list.tpl.php index 350e269..ec108d7 100755 --- a/Theme/Backend/sales-bill-list.tpl.php +++ b/Theme/Backend/sales-bill-list.tpl.php @@ -165,7 +165,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$count; - $url = UriFactory::build('{/base}/sales/bill?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/base}/sales/bill?{?}&id=' . $value->id); ?> getNumber(); ?> type->getL11n(); ?> - client->number; ?> + client->number; ?> printHtml($value->billTo); ?> billAddress; ?> billZip; ?> billCity; ?> billCountry; ?> - netSales->getCurrency(); ?> - netProfit->getCurrency(); ?> + getCurrency($value->netSales); ?> + getCurrency($value->netProfit); ?> createdAt->format('Y-m-d'); ?> diff --git a/Theme/Backend/user-purchase-bill-dashboard.tpl.php b/Theme/Backend/user-purchase-bill-dashboard.tpl.php index f5fd020..cdddcdd 100755 --- a/Theme/Backend/user-purchase-bill-dashboard.tpl.php +++ b/Theme/Backend/user-purchase-bill-dashboard.tpl.php @@ -156,7 +156,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$count; - $url = UriFactory::build('{/base}/private/purchase/bill?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/base}/private/purchase/bill?{?}&id=' . $value->id); ?> getNumber(); ?> type->getL11n(); ?> - supplier->number; ?> + supplier->number; ?> printHtml($value->billTo); ?> billAddress; ?> diff --git a/Theme/Backend/user-purchase-bill.tpl.php b/Theme/Backend/user-purchase-bill.tpl.php index 33f0f0a..a77a9c0 100755 --- a/Theme/Backend/user-purchase-bill.tpl.php +++ b/Theme/Backend/user-purchase-bill.tpl.php @@ -168,12 +168,12 @@ echo $this->getData('nav')->render(); ?> - + - totalSalesPriceNet->getCurrency(); ?> + getCurrency($element->totalSalesPriceNet); ?> @@ -189,9 +189,9 @@ echo $this->getData('nav')->render(); ?>
getHtml('Freightage'); ?>: 0.00 - - getHtml('Net'); ?>: netSales->getCurrency(); ?> - + getHtml('Net'); ?>: getCurrency($bill->netSales); ?> - getHtml('Tax'); ?>: 0.00 - - getHtml('Total'); ?>: grossSales->getCurrency(); ?> + getHtml('Total'); ?>: getCurrency($bill->grossSales); ?>
@@ -203,7 +203,7 @@ echo $this->getData('nav')->render(); ?>
- + id > 0) : ?>
@@ -217,7 +217,7 @@ echo $this->getData('nav')->render(); ?>
- + id > 0) : ?>
@@ -299,9 +299,9 @@ echo $this->getData('nav')->render(); ?> extension === 'collection' ? UriFactory::build('{/base}/media/list?path=' . \rtrim($file->getVirtualPath(), '/') . '/' . $file->name) - : UriFactory::build('{/base}/media/single?id=' . $file->getId() + : UriFactory::build('{/base}/media/single?id=' . $file->id . '&path={?path}' . ( - $file->getId() === 0 + $file->id === 0 ? '/' . $file->name : '' ) diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 33b4fca..0e19e71 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -123,7 +123,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $this->module->apiBillCreate($request, $response); - $bId = $response->get('')['response']->getId(); + $bId = $response->get('')['response']->id; self::assertGreaterThan(0, $bId); for ($k = 0; $k < 10; ++$k) { @@ -151,7 +151,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase } $this->module->apiBillElementCreate($request, $response); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } $response = new HttpResponse(); @@ -163,7 +163,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $this->module->apiBillPdfArchiveCreate($request, $response); $result = $response->get(''); - self::assertGreaterThan(0, $result === null ? -1 : $result['response']?->getId()); + self::assertGreaterThan(0, $result === null ? -1 : $result['response']?->id); } */ @@ -199,7 +199,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $this->module->apiBillCreate($request, $response); - $bId = $response->get('')['response']->getId(); + $bId = $response->get('')['response']->id; self::assertGreaterThan(0, $bId); for ($k = 0; $k < 10; ++$k) { @@ -227,7 +227,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase } $this->module->apiBillElementCreate($request, $response); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } $response = new HttpResponse(); @@ -239,7 +239,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $this->module->apiBillPdfArchiveCreate($request, $response); $result = $response->get(''); - self::assertGreaterThan(0, $result === null ? -1 : $result['response']?->getId()); + self::assertGreaterThan(0, $result === null ? -1 : $result['response']?->id); } */ diff --git a/tests/Models/BillElementTest.php b/tests/Models/BillElementTest.php index 08d7a29..2356c19 100755 --- a/tests/Models/BillElementTest.php +++ b/tests/Models/BillElementTest.php @@ -37,7 +37,7 @@ final class BillElementTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals(0, $this->element->getId()); + self::assertEquals(0, $this->element->id); self::assertInstanceOf('\phpOMS\Localization\Money', $this->element->singleSalesPriceNet); self::assertInstanceOf('\phpOMS\Localization\Money', $this->element->totalSalesPriceNet); self::assertInstanceOf('\phpOMS\Localization\Money', $this->element->singlePurchasePriceNet); diff --git a/tests/Models/BillTest.php b/tests/Models/BillTest.php index b5afcff..2218718 100755 --- a/tests/Models/BillTest.php +++ b/tests/Models/BillTest.php @@ -42,7 +42,7 @@ final class BillTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals(0, $this->bill->getId()); + self::assertEquals(0, $this->bill->id); self::assertEquals('', $this->bill->number); self::assertEquals('', $this->bill->referralName); self::assertEquals('', $this->bill->info); @@ -93,7 +93,7 @@ final class BillTest extends \PHPUnit\Framework\TestCase */ public function testNumberRendering() : void { - $this->bill->numberFormat = '{y}{m}{d}-{id}'; + $this->bill->type->numberFormat = '{y}{m}{d}-{id}'; self::assertEquals(\date('Y') . \date('m') . \date('d') . '-0', $this->bill->getNumber()); } @@ -165,7 +165,6 @@ final class BillTest extends \PHPUnit\Framework\TestCase public function testSerialize() : void { $this->bill->number = '123456'; - $this->bill->numberFormat = '{y}'; $this->bill->type = new NullBillType(2); $this->bill->shipTo = 'To'; $this->bill->shipFAO = 'FAO'; @@ -184,7 +183,6 @@ final class BillTest extends \PHPUnit\Framework\TestCase [ 'id' => 0, 'number' => '123456', - 'numberFormat' => '{y}', 'type' => $this->bill->type, 'shipTo' => 'To', 'shipFAO' => 'FAO', diff --git a/tests/Models/BillTypeTest.php b/tests/Models/BillTypeTest.php index 4730619..a57ad34 100755 --- a/tests/Models/BillTypeTest.php +++ b/tests/Models/BillTypeTest.php @@ -38,7 +38,7 @@ final class BillTypeTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals(0, $this->type->getId()); + self::assertEquals(0, $this->type->id); self::assertTrue($this->type->transferStock); } diff --git a/tests/Models/NullBillElementTest.php b/tests/Models/NullBillElementTest.php index 4e98466..6a9adae 100755 --- a/tests/Models/NullBillElementTest.php +++ b/tests/Models/NullBillElementTest.php @@ -37,6 +37,6 @@ final class NullBillElementTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullBillElement(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } } diff --git a/tests/Models/NullBillTest.php b/tests/Models/NullBillTest.php index 859b1e3..e059677 100755 --- a/tests/Models/NullBillTest.php +++ b/tests/Models/NullBillTest.php @@ -37,6 +37,6 @@ final class NullBillTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullBill(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } } diff --git a/tests/Models/NullBillTypeTest.php b/tests/Models/NullBillTypeTest.php index d46a2a3..9efce33 100755 --- a/tests/Models/NullBillTypeTest.php +++ b/tests/Models/NullBillTypeTest.php @@ -37,6 +37,6 @@ final class NullBillTypeTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullBillType(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } }