From 155d684128b139fabcaa1bbd9739b0e4f5ede441 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 26 Jan 2023 21:54:13 +0100 Subject: [PATCH] org -> unit change, some new functionality --- Admin/Install/Media.php | 6 +- Admin/Install/Workflow.install.json | 151 +++++++++++++++++++++++++ Admin/Install/Workflow.php | 43 +++++++ Admin/Install/db.json | 78 +++++-------- Controller/ApiController.php | 9 +- Models/Bill.php | 16 +++ Models/BillMapper.php | 2 + info.json | 3 +- tests/Controller/ApiControllerTest.php | 2 +- 9 files changed, 251 insertions(+), 59 deletions(-) create mode 100644 Admin/Install/Workflow.install.json create mode 100644 Admin/Install/Workflow.php diff --git a/Admin/Install/Media.php b/Admin/Install/Media.php index f898c6f..ad827d8 100755 --- a/Admin/Install/Media.php +++ b/Admin/Install/Media.php @@ -53,8 +53,7 @@ class Media SettingsEnum::PREVIEW_MEDIA_TYPE, (string) $preivewType, '\\d+', - null, - 'Billing' + module: 'Billing' ) ); @@ -65,8 +64,7 @@ class Media SettingsEnum::ORIGINAL_MEDIA_TYPE, (string) $originalType, '\\d+', - null, - 'Billing' + module: 'Billing' ) ); } diff --git a/Admin/Install/Workflow.install.json b/Admin/Install/Workflow.install.json new file mode 100644 index 0000000..37cea90 --- /dev/null +++ b/Admin/Install/Workflow.install.json @@ -0,0 +1,151 @@ +{ + "triggers": [ + "PRE:Module:Billing:bill-create", + "POST:Module:Billing:bill-create", + "PRE:Module:Billing:bill-update", + "POST:Module:Billing:bill-update", + "PRE:Module:Billing:bill-delete", + "POST:Module:Billing:bill-delete", + + "PRE:Module:Billing:bill_element-create", + "POST:Module:Billing:bill_element-create", + "PRE:Module:Billing:bill_element-update", + "POST:Module:Billing:bill_element-update", + "PRE:Module:Billing:bill_element-delete", + "POST:Module:Billing:bill_element-delete", + + "PRE:Module:Billing:bill_media-create", + "POST:Module:Billing:bill_media-create", + "PRE:Module:Billing:bill_media-update", + "POST:Module:Billing:bill_media-update", + "PRE:Module:Billing:bill_media-delete", + "POST:Module:Billing:bill_media-delete", + + "PRE:Module:Billing:bill_note-create", + "POST:Module:Billing:bill_note-create", + "PRE:Module:Billing:bill_note-update", + "POST:Module:Billing:bill_note-update", + "PRE:Module:Billing:bill_note-delete", + "POST:Module:Billing:bill_note-delete" + ], + "actions": { + "1005100001": { + "name": "Find Subscripctions", + "description": { + "en": "Finds subscriptions", + "de": "Findet Abonnements" + }, + "function_type": "API", + "function": "apiSubscriptionFind", + "inputs": [ + "date_start", + "date_end", + "client[]", + "payment_type", + "{*}" + ], + "outputs": [ + "subscription[]", + "{*}" + ], + "settings": { + "date_start": { + "type": "input", + "subtype": "datetime", + "default": "now", + "required": true, + "title": { + "en": "Start", + "de": "Start" + } + }, + "date_end": { + "type": "input", + "subtype": "datetime", + "default": null, + "required": false, + "title": { + "en": "End", + "de": "End" + } + }, + "client": { + "type": "input", + "subtype": "text", + "default": "*", + "pattern": "/(^\\*$)|(^(\\d+)(,\\s*\\d+)*$)/", + "examples": [ + "*", + "12,654,789" + ], + "required": true, + "title": { + "en": "Client ID", + "de": "Kundennummer" + }, + "description": { + "en": "The client IDs of the clients. Use * to get all clients or a comma separated list to specify specific clients.", + "de": "Die Kundennummern. Benutzen Sie * um alle Kunden auszuwählen oder eine durch Kommas getrennte Liste von mehreren Kundennummern." + } + }, + "payment_type": { + "type": "select", + "subtype": null, + "default": "cc", + "required": true, + "title": { + "en": "Payment type", + "de": "Zahlungsart" + }, + "options": [ + { + "value": "cc", + "text": { + "en": "Credit Card", + "de": "Kreditkarte" + } + } + ] + } + } + }, + "1005100002": { + "name": "Invoice for Subscription", + "description": { + "en": "Creates invoices for subscriptions", + "de": "Erstellt Rechnungen für Abonnements" + }, + "function_type": "API", + "function": "apiInvoiceFromSubscriptionCreate", + "inputs": [ + "subscription[]", + "{*}" + ], + "outputs": [ + "invoice[]", + "{*}" + ], + "settings": { + "subscription": { + "type": "input", + "subtype": "text", + "default": "*", + "pattern": "/(^\\*$)|(^(\\d+)(,\\s*\\d+)*$)/", + "examples": [ + "*", + "12,654,789" + ], + "required": true, + "title": { + "en": "Subscription ID", + "de": "Abonnement ID" + }, + "description": { + "en": "The subscription IDs of the subscriptions. Use * to get all subscriptions or a comma separated list to specify specific subscriptions.", + "de": "Die Abonnement ID. Benutzen Sie * um alle Abonnements auszuwählen oder eine durch Kommas getrennte Liste von mehreren Abonnement IDs." + } + } + } + } + } +} \ No newline at end of file diff --git a/Admin/Install/Workflow.php b/Admin/Install/Workflow.php new file mode 100644 index 0000000..c87223d --- /dev/null +++ b/Admin/Install/Workflow.php @@ -0,0 +1,43 @@ + __DIR__ . '/Workflow.install.json']); + } +} diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 356ea2f..39f6fd8 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -37,6 +37,12 @@ "name": "billing_type_transfer_stock", "type": "TINYINT(1)", "null": false + }, + "billing_type_is_template": { + "description": "What kind of bill is it?", + "name": "billing_type_is_template", + "type": "TINYINT", + "null": false } } }, @@ -95,8 +101,7 @@ "billing_bill_info": { "name": "billing_bill_info", "type": "TEXT", - "default": null, - "null": true + "null": false }, "billing_bill_status": { "name": "billing_bill_status", @@ -126,6 +131,16 @@ "foreignTable": "clientmgmt_client", "foreignKey": "clientmgmt_client_id" }, + "billing_bill_header": { + "name": "billing_bill_header", + "type": "TEXT", + "null": false + }, + "billing_bill_footer": { + "name": "billing_bill_footer", + "type": "TEXT", + "null": false + }, "billing_bill_stock_from": { "name": "billing_bill_stock_from", "type": "INT", @@ -635,55 +650,20 @@ "foreignTable": "billing_bill", "foreignKey": "billing_bill_id" }, - "billing_bill_subscription_start": { - "name": "billing_bill_subscription_start", - "type": "DATETIME", - "null": false + "billing_bill_subscription_schedule": { + "name": "billing_bill_subscription_schedule", + "type": "INT", + "null": false, + "foreignTable": "schedule", + "foreignKey": "schedule_id" }, - "billing_bill_subscription_end": { - "name": "billing_bill_subscription_end", - "type": "DATETIME", - "null": false - }, - "billing_bill_subscription_numberofoccurrences": { - "name": "billing_bill_subscription_numberofoccurrences", + "billing_bill_subscription_account": { + "name": "billing_bill_subscription_account", "type": "TINYINT(1)", - "null": false - }, - "billing_bill_subscription_pattern_numberofoccurrences": { - "name": "billing_bill_subscription_pattern_numberofoccurrences", - "type": "TINYINT(1)", - "null": false - }, - "billing_bill_subscription_pattern_type": { - "name": "billing_bill_subscription_pattern_type", - "type": "TINYINT(1)", - "null": false - }, - "billing_bill_subscription_pattern_pattern_interval": { - "name": "billing_bill_subscription_pattern_pattern_interval", - "type": "TINYINT(1)", - "null": false - }, - "billing_bill_subscription_pattern_dayofmonth": { - "name": "billing_bill_subscription_pattern_dayofmonth", - "type": "TINYINT(1)", - "null": false - }, - "billing_bill_subscription_pattern_daysofweek": { - "name": "billing_bill_subscription_pattern_daysofweek", - "type": "TINYINT(1)", - "null": false - }, - "billing_bill_subscription_pattern_index": { - "name": "billing_bill_subscription_pattern_index", - "type": "TINYINT(1)", - "null": false - }, - "billing_bill_subscription_pattern_month": { - "name": "billing_bill_subscription_pattern_month", - "type": "TINYINT(1)", - "null": false + "null": true, + "default": null, + "foreignTable": "account", + "foreignKey": "account_id" } } }, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 0726099..2077c39 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -38,6 +38,7 @@ use Modules\Media\Models\UploadStatus; use Modules\SupplierManagement\Models\NullSupplier; use Modules\SupplierManagement\Models\SupplierMapper; use phpOMS\Autoloader; +use phpOMS\Localization\ISO639x1Enum; use phpOMS\Localization\Money; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; @@ -293,7 +294,7 @@ final class ApiController extends Controller $bill->getId(), $media->getId(), BillMapper::class, - 'media', + 'bill_media', '', $request->getOrigin() ); @@ -321,7 +322,7 @@ final class ApiController extends Controller $bill->getId(), $media, BillMapper::class, - 'media', + 'bill_media', '', $request->getOrigin() ); @@ -581,7 +582,7 @@ final class ApiController extends Controller $bill->getId(), $media->getId(), BillMapper::class, - 'media', + 'bill_media', '', $request->getOrigin() ); @@ -639,7 +640,7 @@ final class ApiController extends Controller } $model = $response->get($request->uri->__toString())['response']; - $this->createModelRelation($request->header->account, $request->getData('id'), $model->getId(), BillMapper::class, 'notes', '', $request->getOrigin()); + $this->createModelRelation($request->header->account, $request->getData('id'), $model->getId(), BillMapper::class, 'bill_note', '', $request->getOrigin()); } /** diff --git a/Models/Bill.php b/Models/Bill.php index e5536dc..407496b 100755 --- a/Models/Bill.php +++ b/Models/Bill.php @@ -312,6 +312,22 @@ class Bill implements \JsonSerializable */ private string $currency = ISO4217CharEnum::_EUR; + /** + * Info text. + * + * @var string + * @since 1.0.0 + */ + public string $header = ''; + + /** + * Info text. + * + * @var string + * @since 1.0.0 + */ + public string $footer = ''; + /** * Info text. * diff --git a/Models/BillMapper.php b/Models/BillMapper.php index 5edc4d2..043b2e1 100755 --- a/Models/BillMapper.php +++ b/Models/BillMapper.php @@ -42,6 +42,8 @@ class BillMapper extends DataMapperFactory 'billing_bill_number' => ['name' => 'billing_bill_number', 'type' => 'string', 'internal' => 'number'], 'billing_bill_numberformat' => ['name' => 'billing_bill_numberformat', 'type' => 'string', 'internal' => 'numberFormat'], 'billing_bill_type' => ['name' => 'billing_bill_type', 'type' => 'int', 'internal' => 'type'], + 'billing_bill_header' => ['name' => 'billing_bill_header', 'type' => 'string', 'internal' => 'header'], + 'billing_bill_footer' => ['name' => 'billing_bill_footer', 'type' => 'string', 'internal' => 'footer'], 'billing_bill_info' => ['name' => 'billing_bill_info', 'type' => 'string', 'internal' => 'info'], 'billing_bill_status' => ['name' => 'billing_bill_status', 'type' => 'int', 'internal' => 'status'], 'billing_bill_shipTo' => ['name' => 'billing_bill_shipTo', 'type' => 'string', 'internal' => 'shipTo'], diff --git a/info.json b/info.json index f299346..63015f3 100755 --- a/info.json +++ b/info.json @@ -26,7 +26,8 @@ }, "providing": { "Navigation": "*", - "Media": "*" + "Media": "*", + "Workflow": "*" }, "load": [ { diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 9275991..ecd866b 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -57,7 +57,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase }; $this->app->dbPool = $GLOBALS['dbpool']; - $this->app->orgId = 1; + $this->app->unitId = 1; $this->app->accountManager = new AccountManager($GLOBALS['session']); $this->app->appSettings = new CoreSettings(); $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');