fix php version, lang files, basic tpl and sales impl.

This commit is contained in:
Dennis Eichhorn 2021-03-05 21:01:37 +01:00
parent c0b97d0c26
commit 9a3a986251
24 changed files with 456 additions and 314 deletions

View File

@ -6,282 +6,171 @@ use Mpdf\Mpdf;
* @var \phpOMS\Views\View $this
*/
$bill = $this->getData('bill');
$elements = $bill->getElements();
$mpdf = new Mpdf([
'mode' => 'utf-8',
'format' => 'A4-L',
'orientation' => 'L',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'margin_left' => 20,
'margin_right' => 15,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetTitle($bill->getNumber());
$mpdf->SetAuthor('Orange Management');
$mpdf->AddPage();
$mpdf->SetHTMLHeader('
');
$mpdf->SetHTMLFooter('
');
$mpdf->WriteHTML('
$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
table.items {
border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
font-variant: small-caps;
}
.items td.blanktotal {
background-color: #EEEEEE;
border: 0.1mm solid #000000;
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
.items td.totals {
text-align: right;
border: 0.1mm solid #000000;
}
.items td.cost {
text-align: "." center;
}
</style>
<style>
body {
font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
table.items {
border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
table thead td {
background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
font-variant: small-caps;
}
.items td.blanktotal {
background-color: #EEEEEE;
border: 0.1mm solid #000000;
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
.items td.totals {
text-align: right;
border: 0.1mm solid #000000;
}
.items td.cost {
text-align: "." center;
}
</style>
</head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="50%" style="color:#0000BB; "><span style="font-weight: bold; font-size: 14pt;">Acme Trading Co.</span><br />123 Anystreet<br />Your City<br />GD12 4LP<br /><span style="font-family:dejavusanscondensed;">&#9742;</span> 01777 123 567</td>
<td width="50%" style="text-align: right;">Invoice No.<br /><span style="font-weight: bold; font-size: 12pt;">0012345</span></td>
</tr></table>
<table width="100%">
<tr>
<td width="50%" style="color:#0000BB; ">
<span style="font-weight: bold; font-size: 14pt;">Orange Management</span><br />
123 1313 Webfoot Street<br />
Duckburg<br />
</td>
<td width="50%" style="text-align: right;">
Invoice No.<br />
<span style="font-weight: bold; font-size: 12pt;">' . $bill->getNumber() . '</span>
</td>
</tr>
</table>
</htmlpageheader>
<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
<div style="text-align: right">Date: 13th November 2008</div>
<table width="100%" style="font-family: serif;" cellpadding="10"><tr>
<td width="45%" style="border: 0.1mm solid #888888; "><span style="font-size: 7pt; color: #555555; font-family: sans;">SOLD TO:</span><br /><br />345 Anotherstreet<br />Little Village<br />Their City<br />CB22 6SO</td>
<td width="10%">&nbsp;</td>
<td width="45%" style="border: 0.1mm solid #888888;"><span style="font-size: 7pt; color: #555555; font-family: sans;">SHIP TO:</span><br /><br />345 Anotherstreet<br />Little Village<br />Their City<br />CB22 6SO</td>
</tr></table>
<br />
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="15%">Ref. No.</td>
<td width="10%">Quantity</td>
<td width="45%">Description</td>
<td width="15%">Unit Price</td>
<td width="15%">Amount</td>
</tr>
</thead>
<tbody>
<!-- ITEMS HERE -->
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<!-- END ITEMS HERE -->
<tr>
<td class="blanktotal" colspan="3" rowspan="6"></td>
<td class="totals">Subtotal:</td>
<td class="totals cost">&pound;1825.60</td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">&pound;18.25</td>
</tr>
<tr>
<td class="totals">Shipping:</td>
<td class="totals cost">&pound;42.56</td>
</tr>
<tr>
<td class="totals"><b>TOTAL:</b></td>
<td class="totals cost"><b>&pound;1882.56</b></td>
</tr>
<tr>
<td class="totals">Deposit:</td>
<td class="totals cost">&pound;100.00</td>
</tr>
<tr>
<td class="totals"><b>Balance due:</b></td>
<td class="totals cost"><b>&pound;1782.56</b></td>
</tr>
</tbody>
<table width="100%" style="font-family: serif;" cellpadding="10">
<tr>
<td width="45%" style="border: 0.1mm solid #888888; ">
<span style="font-size: 7pt; color: #555555; font-family: sans;">SOLD TO:</span><br /><br />
345 Anotherstreet<br />
Little Village<br />
Their City<br />
CB22 6SO
</td>
<td width="10%">&nbsp;</td>
<td width="45%" style="border: 0.1mm solid #888888;">
<span style="font-size: 7pt; color: #555555; font-family: sans;">SHIP TO:</span><br /><br />
345 Anotherstreet<br />
Little Village<br />
Their City<br />CB22 6SO</td>
</tr>
</table>
<br />
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="15%">Ref. No.</td>
<td width="10%">Quantity</td>
<td width="45%">Description</td>
<td width="15%">Unit Price</td>
<td width="15%">Amount</td>
</tr>
</thead>
<tbody>';
foreach ($elements as $element) {
$html .= '
<tr>
<td align="center">' . $element->itemNumber . '</td>
<td align="center">' . $element->quantity . '</td>
<td>' . $element->itemName . '</td>
<td class="cost">' . $element->singleSalesPriceNet->getCurrency(null) . '</td>
<td class="cost">' . $element->totalSalesPriceNet->getCurrency(null) . '</td>
</tr>';
}
$html .= '
<tr>
<td class="blanktotal" colspan="3" rowspan="6"></td>
<td class="totals">Subtotal:</td>
<td class="totals cost">' . $bill->net->getCurrency(null) . '</td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">&pound;18.25</td>
</tr>
<tr>
<td class="totals">Shipping:</td>
<td class="totals cost">&pound;42.56</td>
</tr>
<tr>
<td class="totals"><strong>TOTAL:</strong></td>
<td class="totals cost"><strong>' . $bill->gross->getCurrency(null) . '</strong></td>
</tr>
<tr>
<td class="totals">Deposit:</td>
<td class="totals cost">&pound;100.00</td>
</tr>
<tr>
<td class="totals"><strong>Balance due:</strong></td>
<td class="totals cost"><strong>&pound;1782.56</strong></td>
</tr>
</tbody>
</table>
<div style="text-align: center; font-style: italic;">Payment terms: payment due in 30 days</div>
</body>
</html>
');
';
$mpdf->AddPage();
$mpdf->WriteHTML($html);
$mpdf->Output($this->getData('path'), \Mpdf\Output\Destination::FILE);

View File

@ -90,5 +90,51 @@
"children": []
}
]
},
{
"id": 1005106001,
"pid": "/",
"type": 2,
"subtype": 1,
"name": "Billing",
"uri": "{/prefix}warehouse/bill/list",
"target": "self",
"icon": null,
"order": 5,
"from": "Billing",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1001301001,
"children": [
{
"id": 1005106101,
"pid": "/warehouse/bill",
"type": 3,
"subtype": 1,
"name": "List",
"uri": "{/prefix}warehouse/bill/list",
"target": "self",
"icon": null,
"order": 1,
"from": "Billing",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1005106001,
"children": []
},
{
"id": 1005106301,
"pid": "/warehouse/bill",
"type": 3,
"subtype": 1,
"name": "Create",
"uri": "{/prefix}warehouse/bill/create?{?}",
"target": "self",
"icon": null,
"order": 5,
"from": "Billing",
"permission": { "permission": 4, "type": null, "element": null },
"parent": 1005106001,
"children": []
}
]
}
]

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Admin\Install
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Admin
* @copyright Dennis Eichhorn

View File

@ -72,4 +72,37 @@ return [
],
],
],
'^.*/warehouse/bill/create.*$' => [
[
'dest' => '\Modules\Billing\Controller\BackendController:viewBillingStockInvoiceCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::CREATE,
'state' => PermissionState::PURCHASE_INVOICE,
],
],
],
'^.*/warehouse/bill/list.*$' => [
[
'dest' => '\Modules\Billing\Controller\BackendController:viewBillingStockList',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::PURCHASE_INVOICE,
],
],
],
'^.*/warehouse/bill\?.*$' => [
[
'dest' => '\Modules\Billing\Controller\BackendController:viewBillingStockInvoice',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::SALES_INVOICE,
],
],
],
];

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Admin
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Admin
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Admin
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
@ -16,6 +16,7 @@ namespace Modules\Billing\Controller;
use Modules\Billing\Models\SalesBillMapper;
use Modules\Billing\Models\PurchaseBillMapper;
use Modules\Billing\Models\StockBillMapper;
use Modules\Billing\Models\BillTypeL11n;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
@ -178,4 +179,67 @@ final class BackendController extends Controller
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewBillingStockList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/purchase-bill-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005106001, $request, $response));
if ($request->getData('ptype') === 'p') {
$view->setData('bills',
StockBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
::getStockBeforePivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} elseif ($request->getData('ptype') === 'n') {
$view->setData('bills',
StockBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
::getStockAfterPivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 3)
);
} else {
$view->setData('bills',
StockBillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
::getStockAfterPivot(0, limit: 25, depth: 3)
);
}
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewBillingStockInvoice(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/purchase-bill');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005106001, $request, $response));
$bill = StockBillMapper::get((int) $request->getData('id'));
$view->setData('bill', $bill);
return $view;
}
}

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
@ -52,9 +52,7 @@ class Bill implements \JsonSerializable
* @var int|BillType
* @since 1.0.0
*/
public int |
BillType $type = 0;
public int | BillType $type = 0;
/**
* Bill status.

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
@ -54,22 +54,6 @@ final class PurchaseBillMapper extends BillMapper
return self::getBeforePivot($pivot, $column, $limit, $order, $relations, $depth, $query);
}
public static function getStockBeforePivot(
mixed $pivot,
string $column = null,
int $limit = 50,
string $order = 'ASC',
int $relations = RelationType::ALL,
int $depth = 3,
Builder $query = null
) : array
{
$query = self::getQuery(null, [], $relations, $depth);
$query->where(BillTypeMapper::getTable() . '_' . ($depth - 1) . '.billing_type_transfer_type', '=', BillTransferType::STOCK);
return self::getBeforePivot($pivot, $column, $limit, $order, $relations, $depth, $query);
}
public static function getPurchaseAfterPivot(
mixed $pivot,
string $column = null,
@ -86,22 +70,6 @@ final class PurchaseBillMapper extends BillMapper
return self::getAfterPivot($pivot, $column, $limit, $order, $relations, $depth, $query);
}
public static function getStockAfterPivot(
mixed $pivot,
string $column = null,
int $limit = 50,
string $order = 'ASC',
int $relations = RelationType::ALL,
int $depth = 3,
Builder $query = null
) : array
{
$query = self::getQuery(null, [], $relations, $depth);
$query->where(BillTypeMapper::getTable() . '_' . ($depth - 1) . '.billing_type_transfer_type', '=', BillTransferType::STOCK);
return self::getAfterPivot($pivot, $column, $limit, $order, $relations, $depth, $query);
}
public static function getPurchaseByItemId(int $id, \DateTime $start, \DateTime $end) : Money
{
$query = new Builder(self::$db);
@ -145,10 +113,10 @@ final class PurchaseBillMapper extends BillMapper
->execute()
->fetch();
return new Money((int) (((int) $result[0]) / ((int) $result[1])));
return new Money($result === false || $result[1] == 0 ? 0 : (int) (((int) $result[0]) / ((int) $result[1])));
}
public static function getLastOrderDateByItemId(int $id) : \DateTimeImmutable
public static function getLastOrderDateByItemId(int $id) : ?\DateTimeImmutable
{
// @todo: only delivers/invoice/production (no offers ...)
$query = new Builder(self::$db);
@ -162,10 +130,10 @@ final class PurchaseBillMapper extends BillMapper
->execute()
->fetch();
return new \DateTimeImmutable($result[0]);
return $result === false ? null : new \DateTimeImmutable($result[0]);
}
public static function getLastOrderDateBySupplierId(int $id) : \DateTimeImmutable
public static function getLastOrderDateBySupplierId(int $id) : ?\DateTimeImmutable
{
// @todo: only delivers/invoice/production (no offers ...)
$query = new Builder(self::$db);
@ -177,7 +145,7 @@ final class PurchaseBillMapper extends BillMapper
->execute()
->fetch();
return new \DateTimeImmutable($result[0]);
return $result === false ? null : new \DateTimeImmutable($result[0]);
}
public static function getItemRetentionRate(int $id, \DateTime $start, \DateTime $end) : float

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
@ -113,10 +113,10 @@ final class SalesBillMapper extends BillMapper
->execute()
->fetch();
return new Money((int) (((int) $result[0]) / ((int) $result[1])));
return new Money($result === false || $result[1] == 0 ? 0 : (int) (((int) $result[0]) / ((int) $result[1])));
}
public static function getLastOrderDateByItemId(int $id) : \DateTimeImmutable
public static function getLastOrderDateByItemId(int $id) : ?\DateTimeImmutable
{
// @todo: only delivers/invoice/production (no offers ...)
$query = new Builder(self::$db);
@ -130,10 +130,10 @@ final class SalesBillMapper extends BillMapper
->execute()
->fetch();
return new \DateTimeImmutable($result[0]);
return $result === false ? null : new \DateTimeImmutable($result[0]);
}
public static function getLastOrderDateByClientId(int $id) : \DateTimeImmutable
public static function getLastOrderDateByClientId(int $id) : ?\DateTimeImmutable
{
// @todo: only delivers/invoice/production (no offers ...)
$query = new Builder(self::$db);
@ -145,7 +145,7 @@ final class SalesBillMapper extends BillMapper
->execute()
->fetch();
return new \DateTimeImmutable($result[0]);
return $result === false ? null : new \DateTimeImmutable($result[0]);
}
public static function getItemRetentionRate(int $id, \DateTime $start, \DateTime $end) : float

View File

@ -0,0 +1,72 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\Models;
use Modules\SupplierManagement\Models\SupplierMapper;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\RelationType;
use phpOMS\Localization\Defaults\CountryMapper;
use phpOMS\Localization\Money;
/**
* Mapper class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class StockBillMapper extends BillMapper
{
/**
* Model to use by the mapper.
*
* @var string
* @since 1.0.0
*/
protected static string $model = Bill::class;
public static function getStockBeforePivot(
mixed $pivot,
string $column = null,
int $limit = 50,
string $order = 'ASC',
int $relations = RelationType::ALL,
int $depth = 3,
Builder $query = null
) : array
{
$query = self::getQuery(null, [], $relations, $depth);
$query->where(BillTypeMapper::getTable() . '_' . ($depth - 1) . '.billing_type_transfer_type', '=', BillTransferType::STOCK);
return self::getBeforePivot($pivot, $column, $limit, $order, $relations, $depth, $query);
}
public static function getStockAfterPivot(
mixed $pivot,
string $column = null,
int $limit = 50,
string $order = 'ASC',
int $relations = RelationType::ALL,
int $depth = 3,
Builder $query = null
) : array
{
$query = self::getQuery(null, [], $relations, $depth);
$query->where(BillTypeMapper::getTable() . '_' . ($depth - 1) . '.billing_type_transfer_type', '=', BillTransferType::STOCK);
return self::getAfterPivot($pivot, $column, $limit, $order, $relations, $depth, $query);
}
}

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing
* @copyright Dennis Eichhorn

View File

@ -0,0 +1,70 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
return ['Billing' => [
'Address' => '',
'Addresses' => '',
'AlreadyPaid' => '',
'Bills' => '',
'Bonus' => '',
'Cashback' => '',
'City' => '',
'Client' => '',
'ClientID' => '',
'Confirmation' => '',
'Country' => '',
'Created' => '',
'CreditCard' => '',
'CreditNote' => '',
'Date' => '',
'Delivery' => '',
'DeliveryNote' => '',
'DirectDebit' => '',
'Discount' => '',
'DiscountP' => '',
'Due' => '',
'Freightage' => '',
'Gross' => '',
'Invoice' => '',
'Invoices' => '',
'Item' => '',
'Items' => '',
'Log' => '',
'Logs' => '',
'Media' => '',
'MoneyTransfer' => '',
'Name' => '',
'Net' => '',
'Offer' => '',
'Payment' => '',
'Postal' => '',
'Prepaid' => '',
'Preview' => '',
'Price' => '',
'Profit' => '',
'Quantity' => '',
'Recipient' => '',
'Select' => '',
'Shipment' => '',
'Source' => '',
'Supplier' => '',
'SupplierID' => '',
'Tax' => '',
'TermsOfDelivery' => '',
'Total' => '',
'Type' => '',
'Upload' => '',
'Variation' => '',
'Zip' => '',
]];

6
Theme/Backend/Lang/en.lang.php Executable file → Normal file
View File

@ -2,9 +2,9 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
@ -16,6 +16,7 @@ return ['Billing' => [
'Address' => 'Address',
'Addresses' => 'Addresses',
'AlreadyPaid' => 'Already Paid',
'Bills' => 'Bills',
'Bonus' => 'Bonus',
'Cashback' => 'Cash Back',
'City' => 'City',
@ -49,6 +50,7 @@ return ['Billing' => [
'Payment' => 'Payment',
'Postal' => 'Postal',
'Prepaid' => 'Prepaid',
'Preview' => 'Preview',
'Price' => 'Price',
'Profit' => 'Profit',
'Quantity' => 'Quantity',