billing draft

This commit is contained in:
Dennis Eichhorn 2021-01-23 12:26:17 +01:00
parent d67c5fc580
commit 6ff583ebed
23 changed files with 1665 additions and 413 deletions

View File

@ -1,359 +1,401 @@
{
"billing_invoice": {
"name": "billing_invoice",
"billing_type": {
"name": "billing_type",
"fields": {
"billing_invoice_id": {
"name": "billing_invoice_id",
"billing_type_id": {
"name": "billing_type_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
}
}
},
"billing_type_l11n": {
"name": "billing_type_l11n",
"fields": {
"billing_type_l11n_id": {
"name": "billing_type_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"billing_invoice_number": {
"name": "billing_invoice_number",
"billing_type_l11n_name": {
"name": "billing_type_l11n_name",
"type": "VARCHAR(255)",
"null": false
},
"billing_invoice_info": {
"name": "billing_invoice_info",
"billing_type_l11n_type": {
"name": "billing_type_l11n_type",
"type": "INT",
"null": false,
"foreignTable": "billing_type",
"foreignKey": "billing_type_id"
},
"billing_type_l11n_language": {
"name": "billing_type_l11n_language",
"type": "VARCHAR(2)",
"default": null,
"null": true,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"billing_out": {
"name": "billing_out",
"fields": {
"billing_out_id": {
"name": "billing_out_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"billing_out_number": {
"name": "billing_out_number",
"type": "VARCHAR(255)",
"null": false
},
"billing_out_info": {
"name": "billing_out_info",
"type": "TEXT",
"default": null,
"null": true
},
"billing_invoice_status": {
"name": "billing_invoice_status",
"billing_out_status": {
"name": "billing_out_status",
"type": "TINYINT",
"null": false
},
"billing_invoice_type": {
"name": "billing_invoice_type",
"type": "TINYINT",
"null": false
},
"billing_invoice_client": {
"name": "billing_invoice_client",
"billing_out_type": {
"name": "billing_out_type",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
"foreignTable": "billing_type",
"foreignKey": "billing_type_id"
},
"billing_invoice_shipTo": {
"name": "billing_invoice_shipTo",
"billing_out_client": {
"name": "billing_out_client",
"type": "INT",
"null": false,
"foreignTable": "clientmgmt_client",
"foreignKey": "clientmgmt_client_id"
},
"billing_out_shipTo": {
"name": "billing_out_shipTo",
"type": "VARCHAR(255)",
"null": false
},
"billing_invoice_shipFAO": {
"name": "billing_invoice_shipFAO",
"billing_out_shipFAO": {
"name": "billing_out_shipFAO",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_shipAddr": {
"name": "billing_invoice_shipAddr",
"billing_out_shipAddr": {
"name": "billing_out_shipAddr",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_shipCity": {
"name": "billing_invoice_shipCity",
"billing_out_shipCity": {
"name": "billing_out_shipCity",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_shipZip": {
"name": "billing_invoice_shipZip",
"billing_out_shipZip": {
"name": "billing_out_shipZip",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_shipCountry": {
"name": "billing_invoice_shipCountry",
"billing_out_shipCountry": {
"name": "billing_out_shipCountry",
"type": "VARCHAR(3)",
"default": null,
"null": true
},
"billing_invoice_billTo": {
"name": "billing_invoice_billTo",
"billing_out_billTo": {
"name": "billing_out_billTo",
"type": "VARCHAR(255)",
"null": false
},
"billing_invoice_billFAO": {
"name": "billing_invoice_billFAO",
"billing_out_billFAO": {
"name": "billing_out_billFAO",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_billAddr": {
"name": "billing_invoice_billAddr",
"billing_out_billAddr": {
"name": "billing_out_billAddr",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_billCity": {
"name": "billing_invoice_billCity",
"billing_out_billCity": {
"name": "billing_out_billCity",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_billZip": {
"name": "billing_invoice_billZip",
"billing_out_billZip": {
"name": "billing_out_billZip",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_billCountry": {
"name": "billing_invoice_billCountry",
"billing_out_billCountry": {
"name": "billing_out_billCountry",
"type": "VARCHAR(3)",
"default": null,
"null": true
},
"billing_invoice_created_at": {
"name": "billing_invoice_created_at",
"billing_out_created_at": {
"name": "billing_out_created_at",
"type": "DATETIME",
"null": false
},
"billing_invoice_created_by": {
"name": "billing_invoice_created_by",
"billing_out_created_by": {
"name": "billing_out_created_by",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
},
"billing_invoice_finished_at": {
"name": "billing_invoice_finished_at",
"type": "DATETIME",
"billing_out_gross": {
"name": "billing_out_gross",
"type": "INT",
"null": false
},
"billing_out_net": {
"name": "billing_out_net",
"type": "INT",
"null": false
},
"billing_out_costs": {
"name": "billing_out_costs",
"type": "INT",
"null": false
},
"billing_out_profit": {
"name": "billing_out_profit",
"type": "INT",
"null": false
},
"billing_out_currency": {
"name": "billing_out_currency",
"type": "INT",
"null": false
},
"billing_out_referral": {
"name": "billing_out_referral",
"type": "INT",
"null": true,
"default": null,
"null": false
},
"billing_invoice_gross": {
"name": "billing_invoice_gross",
"type": "INT",
"null": false
},
"billing_invoice_net": {
"name": "billing_invoice_net",
"type": "INT",
"null": false
},
"billing_invoice_costs": {
"name": "billing_invoice_costs",
"type": "INT",
"null": false
},
"billing_invoice_profit": {
"name": "billing_invoice_profit",
"type": "INT",
"null": false
},
"billing_invoice_currency": {
"name": "billing_invoice_currency",
"type": "INT",
"null": false
},
"billing_invoice_freightage": {
"name": "billing_invoice_freightage",
"type": "INT",
"null": false
},
"billing_invoice_insurance": {
"name": "billing_invoice_insurance",
"type": "INT",
"null": false
},
"billing_invoice_customs": {
"name": "billing_invoice_customs",
"type": "INT",
"null": false
},
"billing_invoice_packaging": {
"name": "billing_invoice_packaging",
"type": "INT",
"null": false
},
"billing_invoice_referral": {
"name": "billing_invoice_referral",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
},
"billing_invoice_referral_name": {
"name": "billing_invoice_referral_name",
"billing_out_referral_name": {
"name": "billing_out_referral_name",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_reference": {
"name": "billing_invoice_reference",
"billing_out_reference": {
"name": "billing_out_reference",
"type": "INT",
"null": false
},
"billing_invoice_payment": {
"name": "billing_invoice_payment",
"billing_out_payment": {
"name": "billing_out_payment",
"type": "INT",
"null": false
},
"billing_invoice_payment_text": {
"name": "billing_invoice_payment_text",
"billing_out_payment_text": {
"name": "billing_out_payment_text",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_terms": {
"name": "billing_invoice_terms",
"billing_out_paymentterms": {
"name": "billing_out_paymentterms",
"type": "INT",
"null": false
},
"billing_invoice_terms_text": {
"name": "billing_invoice_terms_text",
"billing_out_paymentterms_text": {
"name": "billing_out_paymentterms_text",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"billing_invoice_ship_type": {
"name": "billing_invoice_ship_type",
"billing_out_ship_type": {
"name": "billing_out_ship_type",
"type": "INT",
"null": false
},
"billing_invoice_ship_text": {
"name": "billing_invoice_ship_text",
"billing_out_ship_text": {
"name": "billing_bill_ship_text",
"type": "VARCHAR(255)",
"default": null,
"null": true
}
}
},
"billing_element": {
"name": "billing_element",
"billing_out_element": {
"name": "billing_out_element",
"fields": {
"billing_element_id": {
"name": "billing_element_id",
"billing_out_element_id": {
"name": "billing_out_element_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"billing_element_order": {
"name": "billing_element_order",
"type": "SMALLINT",
"null": false
},
"billing_element_item": {
"name": "billing_element_item",
"billing_out_element_order": {
"name": "billing_out_element_order",
"type": "INT",
"null": false
},
"billing_element_item_segment": {
"name": "billing_element_item_segment",
"billing_out_element_item": {
"name": "billing_out_element_item",
"type": "INT",
"null": true,
"default": null
},
"billing_out_element_item_segment": {
"name": "billing_out_element_item_segment",
"type": "INT",
"default": null,
"null": true
},
"billing_element_item_name": {
"name": "billing_element_item_name",
"billing_out_element_item_number": {
"name": "billing_out_element_item_number",
"type": "VARCHAR(255)",
"null": false
},
"billing_element_item_desc": {
"name": "billing_element_item_desc",
"billing_out_element_item_name": {
"name": "billing_out_element_item_name",
"type": "VARCHAR(255)",
"null": false
},
"billing_element_quantity": {
"name": "billing_element_quantity",
"billing_out_element_item_desc": {
"name": "billing_out_element_item_desc",
"type": "VARCHAR(255)",
"null": false
},
"billing_out_element_quantity": {
"name": "billing_out_element_quantity",
"type": "INT",
"null": false
},
"billing_element_purchase_price": {
"name": "billing_element_purchase_price",
"billing_out_element_purchase_price": {
"name": "billing_out_element_purchase_price",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_single": {
"name": "billing_element_price_single",
"billing_out_element_price_single": {
"name": "billing_out_element_price_single",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_total": {
"name": "billing_element_price_total",
"billing_out_element_price_total": {
"name": "billing_out_element_price_total",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_discount_single": {
"name": "billing_element_price_discount_single",
"billing_out_element_price_discount_single": {
"name": "billing_out_element_price_discount_single",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_discount_total": {
"name": "billing_element_price_discount_total",
"billing_out_element_price_discount_total": {
"name": "billing_out_element_price_discount_total",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_percentage_discount_single": {
"name": "billing_element_percentage_discount_single",
"billing_out_element_percentage_discount_single": {
"name": "billing_out_element_percentage_discount_single",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_percentage_discount_total": {
"name": "billing_element_percentage_discount_total",
"billing_out_element_percentage_discount_total": {
"name": "billing_out_element_percentage_discount_total",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_quantity_discount": {
"name": "billing_element_quantity_discount",
"billing_out_element_quantity_discount": {
"name": "billing_out_element_quantity_discount",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_single_net": {
"name": "billing_element_price_single_net",
"billing_out_element_price_single_net": {
"name": "billing_out_element_price_single_net",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_total_net": {
"name": "billing_element_price_total_net",
"billing_out_element_price_total_net": {
"name": "billing_out_element_price_total_net",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_tax_price": {
"name": "billing_element_tax_price",
"billing_out_element_tax_price": {
"name": "billing_out_element_tax_price",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_tax_type": {
"name": "billing_element_tax_type",
"billing_out_element_tax_type": {
"name": "billing_out_element_tax_type",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_tax_percentage": {
"name": "billing_element_tax_percentage",
"billing_out_element_tax_percentage": {
"name": "billing_out_element_tax_percentage",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_single_gross": {
"name": "billing_element_price_single_gross",
"billing_out_element_price_single_gross": {
"name": "billing_out_element_price_single_gross",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_price_total_gross": {
"name": "billing_element_price_total_gross",
"billing_out_element_price_total_gross": {
"name": "billing_out_element_price_total_gross",
"type": "INT",
"null": false
"null": true,
"default": null
},
"billing_element_invoice": {
"name": "billing_element_invoice",
"billing_out_element_bill": {
"name": "billing_out_element_bill",
"type": "INT",
"null": false,
"foreignTable": "billing_invoice",
"foreignKey": "billing_invoice_id"
"foreignTable": "billing_out",
"foreignKey": "billing_out_id"
},
"billing_element_promotion": {
"name": "billing_element_promotion",
"billing_out_element_promotion": {
"name": "billing_out_element_promotion",
"type": "INT",
"default": null,
"null": true
},
"billing_element_event": {
"name": "billing_element_event",
"billing_out_element_event": {
"name": "billing_out_element_event",
"type": "INT",
"default": null,
"null": true

View File

@ -14,7 +14,15 @@ declare(strict_types=1);
namespace Modules\Billing\Admin;
use Modules\Billing\Models\BillType;
use Modules\Billing\Models\BillTypeMapper;
use Modules\Billing\Models\BillTypeL11n;
use Modules\Billing\Models\BillTypeL11nMapper;
use phpOMS\Config\SettingsInterface;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\ModuleInfo;
/**
* Installer class.
@ -26,4 +34,51 @@ use phpOMS\Module\InstallerAbstract;
*/
final class Installer extends InstallerAbstract
{
/**
* {@inheritdoc}
*/
public static function install(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void
{
parent::install($dbPool, $info, $cfgHandler);
self::createBillTypes();
}
/**
* Install default bill types
*
* @return BillType[]
*
* @since 1.0.0
*/
private static function createBillTypes() : array
{
$billType = [];
$billType['offer'] = new BillType('Offer');
BillTypeMapper::create($billType['offer']);
BillTypeL11nMapper::create(new BillTypeL11n($billType['offer']->getId(), 'Angebot', ISO639x1Enum::_DE));
$billType['order_confirmation'] = new BillType('Order Confirmation');
BillTypeMapper::create($billType['order_confirmation']);
BillTypeL11nMapper::create(new BillTypeL11n($billType['order_confirmation']->getId(), 'Auftragsbestaetigung', ISO639x1Enum::_DE));
$billType['delivery_note'] = new BillType('Delivery Note');
BillTypeMapper::create($billType['delivery_note']);
BillTypeL11nMapper::create(new BillTypeL11n($billType['delivery_note']->getId(), 'Lieferschein', ISO639x1Enum::_DE));
$billType['invoice'] = new BillType('Invoice');
BillTypeMapper::create($billType['invoice']);
BillTypeL11nMapper::create(new BillTypeL11n($billType['invoice']->getId(), 'Rechnung', ISO639x1Enum::_DE));
$billType['credit_note'] = new BillType('Credit Note');
BillTypeMapper::create($billType['credit_note']);
BillTypeL11nMapper::create(new BillTypeL11n($billType['credit_note']->getId(), 'Rechnungskorrektur', ISO639x1Enum::_DE));
$billType['reverse_invoice'] = new BillType('Credit Note');
BillTypeMapper::create($billType['reverse_invoice']);
BillTypeL11nMapper::create(new BillTypeL11n($billType['reverse_invoice']->getId(), 'Gutschrift', ISO639x1Enum::_DE));
return $billType;
}
}

View File

@ -28,6 +28,17 @@ return [
],
],
],
'^.*/sales/invoice\?.*$' => [
[
'dest' => '\Modules\Billing\Controller\BackendController:viewBillingInvoice',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::SALES_INVOICE,
],
],
],
'^.*/purchase/invoice/create.*$' => [
[
'dest' => '\Modules\Billing\Controller\BackendController:viewBillingPurchaseInvoiceCreate',

View File

@ -0,0 +1,191 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\Controller;
use Modules\Admin\Models\NullAccount;
use Modules\Billing\Models\Bill;
use Modules\Billing\Models\BillMapper;
use Modules\Billing\Models\BillElement;
use Modules\Billing\Models\BillElementMapper;
use Modules\Billing\Models\NullBillType;
use Modules\ClientManagement\Models\NullClient;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Model\Message\FormValidation;
use phpOMS\Utils\Parser\Markdown\Markdown;
use Modules\ItemManagement\Models\ItemMapper;
/**
* Billing class.
*
* @package Modules\Billing
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ApiController extends Controller
{
/**
* Api method to create a wiki entry
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiBillCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateBillCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$bill = $this->createBillFromRequest($request, $response, $data);
$this->createModel($request->header->account, $bill, BillMapper::class, 'bill', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Bill', 'Bill successfully created.', $bill);
}
/**
* Method to create a wiki entry from request.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return Bill
*
* @since 1.0.0
*/
public function createBillFromRequest(RequestAbstract $request, ResponseAbstract $response, $data = null) : Bill
{
$bill = new Bill();
$bill->setCreatedBy(new NullAccount($request->header->account));
$bill->type = new NullBillType((int) $request->getData('type'));
$bill->client = new NullClient((int) $request->getData('client'));
return $bill;
}
/**
* Method to validate wiki entry creation from request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateBillCreate(RequestAbstract $request) : array
{
$val = [];
/*if (($val['title'] = empty($request->getData('title')))
|| ($val['plain'] = empty($request->getData('plain')))
|| ($val['status'] = (
$request->getData('status') !== null
&& !WikiStatus::isValidValue((int) $request->getData('status'))
))
) {
return $val;
}*/
return [];
}
/**
* Api method to create a wiki entry
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiBillElementCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateBillElementCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$element = $this->createBillElementFromRequest($request, $response, $data);
$this->createModel($request->header->account, $element, BillElementMapper::class, 'bill_element', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Bill element', 'Bill element successfully created.', $element);
}
/**
* Method to create a wiki entry from request.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return BillElement
*
* @since 1.0.0
*/
public function createBillElementFromRequest(RequestAbstract $request, ResponseAbstract $response, $data = null) : BillElement
{
$element = new BillElement();
$element->bill = (int) $request->getData('bill');
$element->item = $request->getData('item', 'int');
if ($element->item !== null) {
$item = ItemMapper::withConditional('language', $response->getLanguage())::get($element->item);
// @todo: which item name should be stored in the database? server language (problem for international company with subsidiaries)? customer default language/customer invoice language?
$element->itemNumber = $item->number;
$element->itemName = $item->getL11n('name1')->description;
$element->quantity = $request->getData('quantity', 'int');;
}
return $element;
}
/**
* Method to validate wiki entry creation from request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateBillElementCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['bill'] = empty($request->getData('bill')))
) {
return $val;
}
return [];
}
}

View File

@ -14,10 +14,14 @@ declare(strict_types=1);
namespace Modules\Billing\Controller;
use Modules\Billing\Models\BillMapper;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
use Modules\Billing\Models\BillType;
use Modules\Billing\Models\BillTypeL11n;
use phpOMS\DataStorage\Database\RelationType;
/**
* Billing class.
@ -44,9 +48,51 @@ final class BackendController extends Controller
public function viewBillingInvoiceList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/invoice-list');
$view->setTemplate('/Modules/Billing/Theme/Backend/sales-bill-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response));
if ($request->getData('ptype') === 'p') {
$view->setData('bills',
BillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
::getBeforePivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 4)
);
} elseif ($request->getData('ptype') === 'n') {
$view->setData('bills',
BillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
::getAfterPivot((int) ($request->getData('id') ?? 0), limit: 25, depth: 4)
);
} else {
$view->setData('bills',
BillMapper::withConditional('language', $response->getLanguage(), [BillTypeL11n::class])
::getAfterPivot(0, limit: 25, depth: 4)
);
}
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 viewBillingInvoice(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/sales-bill');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response));
$bill = BillMapper::get((int) $request->getData('id'));
$view->setData('bill', $bill);
return $view;
}

View File

@ -14,18 +14,20 @@ declare(strict_types=1);
namespace Modules\Billing\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use phpOMS\Localization\ISO4217CharEnum;
use phpOMS\Localization\Money;
/**
* Invoice class.
* Bill class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Invoice implements \JsonSerializable
class Bill implements \JsonSerializable
{
/**
* ID.
@ -44,40 +46,46 @@ class Invoice implements \JsonSerializable
private string $number = '';
/**
* Invoice type.
* Bill type.
*
* @var int|BillType
* @since 1.0.0
*/
public int|BillType $type = 0;
/**
* Bill status.
*
* @var int
* @since 1.0.0
*/
private int $type = InvoiceType::BILL;
private int $status = BillStatus::DRAFT;
/**
* Invoice status.
*
* @var int
* @since 1.0.0
*/
private int $status = InvoiceStatus::DRAFT;
/**
* Invoice created at.
* Bill created at.
*
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $createdAt;
public \DateTimeImmutable $createdAt;
/**
* Invoice send at.
* Bill send at.
*
* @var null|\DateTime
* @since 1.0.0
*/
private ?\DateTime $send = null;
private $createdBy = 0;
/**
* Creator.
*
* @var Account
* @since 1.0.0
*/
public Account $createdBy;
private $client = 0;
public $client = 0;
/**
* Receiver.
@ -181,19 +189,17 @@ class Invoice implements \JsonSerializable
* @var int
* @since 1.0.0
*/
private int $referer = 0;
private $referral;
private $refererName = '';
private $referralName = '';
private $taxId = '';
public ?Money $net = null;
private $insurance = null;
public ?Money $gross = null;
private $freight = null;
public ?Money $costs = null;
private $net = null;
private $gross = null;
public ?Money $profit = null;
private $currency = ISO4217CharEnum::_EUR;
@ -218,7 +224,7 @@ class Invoice implements \JsonSerializable
private $elements = [];
/**
* Reference to other invoice (delivery note/credit note etc).
* Reference to other Bill (delivery note/credit note etc).
*
* @var int
* @since 1.0.0
@ -232,12 +238,40 @@ class Invoice implements \JsonSerializable
*/
public function __construct()
{
$this->insurance = new Money();
$this->freight = new Money();
$this->net = new Money();
$this->gross = new Money();
$this->net = new Money(0);
$this->gross = new Money(0);
$this->costs = new Money(0);
$this->profit = new Money(0);
$this->createdAt = new \DateTime();
$this->createdAt = new \DateTimeImmutable();
$this->createdBy = new NullAccount();
$this->referer = new NullAccount();
}
/**
* Get created by
*
* @return Account
*
* @since 1.0.0
*/
public function getCreatedBy() : Account
{
return $this->createdBy;
}
/**
* Set created by
*
* @param Account $account Created by
*
* @return void
*
* @since 1.0.0
*/
public function setCreatedBy(Account $account) : void
{
$this->createdBy = $account;
}
/**
@ -253,7 +287,7 @@ class Invoice implements \JsonSerializable
}
/**
* Get invoice number.
* Get Bill number.
*
* @return string
*
@ -265,9 +299,9 @@ class Invoice implements \JsonSerializable
}
/**
* Set invoice number.
* Set Bill number.
*
* @param string $number Invoice number
* @param string $number Bill number
*
* @return void
*
@ -368,32 +402,6 @@ class Invoice implements \JsonSerializable
return $this->send;
}
/**
* Get created by
*
* @return int|\phpOMS\Account\Account
*
* @since 1.0.0
*/
public function getCreatedBy()
{
return $this->createdBy;
}
/**
* Set creator.
*
* @param int $creator Creator
*
* @return void
*
* @since 1.0.0
*/
public function setCreatedBy(int $creator) : void
{
$this->createdBy = $creator;
}
/**
* Get client.
*
@ -1149,7 +1157,7 @@ class Invoice implements \JsonSerializable
}
/**
* Get invoice elements.
* Get Bill elements.
*
* @return array
*
@ -1161,9 +1169,9 @@ class Invoice implements \JsonSerializable
}
/**
* Add invoice element.
* Add Bill element.
*
* @param mixed $element Invoice element
* @param mixed $element Bill element
*
* @return void
*

View File

@ -17,14 +17,14 @@ namespace Modules\Billing\Models;
use phpOMS\Localization\Money;
/**
* Invoice class.
* Bill class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class InvoiceElement implements \JsonSerializable
class BillElement implements \JsonSerializable
{
/**
* ID.
@ -34,15 +34,17 @@ class InvoiceElement implements \JsonSerializable
*/
protected int $id = 0;
private $order = 0;
private int $order = 0;
private $item = 0;
public $item = null;
private $itemName = '';
public string $itemNumber = '';
private $itemDescription = '';
public string $itemName = '';
private $quantity = 0;
public string $itemDescription = '';
public int|float $quantity = 0;
private $singlePrice = null;
@ -72,7 +74,7 @@ class InvoiceElement implements \JsonSerializable
private $promotion = 0;
private $invoice = 0;
public $bill = 0;
/**
* Get id.

View File

@ -0,0 +1,75 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @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\ClientManagement\Models\ClientMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Mapper class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class BillElementMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'billing_out_element_id' => ['name' => 'billing_out_element_id', 'type' => 'int', 'internal' => 'id'],
'billing_out_element_order' => ['name' => 'billing_out_element_order', 'type' => 'int', 'internal' => 'order'],
'billing_out_element_item' => ['name' => 'billing_out_element_item', 'type' => 'int', 'internal' => 'item'],
'billing_out_element_item_number' => ['name' => 'billing_out_element_item_number', 'type' => 'string', 'internal' => 'itemNumber'],
'billing_out_element_item_name' => ['name' => 'billing_out_element_item_name', 'type' => 'string', 'internal' => 'itemName'],
'billing_out_element_item_desc' => ['name' => 'billing_out_element_item_desc', 'type' => 'string', 'internal' => 'itemDescription'],
'billing_out_element_quantity' => ['name' => 'billing_out_element_quantity', 'type' => 'int', 'internal' => 'quantity'],
'billing_out_element_bill' => ['name' => 'billing_out_element_bill', 'type' => 'int', 'internal' => 'bill'],
];
/**
* Belongs to.
*
* @var array<string, array{mapper:string, external:string}>
* @since 1.0.0
*/
protected static array $belongsTo = [
'bill' => [
'mapper' => BillMapper::class,
'external' => 'billing_out_element_bill',
],
];
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'billing_out_element_id';
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'billing_out_element';
}

138
Models/BillMapper.php Normal file
View File

@ -0,0 +1,138 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @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\Admin\Models\AccountMapper;
use Modules\ClientManagement\Models\ClientMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Mapper class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class BillMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'billing_out_id' => ['name' => 'billing_out_id', 'type' => 'int', 'internal' => 'id'],
'billing_out_number' => ['name' => 'billing_out_number', 'type' => 'string', 'internal' => 'number'],
'billing_out_type' => ['name' => 'billing_out_type', 'type' => 'int', 'internal' => 'type'],
'billing_out_info' => ['name' => 'billing_out_info', 'type' => 'string', 'internal' => 'info'],
'billing_out_status' => ['name' => 'billing_out_status', 'type' => 'int', 'internal' => 'status'],
'billing_out_shipTo' => ['name' => 'billing_out_shipTo', 'type' => 'string', 'internal' => 'shipTo'],
'billing_out_shipFAO' => ['name' => 'billing_out_shipFAO', 'type' => 'string', 'internal' => 'shipFAO'],
'billing_out_shipAddr' => ['name' => 'billing_out_shipAddr', 'type' => 'string', 'internal' => 'shipAddress'],
'billing_out_shipCity' => ['name' => 'billing_out_shipCity', 'type' => 'string', 'internal' => 'shipCity'],
'billing_out_shipZip' => ['name' => 'billing_out_shipZip', 'type' => 'string', 'internal' => 'shipZip'],
'billing_out_shipCountry' => ['name' => 'billing_out_shipCountry', 'type' => 'string', 'internal' => 'shipCountry'],
'billing_out_billTo' => ['name' => 'billing_out_billTo', 'type' => 'string', 'internal' => 'billTo'],
'billing_out_billFAO' => ['name' => 'billing_out_billFAO', 'type' => 'string', 'internal' => 'billFAO'],
'billing_out_billAddr' => ['name' => 'billing_out_billAddr', 'type' => 'string', 'internal' => 'billAddress'],
'billing_out_billCity' => ['name' => 'billing_out_billCity', 'type' => 'string', 'internal' => 'billCity'],
'billing_out_billZip' => ['name' => 'billing_out_billZip', 'type' => 'string', 'internal' => 'billZip'],
'billing_out_billCountry' => ['name' => 'billing_out_billCountry', 'type' => 'string', 'internal' => 'billCountry'],
'billing_out_gross' => ['name' => 'billing_out_gross', 'type' => 'Serializable', 'internal' => 'gross'],
'billing_out_net' => ['name' => 'billing_out_net', 'type' => 'Serializable', 'internal' => 'net'],
'billing_out_costs' => ['name' => 'billing_out_costs', 'type' => 'Serializable', 'internal' => 'costs'],
'billing_out_profit' => ['name' => 'billing_out_profit', 'type' => 'Serializable', 'internal' => 'profit'],
'billing_out_currency' => ['name' => 'billing_out_currency', 'type' => 'int', 'internal' => 'currency'],
'billing_out_referral' => ['name' => 'billing_out_referral', 'type' => 'int', 'internal' => 'referral'],
'billing_out_referral_name' => ['name' => 'billing_out_referral_name', 'type' => 'string', 'internal' => 'referralName'],
'billing_out_reference' => ['name' => 'billing_out_reference', 'type' => 'int', 'internal' => 'reference'],
'billing_out_payment' => ['name' => 'billing_out_payment', 'type' => 'int', 'internal' => 'payment'],
'billing_out_payment_text' => ['name' => 'billing_out_payment_text', 'type' => 'string', 'internal' => 'paymentText'],
'billing_out_paymentterms' => ['name' => 'billing_out_paymentterms', 'type' => 'int', 'internal' => 'terms'],
'billing_out_paymentterms_text' => ['name' => 'billing_out_paymentterms_text', 'type' => 'string', 'internal' => 'termsText'],
'billing_out_ship_type' => ['name' => 'billing_out_ship_type', 'type' => 'int', 'internal' => 'shipping'],
'billing_out_ship_text' => ['name' => 'billing_out_ship_text', 'type' => 'string', 'internal' => 'shippingText'],
'billing_out_client' => ['name' => 'billing_out_client', 'type' => 'int', 'internal' => 'client'],
'billing_out_created_by' => ['name' => 'billing_out_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'billing_out_created_at' => ['name' => 'billing_out_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'elements' => [
'mapper' => BillElementMapper::class,
'table' => 'billing_out_element',
'self' => 'billing_out_element_bill',
'external' => null,
],
];
/**
* Has one relation.
*
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
protected static array $ownsOne = [
'type' => [
'mapper' => BillTypeMapper::class,
'external' => 'billing_out_type',
],
'referral' => [
'mapper' => AccountMapper::class,
'external' => 'billing_out_referral',
],
];
/**
* Belongs to.
*
* @var array<string, array{mapper:string, external:string}>
* @since 1.0.0
*/
protected static array $belongsTo = [
'createdBy' => [
'mapper' => AccountMapper::class,
'external' => 'billing_out_created_by',
],
'client' => [
'mapper' => ClientMapper::class,
'external' => 'billing_out_client',
],
];
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'billing_out_id';
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'billing_out';
}

View File

@ -24,7 +24,7 @@ use phpOMS\Stdlib\Base\Enum;
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class InvoiceStatus extends Enum
abstract class BillStatus extends Enum
{
public const ACTIVE = 1;
public const ARCHIVED = 2;

100
Models/BillType.php Normal file
View File

@ -0,0 +1,100 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @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 phpOMS\Localization\ISO639x1Enum;
/**
* Task type enum.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class BillType
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Localization
*
* @var int|int[]|BillTypeL11n|BillTypeL11n[]
*/
protected $l11n = 0;
/**
* Constructor.
*
* @param string $name Name/identifier of the attribute type
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->setL11n($name);
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set l11n
*
* @param string|BillTypeL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n($l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof BillTypeL11n) {
$this->l11n = $l11n;
} elseif ($this->l11n instanceof BillTypeL11n && \is_string($l11n)) {
$this->l11n->name = $l11n;
} elseif (\is_string($l11n)) {
$this->l11n = new BillTypeL11n();
$this->l11n->name = $l11n;
$this->l11n->setLanguage($lang);
}
}
/**
* @return string
*
* @since 1.0.0
*/
public function getL11n() : string
{
return $this->l11n instanceof BillTypeL11n ? $this->l11n->name : $this->l11n;
}
}

162
Models/BillTypeL11n.php Normal file
View File

@ -0,0 +1,162 @@
<?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 phpOMS\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Billing class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class BillTypeL11n implements \JsonSerializable, ArrayableInterface
{
/**
* Type ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Type.
*
* @var int
* @since 1.0.0
*/
protected int|BillType $type = 0;
/**
* Language.
*
* @var string
* @since 1.0.0
*/
protected string $language = ISO639x1Enum::_EN;
/**
* Name.
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* Constructor.
*
* @param int|BillType $type Attribute type
* @param string $name Localized name
* @param string $language Language
*
* @since 1.0.0
*/
public function __construct(int|BillType $type = 0, string $name = '', string $language = ISO639x1Enum::_EN)
{
$this->type = $type;
$this->name = $name;
$this->language = $language;
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set type.
*
* @param int $type Type id
*
* @return void
*
* @since 1.0.0
*/
public function setBillType(int $type) : void
{
$this->type = $type;
}
/**
* Get type
*
* @return int
*
* @since 1.0.0
*/
public function getType() : int
{
return $this->type;
}
/**
* Get language
*
* @return string
*
* @since 1.0.0
*/
public function getLanguage() : string
{
return $this->language;
}
/**
* Set language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
'type' => $this->type,
'language' => $this->language,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,57 @@
<?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 phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Bill type mapper class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class BillTypeL11nMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'billing_type_l11n_id' => ['name' => 'billing_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
'billing_type_l11n_name' => ['name' => 'billing_type_l11n_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'billing_type_l11n_type' => ['name' => 'billing_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
'billing_type_l11n_language' => ['name' => 'billing_type_l11n_language', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'billing_type_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'billing_type_l11n_id';
}

94
Models/BillTypeMapper.php Normal file
View File

@ -0,0 +1,94 @@
<?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 phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Billing mapper class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class BillTypeMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'billing_type_id' => ['name' => 'billing_type_id', 'type' => 'int', 'internal' => 'id'],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'l11n' => [
'mapper' => BillTypeL11nMapper::class,
'table' => 'billing_type_l11n',
'self' => 'billing_type_l11n_type',
'column' => 'name',
'conditional' => true,
'external' => null,
],
];
/**
* Belongs to.
*
* @var array<string, array{mapper:string, self:string}>
* @since 1.0.0
*/
/*
protected static array $belongsTo = [
'owner' => [
'mapper' => AccountMapper::class,
'external' => 'billing_type_owner',
],
];
*/
/**
* Model to use by the mapper.
*
* @var string
* @since 1.0.0
*/
protected static string $model = BillType::class;
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'billing_type';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'billing_type_id';
}

View File

@ -1,44 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @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 phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Mapper class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class InvoiceMapper extends DataMapperAbstract
{
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'billing_invoice_id';
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'billing_invoice';
}

27
Models/NullBill.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package phpOMS\Account
* @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;
/**
* Null account class.
*
* @package phpOMS\Account
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullBill extends Bill
{
}

View File

@ -2,7 +2,7 @@
/**
* Orange Management
*
* PHP Version 7.4
* PHP Version 8.0
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
@ -14,22 +14,26 @@ declare(strict_types=1);
namespace Modules\Billing\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Task type enum.
* Null account class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class InvoiceType extends Enum
final class NullBillType extends BillType
{
public const BILL = 1;
public const DELIVERY_NOTE = 2;
public const CREDIT_NOTE = 3;
public const DEBIT_NOTE = 4;
public const OFFER = 5;
public const ORDER_CONFIRMATION = 6;
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -135,22 +135,22 @@ echo $this->getData('nav')->render(); ?>
<thead>
<tr>
<td>
<td><?= $this->getHtml('Item') ?>
<td><?= $this->getHtml('Variation') ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td><?= $this->getHtml('Quantity') ?>
<td><?= $this->getHtml('Discount') ?>
<td><?= $this->getHtml('DiscountP') ?>
<td><?= $this->getHtml('Bonus') ?>
<td><?= $this->getHtml('Tax') ?>
<td><?= $this->getHtml('Net') ?>
<td><?= $this->getHtml('Item'); ?>
<td><?= $this->getHtml('Variation'); ?>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Quantity'); ?>
<td><?= $this->getHtml('Discount'); ?>
<td><?= $this->getHtml('DiscountP'); ?>
<td><?= $this->getHtml('Bonus'); ?>
<td><?= $this->getHtml('Tax'); ?>
<td><?= $this->getHtml('Net'); ?>
<tfoot>
<tr>
<td colspan="8">
<?= $this->getHtml('Freightage') ?>: 0.00 -
<?= $this->getHtml('Net') ?>: 0.00 -
<?= $this->getHtml('Tax') ?>: 0.00 -
<?= $this->getHtml('Total') ?>: 0.00
<?= $this->getHtml('Freightage'); ?>: 0.00 -
<?= $this->getHtml('Net'); ?>: 0.00 -
<?= $this->getHtml('Tax'); ?>: 0.00 -
<?= $this->getHtml('Total'); ?>: 0.00
<tbody>
<tr>
<td><i class="fa fa-plus"></i> <i class="fa fa-chevron-up"></i> <i class="fa fa-chevron-down"></i>
@ -215,15 +215,15 @@ echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Media') ?></h1></header>
<header><h1><?= $this->getHtml('Media'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tbody>
<tr><td colspan="2"><label for="iMedia"><?= $this->getHtml('Media') ?></label>
<tr><td><input type="text" id="iMedia" placeholder="&#xf15b; File"><td><button><?= $this->getHtml('Select') ?></button>
<tr><td colspan="2"><label for="iUpload"><?= $this->getHtml('Upload') ?></label>
<tr><td colspan="2"><label for="iMedia"><?= $this->getHtml('Media'); ?></label>
<tr><td><input type="text" id="iMedia" placeholder="&#xf15b; File"><td><button><?= $this->getHtml('Select'); ?></button>
<tr><td colspan="2"><label for="iUpload"><?= $this->getHtml('Upload'); ?></label>
<tr><td><input type="file" id="iUpload" form="fTask"><input form="fTask" type="hidden" name="type"><td>
</table>
</form>
@ -249,9 +249,9 @@ echo $this->getData('nav')->render(); ?>
<tr>
<td>IP
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Name') ?>
<td class="wf-100"><?= $this->getHtml('Log') ?>
<td><?= $this->getHtml('Date') ?>
<td><?= $this->getHtml('Name'); ?>
<td class="wf-100"><?= $this->getHtml('Log'); ?>
<td><?= $this->getHtml('Date'); ?>
<tfoot>
<tr>
<td colspan="6">

View File

@ -1,51 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Invoices'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Type') ?>
<td><?= $this->getHtml('ClientID') ?>
<td class="wf-100"><?= $this->getHtml('Client') ?>
<td><?= $this->getHtml('Net') ?>
<td><?= $this->getHtml('Gross') ?>
<td><?= $this->getHtml('Created') ?>
<td><?= $this->getHtml('Due') ?>
<tfoot>
<tr>
<td colspan="8">
<tbody>
<?php $count = 0; foreach ([] as $key => $value) : ++$count; ?>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="8" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -1,18 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render();

View File

@ -28,13 +28,13 @@ echo $this->getData('nav')->render(); ?>
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Type') ?>
<td><?= $this->getHtml('SupplierID') ?>
<td class="wf-100"><?= $this->getHtml('Supplier') ?>
<td><?= $this->getHtml('Net') ?>
<td><?= $this->getHtml('Gross') ?>
<td><?= $this->getHtml('Created') ?>
<td><?= $this->getHtml('Due') ?>
<td><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('SupplierID'); ?>
<td class="wf-100"><?= $this->getHtml('Supplier'); ?>
<td><?= $this->getHtml('Net'); ?>
<td><?= $this->getHtml('Gross'); ?>
<td><?= $this->getHtml('Created'); ?>
<td><?= $this->getHtml('Due'); ?>
<tfoot>
<tr>
<td colspan="8">

View File

@ -0,0 +1,66 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
$bills = $this->getData('bills') ?? [];
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Invoices'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="billList" class="default">
<thead>
<tr>
<td><?= $this->getHtml('Id', '', ''); ?>
<td><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('ClientID'); ?>
<td class="wf-100"><?= $this->getHtml('Client'); ?>
<td class="wf-100"><?= $this->getHtml('Address'); ?>
<td class="wf-100"><?= $this->getHtml('Postal'); ?>
<td class="wf-100"><?= $this->getHtml('City'); ?>
<td class="wf-100"><?= $this->getHtml('Country'); ?>
<td><?= $this->getHtml('Net'); ?>
<td><?= $this->getHtml('Gross'); ?>
<td><?= $this->getHtml('Profit'); ?>
<td><?= $this->getHtml('Created'); ?>
<tbody>
<?php $count = 0; foreach ($bills as $key => $value) :
++$count;
$url = UriFactory::build('{/prefix}sales/invoice?{?}&id=' . $value->getId());
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->type->getL11n(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->client->number; ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->client->profile->account->name3 . ' ' . $value->client->profile->account->name2 . ' ' . $value->client->profile->account->name1); ?></a>
<td><a href="<?= $url; ?>"><?= $value->client->mainAddress->address; ?></a>
<td><a href="<?= $url; ?>"><?= $value->client->mainAddress->postal; ?></a>
<td><a href="<?= $url; ?>"><?= $value->client->mainAddress->city; ?></a>
<td><a href="<?= $url; ?>"><?= $value->client->mainAddress->getCountry(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->net->getCurrency(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->gross->getCurrency(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->profit->getCurrency(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->createdAt->format('Y-m-d'); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="9" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,287 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
$bill = $this->getData('bill');
$elements = $bill->getElements();
echo $this->getData('nav')->render(); ?>
<div class="tabview tab-2">
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Invoice'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Items'); ?></label></li>
<li><label for="c-tab-3">Preview</label></li>
<li><label for="c-tab-4"><?= $this->getHtml('Payment'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Media'); ?></label></li>
<li><label for="c-tab-6"><?= $this->getHtml('Logs'); ?></label></li>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2" checked>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<form>
<div class="portlet-head"><?= $this->getHtml('Invoice'); ?></div>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td><label for="iSource"><?= $this->getHtml('Source'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iSource" name="source"></span>
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option><?= $this->getHtml('Invoice'); ?>
<option><?= $this->getHtml('Offer'); ?>
<option><?= $this->getHtml('Confirmation'); ?>
<option><?= $this->getHtml('DeliveryNote'); ?>
<option><?= $this->getHtml('CreditNote'); ?>
</select>
<tr><td><label for="iClient"><?= $this->getHtml('Client'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iClient" name="client"></span>
<tr><td><label for="iDelivery"><?= $this->getHtml('Delivery'); ?></label>
<tr><td><input type="datetime-local" id="iDelivery" name="delivery">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iFreightage"><?= $this->getHtml('Freightage'); ?></label>
<tr><td><input type="number" id="iFreightage" name="freightage">
<tr><td><label for="iShipment"><?= $this->getHtml('Shipment'); ?></label>
<tr><td><select id="iShipment" name="shipment">
<option>
</select>
<tr><td><label for="iTermsOfDelivery"><?= $this->getHtml('TermsOfDelivery'); ?></label>
<tr><td><select id="iTermsOfDelivery" name="termsofdelivery">
<option>
</select>
</table>
</div>
<div class="portlet-foot"><input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>"></div>
</form>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Invoice'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iAddressS"><?= $this->getHtml('Addresses'); ?></label>
<tr><td><select id="iAddressS" name="addressS">
<option>
</select>
<tr><td><label for="iIRecipient"><?= $this->getHtml('Recipient'); ?></label>
<tr><td><input type="text" id="iIRecipient" name="irecipient">
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input type="text" id="iZip" name="zip">
<tr><td><label for="iCity"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iCity" name="city">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input type="text" id="iCountry" name="country">
</table>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Delivery'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iAddressS"><?= $this->getHtml('Addresses'); ?></label>
<tr><td><select id="iAddressS" name="addressS">
<option>
</select>
<tr><td><label for="iDRecipient"><?= $this->getHtml('Recipient'); ?></label>
<tr><td><input type="text" id="iDRecipient" name="drecipient">
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input type="text" id="iZip" name="zip">
<tr><td><label for="iCity"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iCity" name="city">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input type="text" id="iCountry" name="country">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Invoice'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table class="default">
<thead>
<tr>
<td>
<td><?= $this->getHtml('Item'); ?>
<td><?= $this->getHtml('Variation'); ?>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Quantity'); ?>
<td><?= $this->getHtml('Discount'); ?>
<td><?= $this->getHtml('DiscountP'); ?>
<td><?= $this->getHtml('Bonus'); ?>
<td><?= $this->getHtml('Tax'); ?>
<td><?= $this->getHtml('Net'); ?>
<tbody>
<?php foreach ($elements as $element) : ?>
<tr>
<td><i class="fa fa-plus"></i> <i class="fa fa-chevron-up"></i> <i class="fa fa-chevron-down"></i>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" value="<?= $element->itemNumber; ?>" required></span>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" required></span>
<td><textarea required><?= $element->itemName; ?></textarea>
<td><input type="number" min="0" value="0" required>
<td><input type="number" min="0">
<td><input type="number" min="0" max="100" step="any">
<td><input type="number" min="0" step="any">
<td><input type="number" min="0" step="any">
<td>
<?php endforeach; ?>
<tr>
<td><i class="fa fa-plus"></i> <i class="fa fa-chevron-up"></i> <i class="fa fa-chevron-down"></i>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" required></span>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" required></span>
<td><textarea required></textarea>
<td><input type="number" min="0" value="0" required>
<td><input type="number" min="0">
<td><input type="number" min="0" max="100" step="any">
<td><input type="number" min="0" step="any">
<td><input type="number" min="0" step="any">
<td>
</table>
<div class="portlet-foot">
<?= $this->getHtml('Freightage'); ?>: 0.00 -
<?= $this->getHtml('Net'); ?>: 0.00 -
<?= $this->getHtml('Tax'); ?>: 0.00 -
<?= $this->getHtml('Total'); ?>: 0.00
</div>
</div>
</div>
</div>
</div>
<input type="radio" id="c-tab-3" name="tabular-2">
<div class="tab">
</div>
<input type="radio" id="c-tab-4" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Payment'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option>
</select>
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option><?= $this->getHtml('MoneyTransfer'); ?>
<option><?= $this->getHtml('Prepaid'); ?>
<option><?= $this->getHtml('AlreadyPaid'); ?>
<option><?= $this->getHtml('CreditCard'); ?>
<option><?= $this->getHtml('DirectDebit'); ?>
</select>
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?> - <?= $this->getHtml('Cashback'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iCashBack"><?= $this->getHtml('Cashback'); ?></label>
<tr><td><input type="number" id="iCashBack" name="cashback">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?> - <?= $this->getHtml('Cashback'); ?> 2</label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iCashBack2"><?= $this->getHtml('Cashback'); ?> 2</label>
<tr><td><input type="number" id="iCashBack2" name="cashback2">
<tr><td><input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Media'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tbody>
<tr><td colspan="2"><label for="iMedia"><?= $this->getHtml('Media'); ?></label>
<tr><td><input type="text" id="iMedia" placeholder="&#xf15b; File"><td><button><?= $this->getHtml('Select'); ?></button>
<tr><td colspan="2"><label for="iUpload"><?= $this->getHtml('Upload'); ?></label>
<tr><td><input type="file" id="iUpload" form="fTask"><input form="fTask" type="hidden" name="type"><td>
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-6" name="tabular-2">
<div class="tab">
<?php
$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Logs'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td>IP
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Name'); ?>
<td class="wf-100"><?= $this->getHtml('Log'); ?>
<td><?= $this->getHtml('Date'); ?>
<tfoot>
<tr>
<td colspan="6">
<tbody>
<tr>
<td><?= $this->printHtml($this->request->getOrigin()); ?>
<td><?= $this->printHtml((string) $this->request->header->account); ?>
<td><?= $this->printHtml((string) $this->request->header->account); ?>
<td>Create Invoice
<td><?= $this->printHtml((new \DateTime('now'))->format('Y-m-d H:i:s')); ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>