From a7b5f4ef05609e4c78d86e30cd5b0a29df8ba3bc Mon Sep 17 00:00:00 2001 From: NicoleNG18 Date: Sun, 29 Mar 2026 21:55:53 +0300 Subject: [PATCH] add regex to IBAN field --- codbex-payments/codbex-payments.edm | 26 +- codbex-payments/codbex-payments.gen | 56 ++- codbex-payments/codbex-payments.model | 16 +- .../CustomerPaymentController.ts | 8 +- .../EmployeePaymentController.ts | 8 +- .../PaymentAdjustmentController.ts | 2 +- .../PaymentRecord/PaymentRecordController.ts | 8 +- .../Settings/PaymentDirectionController.ts | 2 +- .../api/Settings/PaymentTypeController.ts | 2 +- .../SupplierPaymentController.ts | 8 +- .../CustomerPayment.extensionpoint | 4 - .../CustomerPaymentRepository.ts | 422 ---------------- .../EmployeePayment.extensionpoint | 4 - .../EmployeePaymentRepository.ts | 422 ---------------- .../PaymentAdjustment.extensionpoint | 4 - .../PaymentAdjustmentRepository.ts | 298 ------------ .../PaymentRecord.extensionpoint | 4 - .../PaymentRecord/PaymentRecordRepository.ts | 450 ------------------ .../Settings/PaymentDirection.extensionpoint | 4 - .../Settings/PaymentDirectionRepository.ts | 198 -------- .../dao/Settings/PaymentType.extensionpoint | 4 - .../dao/Settings/PaymentTypeRepository.ts | 198 -------- .../SupplierPayment.extensionpoint | 4 - .../SupplierPaymentRepository.ts | 422 ---------------- .../codbex-payments/dao/utils/EntityUtils.ts | 20 - .../CustomerPaymentRepository.ts | 20 +- .../EmployeePaymentRepository.ts | 20 +- .../PaymentAdjustmentRepository.ts | 20 +- .../PaymentRecord/PaymentRecordRepository.ts | 22 +- .../Settings/PaymentDirectionRepository.ts | 2 +- .../data/Settings/PaymentTypeRepository.ts | 2 +- .../SupplierPaymentRepository.ts | 20 +- .../CustomerPayment/dialog-window/index.html | 6 +- .../CustomerPayment/main-details/index.html | 6 +- .../EmployeePayment/dialog-window/index.html | 6 +- .../EmployeePayment/main-details/index.html | 6 +- .../PaymentRecord/dialog-window/index.html | 6 +- .../PaymentRecord/main-details/index.html | 6 +- .../SupplierPayment/dialog-window/index.html | 6 +- .../SupplierPayment/main-details/index.html | 6 +- 40 files changed, 223 insertions(+), 2525 deletions(-) delete mode 100644 codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPayment.extensionpoint delete mode 100644 codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPaymentRepository.ts delete mode 100644 codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePayment.extensionpoint delete mode 100644 codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePaymentRepository.ts delete mode 100644 codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustment.extensionpoint delete mode 100644 codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustmentRepository.ts delete mode 100644 codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecord.extensionpoint delete mode 100644 codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecordRepository.ts delete mode 100644 codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirection.extensionpoint delete mode 100644 codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirectionRepository.ts delete mode 100644 codbex-payments/gen/codbex-payments/dao/Settings/PaymentType.extensionpoint delete mode 100644 codbex-payments/gen/codbex-payments/dao/Settings/PaymentTypeRepository.ts delete mode 100644 codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPayment.extensionpoint delete mode 100644 codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPaymentRepository.ts delete mode 100644 codbex-payments/gen/codbex-payments/dao/utils/EntityUtils.ts diff --git a/codbex-payments/codbex-payments.edm b/codbex-payments/codbex-payments.edm index a1f258d..98765c8 100644 --- a/codbex-payments/codbex-payments.edm +++ b/codbex-payments/codbex-payments.edm @@ -5,8 +5,8 @@ - - + + @@ -23,8 +23,8 @@ - - + + @@ -41,8 +41,8 @@ - - + + @@ -58,8 +58,8 @@ - - + + @@ -104,11 +104,11 @@ - + - + @@ -153,11 +153,11 @@ - + - + @@ -205,5 +205,5 @@ - + \ No newline at end of file diff --git a/codbex-payments/codbex-payments.gen b/codbex-payments/codbex-payments.gen index 3b77427..adacd1d 100644 --- a/codbex-payments/codbex-payments.gen +++ b/codbex-payments/codbex-payments.gen @@ -392,6 +392,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -407,7 +408,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -421,6 +422,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -436,7 +438,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -899,6 +901,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -914,7 +917,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -928,6 +931,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -943,7 +947,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -1319,6 +1323,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -1334,7 +1339,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -1348,6 +1353,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -1363,7 +1369,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -1824,6 +1830,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -1839,7 +1846,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -1853,6 +1860,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -1868,7 +1876,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -2301,6 +2309,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -2316,7 +2325,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -2330,6 +2339,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -2345,7 +2355,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -2806,6 +2816,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -2821,7 +2832,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -2835,6 +2846,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -2850,7 +2862,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -3251,6 +3263,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -3266,7 +3279,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -3280,6 +3293,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -3295,7 +3309,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -3405,7 +3419,7 @@ "relationshipName": "PaymentRecord_PaymentDirection", "relationshipEntityName": "PaymentDirection", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -3437,7 +3451,7 @@ "relationshipName": "PaymentRecord_PaymentType", "relationshipEntityName": "PaymentType", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -3799,6 +3813,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -3814,7 +3829,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -3828,6 +3843,7 @@ "tooltip": "", "widgetIsMajor": true, "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX", "dataNotNull": true, @@ -3843,7 +3859,7 @@ "dataTypeTypescript": "string", "minLength": 0, "maxLength": 34, - "inputRule": "" + "inputRule": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$" }, { "auditType": "NONE", @@ -3953,7 +3969,7 @@ "relationshipName": "PaymentRecord_PaymentDirection", "relationshipEntityName": "PaymentDirection", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, @@ -3985,7 +4001,7 @@ "relationshipName": "PaymentRecord_PaymentType", "relationshipEntityName": "PaymentType", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities", + "relationshipEntityPerspectiveLabel": "Settings", "dataNotNull": true, "dataAutoIncrement": false, "dataPrimaryKey": false, diff --git a/codbex-payments/codbex-payments.model b/codbex-payments/codbex-payments.model index 61dcecc..f9788d5 100644 --- a/codbex-payments/codbex-payments.model +++ b/codbex-payments/codbex-payments.model @@ -79,6 +79,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -94,6 +95,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -372,6 +374,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -387,6 +390,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -663,6 +667,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -678,6 +683,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -934,6 +940,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -949,6 +956,7 @@ "tooltip": "", "widgetIsMajor": "true", "widgetLength": "34", + "widgetPattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", "widgetSize": "", "widgetType": "TEXTBOX" }, @@ -1021,7 +1029,7 @@ "relationshipName": "PaymentRecord_PaymentDirection", "relationshipEntityName": "PaymentDirection", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities" + "relationshipEntityPerspectiveLabel": "Settings" }, { "auditType": "NONE", @@ -1041,7 +1049,7 @@ "relationshipName": "PaymentRecord_PaymentType", "relationshipEntityName": "PaymentType", "relationshipEntityPerspectiveName": "Settings", - "relationshipEntityPerspectiveLabel": "Entities" + "relationshipEntityPerspectiveLabel": "Settings" }, { "auditType": "NONE", @@ -1601,7 +1609,7 @@ "name": "PaymentType", "perspectiveHeader": "", "perspectiveIcon": "/services/web/resources/unicons/copy.svg", - "perspectiveLabel": "Entities", + "perspectiveLabel": "Settings", "perspectiveName": "Settings", "perspectiveNavId": "", "perspectiveOrder": "100", @@ -2081,7 +2089,7 @@ "name": "PaymentDirection", "perspectiveHeader": "", "perspectiveIcon": "/services/web/resources/unicons/copy.svg", - "perspectiveLabel": "Entities", + "perspectiveLabel": "Settings", "perspectiveName": "Settings", "perspectiveNavId": "", "perspectiveOrder": "100", diff --git a/codbex-payments/gen/codbex-payments/api/CustomerPayment/CustomerPaymentController.ts b/codbex-payments/gen/codbex-payments/api/CustomerPayment/CustomerPaymentController.ts index ea1442f..3f6e86e 100644 --- a/codbex-payments/gen/codbex-payments/api/CustomerPayment/CustomerPaymentController.ts +++ b/codbex-payments/gen/codbex-payments/api/CustomerPayment/CustomerPaymentController.ts @@ -46,7 +46,7 @@ class CustomerPaymentController { this.checkPermissions('write'); this.validateEntity(entity); entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/CustomerPayment/CustomerPaymentService.ts/' + entity.Id); + response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/CustomerPayment/CustomerPaymentController.ts/' + entity.Id); response.setStatus(response.CREATED); return entity; } catch (error: any) { @@ -181,12 +181,18 @@ class CustomerPaymentController { if (entity.OurPartyIBAN?.length > 34) { throw new ValidationError(`The 'OurPartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.OurPartyIBAN)) { + throw new ValidationError(`The value provided for the 'OurPartyIBAN' property ('[${entity.OurPartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyIBAN === null || entity.CounterpartyIBAN === undefined) { throw new ValidationError(`The 'CounterpartyIBAN' property is required, provide a valid value`); } if (entity.CounterpartyIBAN?.length > 34) { throw new ValidationError(`The 'CounterpartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.CounterpartyIBAN)) { + throw new ValidationError(`The value provided for the 'CounterpartyIBAN' property ('[${entity.CounterpartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyName?.length > 100) { throw new ValidationError(`The 'CounterpartyName' exceeds the maximum length of [100] characters`); } diff --git a/codbex-payments/gen/codbex-payments/api/EmployeePayment/EmployeePaymentController.ts b/codbex-payments/gen/codbex-payments/api/EmployeePayment/EmployeePaymentController.ts index caeca14..f7a62d4 100644 --- a/codbex-payments/gen/codbex-payments/api/EmployeePayment/EmployeePaymentController.ts +++ b/codbex-payments/gen/codbex-payments/api/EmployeePayment/EmployeePaymentController.ts @@ -46,7 +46,7 @@ class EmployeePaymentController { this.checkPermissions('write'); this.validateEntity(entity); entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/EmployeePayment/EmployeePaymentService.ts/' + entity.Id); + response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/EmployeePayment/EmployeePaymentController.ts/' + entity.Id); response.setStatus(response.CREATED); return entity; } catch (error: any) { @@ -181,12 +181,18 @@ class EmployeePaymentController { if (entity.OurPartyIBAN?.length > 34) { throw new ValidationError(`The 'OurPartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.OurPartyIBAN)) { + throw new ValidationError(`The value provided for the 'OurPartyIBAN' property ('[${entity.OurPartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyIBAN === null || entity.CounterpartyIBAN === undefined) { throw new ValidationError(`The 'CounterpartyIBAN' property is required, provide a valid value`); } if (entity.CounterpartyIBAN?.length > 34) { throw new ValidationError(`The 'CounterpartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.CounterpartyIBAN)) { + throw new ValidationError(`The value provided for the 'CounterpartyIBAN' property ('[${entity.CounterpartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyName?.length > 100) { throw new ValidationError(`The 'CounterpartyName' exceeds the maximum length of [100] characters`); } diff --git a/codbex-payments/gen/codbex-payments/api/PaymentAdjustment/PaymentAdjustmentController.ts b/codbex-payments/gen/codbex-payments/api/PaymentAdjustment/PaymentAdjustmentController.ts index 5e0e429..54baa9d 100644 --- a/codbex-payments/gen/codbex-payments/api/PaymentAdjustment/PaymentAdjustmentController.ts +++ b/codbex-payments/gen/codbex-payments/api/PaymentAdjustment/PaymentAdjustmentController.ts @@ -44,7 +44,7 @@ class PaymentAdjustmentController { this.checkPermissions('write'); this.validateEntity(entity); entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/PaymentAdjustment/PaymentAdjustmentService.ts/' + entity.Id); + response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/PaymentAdjustment/PaymentAdjustmentController.ts/' + entity.Id); response.setStatus(response.CREATED); return entity; } catch (error: any) { diff --git a/codbex-payments/gen/codbex-payments/api/PaymentRecord/PaymentRecordController.ts b/codbex-payments/gen/codbex-payments/api/PaymentRecord/PaymentRecordController.ts index e11d3e0..5646025 100644 --- a/codbex-payments/gen/codbex-payments/api/PaymentRecord/PaymentRecordController.ts +++ b/codbex-payments/gen/codbex-payments/api/PaymentRecord/PaymentRecordController.ts @@ -44,7 +44,7 @@ class PaymentRecordController { this.checkPermissions('write'); this.validateEntity(entity); entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/PaymentRecord/PaymentRecordService.ts/' + entity.Id); + response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/PaymentRecord/PaymentRecordController.ts/' + entity.Id); response.setStatus(response.CREATED); return entity; } catch (error: any) { @@ -176,12 +176,18 @@ class PaymentRecordController { if (entity.OurPartyIBAN?.length > 34) { throw new ValidationError(`The 'OurPartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.OurPartyIBAN)) { + throw new ValidationError(`The value provided for the 'OurPartyIBAN' property ('[${entity.OurPartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyIBAN === null || entity.CounterpartyIBAN === undefined) { throw new ValidationError(`The 'CounterpartyIBAN' property is required, provide a valid value`); } if (entity.CounterpartyIBAN?.length > 34) { throw new ValidationError(`The 'CounterpartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.CounterpartyIBAN)) { + throw new ValidationError(`The value provided for the 'CounterpartyIBAN' property ('[${entity.CounterpartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyName?.length > 100) { throw new ValidationError(`The 'CounterpartyName' exceeds the maximum length of [100] characters`); } diff --git a/codbex-payments/gen/codbex-payments/api/Settings/PaymentDirectionController.ts b/codbex-payments/gen/codbex-payments/api/Settings/PaymentDirectionController.ts index 5c8d54c..b50fbe2 100644 --- a/codbex-payments/gen/codbex-payments/api/Settings/PaymentDirectionController.ts +++ b/codbex-payments/gen/codbex-payments/api/Settings/PaymentDirectionController.ts @@ -40,7 +40,7 @@ class PaymentDirectionController { try { this.validateEntity(entity); entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/Settings/PaymentDirectionService.ts/' + entity.Id); + response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/Settings/PaymentDirectionController.ts/' + entity.Id); response.setStatus(response.CREATED); return entity; } catch (error: any) { diff --git a/codbex-payments/gen/codbex-payments/api/Settings/PaymentTypeController.ts b/codbex-payments/gen/codbex-payments/api/Settings/PaymentTypeController.ts index f75d387..d537d7d 100644 --- a/codbex-payments/gen/codbex-payments/api/Settings/PaymentTypeController.ts +++ b/codbex-payments/gen/codbex-payments/api/Settings/PaymentTypeController.ts @@ -44,7 +44,7 @@ class PaymentTypeController { this.checkPermissions('write'); this.validateEntity(entity); entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/Settings/PaymentTypeService.ts/' + entity.Id); + response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/Settings/PaymentTypeController.ts/' + entity.Id); response.setStatus(response.CREATED); return entity; } catch (error: any) { diff --git a/codbex-payments/gen/codbex-payments/api/SupplierPayment/SupplierPaymentController.ts b/codbex-payments/gen/codbex-payments/api/SupplierPayment/SupplierPaymentController.ts index 4eef816..48a6b39 100644 --- a/codbex-payments/gen/codbex-payments/api/SupplierPayment/SupplierPaymentController.ts +++ b/codbex-payments/gen/codbex-payments/api/SupplierPayment/SupplierPaymentController.ts @@ -46,7 +46,7 @@ class SupplierPaymentController { this.checkPermissions('write'); this.validateEntity(entity); entity.Id = this.repository.create(entity) as any; - response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/SupplierPayment/SupplierPaymentService.ts/' + entity.Id); + response.setHeader('Content-Location', '/services/ts/codbex-payments/gen/codbex-payments/api/SupplierPayment/SupplierPaymentController.ts/' + entity.Id); response.setStatus(response.CREATED); return entity; } catch (error: any) { @@ -181,12 +181,18 @@ class SupplierPaymentController { if (entity.OurPartyIBAN?.length > 34) { throw new ValidationError(`The 'OurPartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.OurPartyIBAN)) { + throw new ValidationError(`The value provided for the 'OurPartyIBAN' property ('[${entity.OurPartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyIBAN === null || entity.CounterpartyIBAN === undefined) { throw new ValidationError(`The 'CounterpartyIBAN' property is required, provide a valid value`); } if (entity.CounterpartyIBAN?.length > 34) { throw new ValidationError(`The 'CounterpartyIBAN' exceeds the maximum length of [34] characters`); } + if (!RegExp(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/).test(entity.CounterpartyIBAN)) { + throw new ValidationError(`The value provided for the 'CounterpartyIBAN' property ('[${entity.CounterpartyIBAN}]') doesn't match the required pattern '^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'`); + } if (entity.CounterpartyName?.length > 100) { throw new ValidationError(`The 'CounterpartyName' exceeds the maximum length of [100] characters`); } diff --git a/codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPayment.extensionpoint b/codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPayment.extensionpoint deleted file mode 100644 index 4136418..0000000 --- a/codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPayment.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-payments-CustomerPayment-CustomerPayment", - "description": "Extension Point for the codbex-payments-CustomerPayment-CustomerPayment entity" -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPaymentRepository.ts b/codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPaymentRepository.ts deleted file mode 100644 index 40d13e3..0000000 --- a/codbex-payments/gen/codbex-payments/dao/CustomerPayment/CustomerPaymentRepository.ts +++ /dev/null @@ -1,422 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; -import { EntityUtils } from "../utils/EntityUtils"; -// custom imports -import { NumberGeneratorService } from "/codbex-number-generator/service/generator"; - -export interface CustomerPaymentEntity { - readonly Id: number; - Customer: number; - Date: Date; - Valor: Date; - OurPartyIBAN: string; - CounterpartyIBAN: string; - CounterpartyName?: string; - Amount: number; - Currency: number; - Reason: string; - Description?: string; - Company?: number; - Name?: string; - UUID: string; - Reference?: string; - PaymentMethod: number; -} - -export interface CustomerPaymentCreateEntity { - readonly Customer: number; - readonly Date: Date; - readonly Valor: Date; - readonly OurPartyIBAN: string; - readonly CounterpartyIBAN: string; - readonly CounterpartyName?: string; - readonly Amount: number; - readonly Currency: number; - readonly Reason: string; - readonly Description?: string; - readonly Company?: number; - readonly Reference?: string; - readonly PaymentMethod: number; -} - -export interface CustomerPaymentUpdateEntity extends CustomerPaymentCreateEntity { - readonly Id: number; -} - -export interface CustomerPaymentEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Customer?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - Name?: string | string[]; - UUID?: string | string[]; - Reference?: string | string[]; - PaymentMethod?: number | number[]; - }; - notEquals?: { - Id?: number | number[]; - Customer?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - Name?: string | string[]; - UUID?: string | string[]; - Reference?: string | string[]; - PaymentMethod?: number | number[]; - }; - contains?: { - Id?: number; - Customer?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - greaterThan?: { - Id?: number; - Customer?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - greaterThanOrEqual?: { - Id?: number; - Customer?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - lessThan?: { - Id?: number; - Customer?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - lessThanOrEqual?: { - Id?: number; - Customer?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - }, - $select?: (keyof CustomerPaymentEntity)[], - $sort?: string | (keyof CustomerPaymentEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface CustomerPaymentEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface CustomerPaymentUpdateEntityEvent extends CustomerPaymentEntityEvent { - readonly previousEntity: CustomerPaymentEntity; -} - -export class CustomerPaymentRepository { - - private static readonly DEFINITION = { - table: "CODBEX_CUSTOMERPAYMENT", - properties: [ - { - name: "Id", - column: "CUSTOMERPAYMENT_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Customer", - column: "CUSTOMERPAYMENT_CUSTOMER", - type: "INTEGER", - required: true - }, - { - name: "Date", - column: "CUSTOMERPAYMENT_DATE", - type: "DATE", - required: true - }, - { - name: "Valor", - column: "CUSTOMERPAYMENT_VALOR", - type: "DATE", - required: true - }, - { - name: "OurPartyIBAN", - column: "CUSTOMERPAYMENT_OURPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyIBAN", - column: "CUSTOMERPAYMENT_COUNTERPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyName", - column: "CUSTOMERPAYMENT_COUNTERPARTYNAME", - type: "VARCHAR", - }, - { - name: "Amount", - column: "CUSTOMERPAYMENT_AMOUNT", - type: "DECIMAL", - required: true - }, - { - name: "Currency", - column: "CUSTOMERPAYMENT_CURRENCY", - type: "INTEGER", - required: true - }, - { - name: "Reason", - column: "CUSTOMERPAYMENT_REASON", - type: "VARCHAR", - required: true - }, - { - name: "Description", - column: "CUSTOMERPAYMENT_DESCRIPTION", - type: "VARCHAR", - }, - { - name: "Company", - column: "CUSTOMERPAYMENT_COMPANY", - type: "INTEGER", - }, - { - name: "Name", - column: "CUSTOMERPAYMENT_NAME", - type: "VARCHAR", - }, - { - name: "UUID", - column: "CUSTOMERPAYMENT_UUID", - type: "VARCHAR", - required: true - }, - { - name: "Reference", - column: "CUSTOMERPAYMENT_REFERENCE", - type: "VARCHAR", - }, - { - name: "PaymentMethod", - column: "CUSTOMERPAYMENT_PAYMENTMETHOD", - type: "INTEGER", - required: true - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(CustomerPaymentRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: CustomerPaymentEntityOptions = {}): CustomerPaymentEntity[] { - if (options.$sort === undefined && options.$order === undefined) { - options.$sort = "Date"; - options.$order = "DESC"; - } - let list = this.dao.list(options).map((e: CustomerPaymentEntity) => { - EntityUtils.setDate(e, "Date"); - EntityUtils.setDate(e, "Valor"); - return e; - }); - return list; - } - - public findById(id: number, options: CustomerPaymentEntityOptions = {}): CustomerPaymentEntity | undefined { - const entity = this.dao.find(id); - EntityUtils.setDate(entity, "Date"); - EntityUtils.setDate(entity, "Valor"); - return entity ?? undefined; - } - - public create(entity: CustomerPaymentCreateEntity): number { - EntityUtils.setLocalDate(entity, "Date"); - EntityUtils.setLocalDate(entity, "Valor"); - // @ts-ignore - (entity as CustomerPaymentEntity).Name = new NumberGeneratorService().generate(18); - // @ts-ignore - (entity as CustomerPaymentEntity).UUID = require("sdk/utils/uuid").random(); - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_CUSTOMERPAYMENT", - entity: entity, - key: { - name: "Id", - column: "CUSTOMERPAYMENT_ID", - value: id - } - }); - return id; - } - - public update(entity: CustomerPaymentUpdateEntity): void { - // EntityUtils.setLocalDate(entity, "Date"); - // EntityUtils.setLocalDate(entity, "Valor"); - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_CUSTOMERPAYMENT", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "CUSTOMERPAYMENT_ID", - value: entity.Id - } - }); - } - - public upsert(entity: CustomerPaymentCreateEntity | CustomerPaymentUpdateEntity): number { - const id = (entity as CustomerPaymentUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as CustomerPaymentUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_CUSTOMERPAYMENT", - entity: entity, - key: { - name: "Id", - column: "CUSTOMERPAYMENT_ID", - value: id - } - }); - } - - public count(options?: CustomerPaymentEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_CUSTOMERPAYMENT"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: CustomerPaymentEntityEvent | CustomerPaymentUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-payments-CustomerPayment-CustomerPayment", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-payments-CustomerPayment-CustomerPayment").send(JSON.stringify(data)); - } -} diff --git a/codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePayment.extensionpoint b/codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePayment.extensionpoint deleted file mode 100644 index 3516966..0000000 --- a/codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePayment.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-payments-EmployeePayment-EmployeePayment", - "description": "Extension Point for the codbex-payments-EmployeePayment-EmployeePayment entity" -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePaymentRepository.ts b/codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePaymentRepository.ts deleted file mode 100644 index 6959423..0000000 --- a/codbex-payments/gen/codbex-payments/dao/EmployeePayment/EmployeePaymentRepository.ts +++ /dev/null @@ -1,422 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; -import { EntityUtils } from "../utils/EntityUtils"; -// custom imports -import { NumberGeneratorService } from "/codbex-number-generator/service/generator"; - -export interface EmployeePaymentEntity { - readonly Id: number; - Employee: number; - Date: Date; - Valor: Date; - OurPartyIBAN: string; - CounterpartyIBAN: string; - CounterpartyName?: string; - Amount: number; - Currency: number; - Reason: string; - Description?: string; - Company?: number; - Name?: string; - UUID: string; - Reference?: string; - PaymentMethod: number; -} - -export interface EmployeePaymentCreateEntity { - readonly Employee: number; - readonly Date: Date; - readonly Valor: Date; - readonly OurPartyIBAN: string; - readonly CounterpartyIBAN: string; - readonly CounterpartyName?: string; - readonly Amount: number; - readonly Currency: number; - readonly Reason: string; - readonly Description?: string; - readonly Company?: number; - readonly Reference?: string; - readonly PaymentMethod: number; -} - -export interface EmployeePaymentUpdateEntity extends EmployeePaymentCreateEntity { - readonly Id: number; -} - -export interface EmployeePaymentEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Employee?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - Name?: string | string[]; - UUID?: string | string[]; - Reference?: string | string[]; - PaymentMethod?: number | number[]; - }; - notEquals?: { - Id?: number | number[]; - Employee?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - Name?: string | string[]; - UUID?: string | string[]; - Reference?: string | string[]; - PaymentMethod?: number | number[]; - }; - contains?: { - Id?: number; - Employee?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - greaterThan?: { - Id?: number; - Employee?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - greaterThanOrEqual?: { - Id?: number; - Employee?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - lessThan?: { - Id?: number; - Employee?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - lessThanOrEqual?: { - Id?: number; - Employee?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - }, - $select?: (keyof EmployeePaymentEntity)[], - $sort?: string | (keyof EmployeePaymentEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface EmployeePaymentEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface EmployeePaymentUpdateEntityEvent extends EmployeePaymentEntityEvent { - readonly previousEntity: EmployeePaymentEntity; -} - -export class EmployeePaymentRepository { - - private static readonly DEFINITION = { - table: "CODBEX_EMPLOYEEPAYMENT", - properties: [ - { - name: "Id", - column: "EMPLOYEEPAYMENT_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Employee", - column: "EMPLOYEEPAYMENT_EMPLOYEE", - type: "INTEGER", - required: true - }, - { - name: "Date", - column: "EMPLOYEEPAYMENT_DATE", - type: "DATE", - required: true - }, - { - name: "Valor", - column: "EMPLOYEEPAYMENT_VALOR", - type: "DATE", - required: true - }, - { - name: "OurPartyIBAN", - column: "EMPLOYEEPAYMENT_OURPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyIBAN", - column: "EMPLOYEEPAYMENT_COUNTERPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyName", - column: "EMPLOYEEPAYMENT_COUNTERPARTYNAME", - type: "VARCHAR", - }, - { - name: "Amount", - column: "EMPLOYEEPAYMENT_AMOUNT", - type: "DECIMAL", - required: true - }, - { - name: "Currency", - column: "EMPLOYEEPAYMENT_CURRENCY", - type: "INTEGER", - required: true - }, - { - name: "Reason", - column: "EMPLOYEEPAYMENT_REASON", - type: "VARCHAR", - required: true - }, - { - name: "Description", - column: "EMPLOYEEPAYMENT_DESCRIPTION", - type: "VARCHAR", - }, - { - name: "Company", - column: "EMPLOYEEPAYMENT_COMPANY", - type: "INTEGER", - }, - { - name: "Name", - column: "EMPLOYEEPAYMENT_NAME", - type: "VARCHAR", - }, - { - name: "UUID", - column: "EMPLOYEEPAYMENT_UUID", - type: "VARCHAR", - required: true - }, - { - name: "Reference", - column: "EMPLOYEEPAYMENT_REFERENCE", - type: "VARCHAR", - }, - { - name: "PaymentMethod", - column: "EMPLOYEEPAYMENT_PAYMENTMETHOD", - type: "INTEGER", - required: true - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(EmployeePaymentRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: EmployeePaymentEntityOptions = {}): EmployeePaymentEntity[] { - if (options.$sort === undefined && options.$order === undefined) { - options.$sort = "Date"; - options.$order = "DESC"; - } - let list = this.dao.list(options).map((e: EmployeePaymentEntity) => { - EntityUtils.setDate(e, "Date"); - EntityUtils.setDate(e, "Valor"); - return e; - }); - return list; - } - - public findById(id: number, options: EmployeePaymentEntityOptions = {}): EmployeePaymentEntity | undefined { - const entity = this.dao.find(id); - EntityUtils.setDate(entity, "Date"); - EntityUtils.setDate(entity, "Valor"); - return entity ?? undefined; - } - - public create(entity: EmployeePaymentCreateEntity): number { - EntityUtils.setLocalDate(entity, "Date"); - EntityUtils.setLocalDate(entity, "Valor"); - // @ts-ignore - (entity as EmployeePaymentEntity).Name = new NumberGeneratorService().generate(20); - // @ts-ignore - (entity as EmployeePaymentEntity).UUID = require("sdk/utils/uuid").random(); - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_EMPLOYEEPAYMENT", - entity: entity, - key: { - name: "Id", - column: "EMPLOYEEPAYMENT_ID", - value: id - } - }); - return id; - } - - public update(entity: EmployeePaymentUpdateEntity): void { - // EntityUtils.setLocalDate(entity, "Date"); - // EntityUtils.setLocalDate(entity, "Valor"); - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_EMPLOYEEPAYMENT", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "EMPLOYEEPAYMENT_ID", - value: entity.Id - } - }); - } - - public upsert(entity: EmployeePaymentCreateEntity | EmployeePaymentUpdateEntity): number { - const id = (entity as EmployeePaymentUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as EmployeePaymentUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_EMPLOYEEPAYMENT", - entity: entity, - key: { - name: "Id", - column: "EMPLOYEEPAYMENT_ID", - value: id - } - }); - } - - public count(options?: EmployeePaymentEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_EMPLOYEEPAYMENT"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: EmployeePaymentEntityEvent | EmployeePaymentUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-payments-EmployeePayment-EmployeePayment", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-payments-EmployeePayment-EmployeePayment").send(JSON.stringify(data)); - } -} diff --git a/codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustment.extensionpoint b/codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustment.extensionpoint deleted file mode 100644 index 98bfe6f..0000000 --- a/codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustment.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-payments-PaymentAdjustment-PaymentAdjustment", - "description": "Extension Point for the codbex-payments-PaymentAdjustment-PaymentAdjustment entity" -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustmentRepository.ts b/codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustmentRepository.ts deleted file mode 100644 index cd8f18c..0000000 --- a/codbex-payments/gen/codbex-payments/dao/PaymentAdjustment/PaymentAdjustmentRepository.ts +++ /dev/null @@ -1,298 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; -import { EntityUtils } from "../utils/EntityUtils"; - -export interface PaymentAdjustmentEntity { - readonly Id: number; - Date: Date; - Valor: Date; - Amount: number; - Currency: number; - Company: number; - Reason?: string; - UUID?: string; -} - -export interface PaymentAdjustmentCreateEntity { - readonly Date: Date; - readonly Valor: Date; - readonly Amount: number; - readonly Currency: number; - readonly Company: number; - readonly Reason?: string; -} - -export interface PaymentAdjustmentUpdateEntity extends PaymentAdjustmentCreateEntity { - readonly Id: number; -} - -export interface PaymentAdjustmentEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - Amount?: number | number[]; - Currency?: number | number[]; - Company?: number | number[]; - Reason?: string | string[]; - UUID?: string | string[]; - }; - notEquals?: { - Id?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - Amount?: number | number[]; - Currency?: number | number[]; - Company?: number | number[]; - Reason?: string | string[]; - UUID?: string | string[]; - }; - contains?: { - Id?: number; - Date?: Date; - Valor?: Date; - Amount?: number; - Currency?: number; - Company?: number; - Reason?: string; - UUID?: string; - }; - greaterThan?: { - Id?: number; - Date?: Date; - Valor?: Date; - Amount?: number; - Currency?: number; - Company?: number; - Reason?: string; - UUID?: string; - }; - greaterThanOrEqual?: { - Id?: number; - Date?: Date; - Valor?: Date; - Amount?: number; - Currency?: number; - Company?: number; - Reason?: string; - UUID?: string; - }; - lessThan?: { - Id?: number; - Date?: Date; - Valor?: Date; - Amount?: number; - Currency?: number; - Company?: number; - Reason?: string; - UUID?: string; - }; - lessThanOrEqual?: { - Id?: number; - Date?: Date; - Valor?: Date; - Amount?: number; - Currency?: number; - Company?: number; - Reason?: string; - UUID?: string; - }; - }, - $select?: (keyof PaymentAdjustmentEntity)[], - $sort?: string | (keyof PaymentAdjustmentEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface PaymentAdjustmentEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface PaymentAdjustmentUpdateEntityEvent extends PaymentAdjustmentEntityEvent { - readonly previousEntity: PaymentAdjustmentEntity; -} - -export class PaymentAdjustmentRepository { - - private static readonly DEFINITION = { - table: "CODBEX_PAYMENTADJUSTMENT", - properties: [ - { - name: "Id", - column: "PAYMENTADJUSTMENT_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Date", - column: "PAYMENTADJUSTMENT_DATE", - type: "DATE", - required: true - }, - { - name: "Valor", - column: "PAYMENTADJUSTMENT_VALOR", - type: "DATE", - required: true - }, - { - name: "Amount", - column: "PAYMENTADJUSTMENT_AMOUNT", - type: "DECIMAL", - required: true - }, - { - name: "Currency", - column: "PAYMENTADJUSTMENT_CURRENCY", - type: "INTEGER", - required: true - }, - { - name: "Company", - column: "PAYMENTADJUSTMENT_COMPANY", - type: "INTEGER", - required: true - }, - { - name: "Reason", - column: "PAYMENTADJUSTMENT_REASON", - type: "VARCHAR", - }, - { - name: "UUID", - column: "PAYMENTADJUSTMENT_UUID", - type: "VARCHAR", - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(PaymentAdjustmentRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: PaymentAdjustmentEntityOptions = {}): PaymentAdjustmentEntity[] { - let list = this.dao.list(options).map((e: PaymentAdjustmentEntity) => { - EntityUtils.setDate(e, "Date"); - EntityUtils.setDate(e, "Valor"); - return e; - }); - return list; - } - - public findById(id: number, options: PaymentAdjustmentEntityOptions = {}): PaymentAdjustmentEntity | undefined { - const entity = this.dao.find(id); - EntityUtils.setDate(entity, "Date"); - EntityUtils.setDate(entity, "Valor"); - return entity ?? undefined; - } - - public create(entity: PaymentAdjustmentCreateEntity): number { - EntityUtils.setLocalDate(entity, "Date"); - EntityUtils.setLocalDate(entity, "Valor"); - // @ts-ignore - (entity as PaymentAdjustmentEntity).UUID = require("sdk/utils/uuid").random(); - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_PAYMENTADJUSTMENT", - entity: entity, - key: { - name: "Id", - column: "PAYMENTADJUSTMENT_ID", - value: id - } - }); - return id; - } - - public update(entity: PaymentAdjustmentUpdateEntity): void { - // EntityUtils.setLocalDate(entity, "Date"); - // EntityUtils.setLocalDate(entity, "Valor"); - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_PAYMENTADJUSTMENT", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "PAYMENTADJUSTMENT_ID", - value: entity.Id - } - }); - } - - public upsert(entity: PaymentAdjustmentCreateEntity | PaymentAdjustmentUpdateEntity): number { - const id = (entity as PaymentAdjustmentUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as PaymentAdjustmentUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_PAYMENTADJUSTMENT", - entity: entity, - key: { - name: "Id", - column: "PAYMENTADJUSTMENT_ID", - value: id - } - }); - } - - public count(options?: PaymentAdjustmentEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_PAYMENTADJUSTMENT"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: PaymentAdjustmentEntityEvent | PaymentAdjustmentUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-payments-PaymentAdjustment-PaymentAdjustment", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-payments-PaymentAdjustment-PaymentAdjustment").send(JSON.stringify(data)); - } -} diff --git a/codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecord.extensionpoint b/codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecord.extensionpoint deleted file mode 100644 index b1251db..0000000 --- a/codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecord.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-payments-PaymentRecord-PaymentRecord", - "description": "Extension Point for the codbex-payments-PaymentRecord-PaymentRecord entity" -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecordRepository.ts b/codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecordRepository.ts deleted file mode 100644 index 8cd2a95..0000000 --- a/codbex-payments/gen/codbex-payments/dao/PaymentRecord/PaymentRecordRepository.ts +++ /dev/null @@ -1,450 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; -import { EntityUtils } from "../utils/EntityUtils"; - -export interface PaymentRecordEntity { - readonly Id: number; - Date: Date; - Valor: Date; - OurPartyIBAN: string; - CounterpartyIBAN: string; - CounterpartyName?: string; - Amount: number; - Currency: number; - PaymentDirection: number; - PaymentType: number; - Reason?: string; - Description?: string; - Company?: number; - UUID: string; - Reference?: string; - Deleted?: boolean; - DeletedAt?: Date; - DeletedReason?: string; -} - -export interface PaymentRecordCreateEntity { - readonly Date: Date; - readonly Valor: Date; - readonly OurPartyIBAN: string; - readonly CounterpartyIBAN: string; - readonly CounterpartyName?: string; - readonly Amount: number; - readonly Currency: number; - readonly PaymentDirection: number; - readonly PaymentType: number; - readonly Reason?: string; - readonly Description?: string; - readonly Company?: number; - readonly Reference?: string; - readonly Deleted?: boolean; - readonly DeletedAt?: Date; - readonly DeletedReason?: string; -} - -export interface PaymentRecordUpdateEntity extends PaymentRecordCreateEntity { - readonly Id: number; -} - -export interface PaymentRecordEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - PaymentDirection?: number | number[]; - PaymentType?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - UUID?: string | string[]; - Reference?: string | string[]; - Deleted?: boolean | boolean[]; - DeletedAt?: Date | Date[]; - DeletedReason?: string | string[]; - }; - notEquals?: { - Id?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - PaymentDirection?: number | number[]; - PaymentType?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - UUID?: string | string[]; - Reference?: string | string[]; - Deleted?: boolean | boolean[]; - DeletedAt?: Date | Date[]; - DeletedReason?: string | string[]; - }; - contains?: { - Id?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - PaymentDirection?: number; - PaymentType?: number; - Reason?: string; - Description?: string; - Company?: number; - UUID?: string; - Reference?: string; - Deleted?: boolean; - DeletedAt?: Date; - DeletedReason?: string; - }; - greaterThan?: { - Id?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - PaymentDirection?: number; - PaymentType?: number; - Reason?: string; - Description?: string; - Company?: number; - UUID?: string; - Reference?: string; - Deleted?: boolean; - DeletedAt?: Date; - DeletedReason?: string; - }; - greaterThanOrEqual?: { - Id?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - PaymentDirection?: number; - PaymentType?: number; - Reason?: string; - Description?: string; - Company?: number; - UUID?: string; - Reference?: string; - Deleted?: boolean; - DeletedAt?: Date; - DeletedReason?: string; - }; - lessThan?: { - Id?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - PaymentDirection?: number; - PaymentType?: number; - Reason?: string; - Description?: string; - Company?: number; - UUID?: string; - Reference?: string; - Deleted?: boolean; - DeletedAt?: Date; - DeletedReason?: string; - }; - lessThanOrEqual?: { - Id?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - PaymentDirection?: number; - PaymentType?: number; - Reason?: string; - Description?: string; - Company?: number; - UUID?: string; - Reference?: string; - Deleted?: boolean; - DeletedAt?: Date; - DeletedReason?: string; - }; - }, - $select?: (keyof PaymentRecordEntity)[], - $sort?: string | (keyof PaymentRecordEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface PaymentRecordEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface PaymentRecordUpdateEntityEvent extends PaymentRecordEntityEvent { - readonly previousEntity: PaymentRecordEntity; -} - -export class PaymentRecordRepository { - - private static readonly DEFINITION = { - table: "CODBEX_PAYMENTRECORD", - properties: [ - { - name: "Id", - column: "PAYMENTRECORD_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Date", - column: "PAYMENTRECORD_DATE", - type: "DATE", - required: true - }, - { - name: "Valor", - column: "PAYMENTRECORD_VALOR", - type: "DATE", - required: true - }, - { - name: "OurPartyIBAN", - column: "PAYMENTRECORD_OURPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyIBAN", - column: "PAYMENTRECORD_COUNTERPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyName", - column: "PAYMENTRECORD_COUNTERPARTYNAME", - type: "VARCHAR", - }, - { - name: "Amount", - column: "PAYMENTRECORD_AMOUNT", - type: "DECIMAL", - required: true - }, - { - name: "Currency", - column: "PAYMENTRECORD_CURRENCY", - type: "INTEGER", - required: true - }, - { - name: "PaymentDirection", - column: "PAYMENTRECORD_PAYMENTDIRECTION", - type: "INTEGER", - required: true - }, - { - name: "PaymentType", - column: "PAYMENTRECORD_PAYMENTTYPE", - type: "INTEGER", - required: true - }, - { - name: "Reason", - column: "PAYMENTRECORD_REASON", - type: "VARCHAR", - }, - { - name: "Description", - column: "PAYMENTRECORD_DESCRIPTION", - type: "VARCHAR", - }, - { - name: "Company", - column: "PAYMENTRECORD_COMPANY", - type: "INTEGER", - }, - { - name: "UUID", - column: "PAYMENTRECORD_UUID", - type: "VARCHAR", - required: true - }, - { - name: "Reference", - column: "PAYMENTRECORD_REFERENCE", - type: "VARCHAR", - }, - { - name: "Deleted", - column: "PAYMENTRECORD_DELETED", - type: "BOOLEAN", - }, - { - name: "DeletedAt", - column: "PAYMENTRECORD_DELETEDAT", - type: "TIMESTAMP", - }, - { - name: "DeletedReason", - column: "PAYMENTRECORD_DELETEDREASON", - type: "VARCHAR", - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(PaymentRecordRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: PaymentRecordEntityOptions = {}): PaymentRecordEntity[] { - if (options.$sort === undefined && options.$order === undefined) { - options.$sort = "Date"; - options.$order = "DESC"; - } - let list = this.dao.list(options).map((e: PaymentRecordEntity) => { - EntityUtils.setDate(e, "Date"); - EntityUtils.setDate(e, "Valor"); - EntityUtils.setBoolean(e, "Deleted"); - return e; - }); - return list; - } - - public findById(id: number, options: PaymentRecordEntityOptions = {}): PaymentRecordEntity | undefined { - const entity = this.dao.find(id); - EntityUtils.setDate(entity, "Date"); - EntityUtils.setDate(entity, "Valor"); - EntityUtils.setBoolean(entity, "Deleted"); - return entity ?? undefined; - } - - public create(entity: PaymentRecordCreateEntity): number { - EntityUtils.setLocalDate(entity, "Date"); - EntityUtils.setLocalDate(entity, "Valor"); - EntityUtils.setBoolean(entity, "Deleted"); - // @ts-ignore - (entity as PaymentRecordEntity).UUID = require("sdk/utils/uuid").random(); - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_PAYMENTRECORD", - entity: entity, - key: { - name: "Id", - column: "PAYMENTRECORD_ID", - value: id - } - }); - return id; - } - - public update(entity: PaymentRecordUpdateEntity): void { - // EntityUtils.setLocalDate(entity, "Date"); - // EntityUtils.setLocalDate(entity, "Valor"); - EntityUtils.setBoolean(entity, "Deleted"); - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_PAYMENTRECORD", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "PAYMENTRECORD_ID", - value: entity.Id - } - }); - } - - public upsert(entity: PaymentRecordCreateEntity | PaymentRecordUpdateEntity): number { - const id = (entity as PaymentRecordUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as PaymentRecordUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_PAYMENTRECORD", - entity: entity, - key: { - name: "Id", - column: "PAYMENTRECORD_ID", - value: id - } - }); - } - - public count(options?: PaymentRecordEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_PAYMENTRECORD"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: PaymentRecordEntityEvent | PaymentRecordUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-payments-PaymentRecord-PaymentRecord", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-payments-PaymentRecord-PaymentRecord").send(JSON.stringify(data)); - } -} diff --git a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirection.extensionpoint b/codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirection.extensionpoint deleted file mode 100644 index 44517c5..0000000 --- a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirection.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-payments-Settings-PaymentDirection", - "description": "Extension Point for the codbex-payments-Settings-PaymentDirection entity" -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirectionRepository.ts b/codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirectionRepository.ts deleted file mode 100644 index 93ca471..0000000 --- a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentDirectionRepository.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; - -export interface PaymentDirectionEntity { - readonly Id: number; - Name: string; -} - -export interface PaymentDirectionCreateEntity { - readonly Name: string; -} - -export interface PaymentDirectionUpdateEntity extends PaymentDirectionCreateEntity { - readonly Id: number; -} - -export interface PaymentDirectionEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Name?: string | string[]; - }; - notEquals?: { - Id?: number | number[]; - Name?: string | string[]; - }; - contains?: { - Id?: number; - Name?: string; - }; - greaterThan?: { - Id?: number; - Name?: string; - }; - greaterThanOrEqual?: { - Id?: number; - Name?: string; - }; - lessThan?: { - Id?: number; - Name?: string; - }; - lessThanOrEqual?: { - Id?: number; - Name?: string; - }; - }, - $select?: (keyof PaymentDirectionEntity)[], - $sort?: string | (keyof PaymentDirectionEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface PaymentDirectionEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface PaymentDirectionUpdateEntityEvent extends PaymentDirectionEntityEvent { - readonly previousEntity: PaymentDirectionEntity; -} - -export class PaymentDirectionRepository { - - private static readonly DEFINITION = { - table: "CODBEX_PAYMENTDIRECTION", - properties: [ - { - name: "Id", - column: "PAYMENTDIRECTION_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Name", - column: "PAYMENTDIRECTION_NAME", - type: "VARCHAR", - required: true - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(PaymentDirectionRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: PaymentDirectionEntityOptions = {}): PaymentDirectionEntity[] { - let list = this.dao.list(options); - return list; - } - - public findById(id: number, options: PaymentDirectionEntityOptions = {}): PaymentDirectionEntity | undefined { - const entity = this.dao.find(id); - return entity ?? undefined; - } - - public create(entity: PaymentDirectionCreateEntity): number { - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_PAYMENTDIRECTION", - entity: entity, - key: { - name: "Id", - column: "PAYMENTDIRECTION_ID", - value: id - } - }); - return id; - } - - public update(entity: PaymentDirectionUpdateEntity): void { - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_PAYMENTDIRECTION", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "PAYMENTDIRECTION_ID", - value: entity.Id - } - }); - } - - public upsert(entity: PaymentDirectionCreateEntity | PaymentDirectionUpdateEntity): number { - const id = (entity as PaymentDirectionUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as PaymentDirectionUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_PAYMENTDIRECTION", - entity: entity, - key: { - name: "Id", - column: "PAYMENTDIRECTION_ID", - value: id - } - }); - } - - public count(options?: PaymentDirectionEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_PAYMENTDIRECTION"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: PaymentDirectionEntityEvent | PaymentDirectionUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-payments-Settings-PaymentDirection", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-payments-Settings-PaymentDirection").send(JSON.stringify(data)); - } -} diff --git a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentType.extensionpoint b/codbex-payments/gen/codbex-payments/dao/Settings/PaymentType.extensionpoint deleted file mode 100644 index 5e9fecc..0000000 --- a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentType.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-payments-Settings-PaymentType", - "description": "Extension Point for the codbex-payments-Settings-PaymentType entity" -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentTypeRepository.ts b/codbex-payments/gen/codbex-payments/dao/Settings/PaymentTypeRepository.ts deleted file mode 100644 index 0807958..0000000 --- a/codbex-payments/gen/codbex-payments/dao/Settings/PaymentTypeRepository.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; - -export interface PaymentTypeEntity { - readonly Id: number; - Name: string; -} - -export interface PaymentTypeCreateEntity { - readonly Name: string; -} - -export interface PaymentTypeUpdateEntity extends PaymentTypeCreateEntity { - readonly Id: number; -} - -export interface PaymentTypeEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Name?: string | string[]; - }; - notEquals?: { - Id?: number | number[]; - Name?: string | string[]; - }; - contains?: { - Id?: number; - Name?: string; - }; - greaterThan?: { - Id?: number; - Name?: string; - }; - greaterThanOrEqual?: { - Id?: number; - Name?: string; - }; - lessThan?: { - Id?: number; - Name?: string; - }; - lessThanOrEqual?: { - Id?: number; - Name?: string; - }; - }, - $select?: (keyof PaymentTypeEntity)[], - $sort?: string | (keyof PaymentTypeEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface PaymentTypeEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface PaymentTypeUpdateEntityEvent extends PaymentTypeEntityEvent { - readonly previousEntity: PaymentTypeEntity; -} - -export class PaymentTypeRepository { - - private static readonly DEFINITION = { - table: "CODBEX_PAYMENTTYPE", - properties: [ - { - name: "Id", - column: "PAYMENTTYPE_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Name", - column: "PAYMENTTYPE_NAME", - type: "VARCHAR", - required: true - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(PaymentTypeRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: PaymentTypeEntityOptions = {}): PaymentTypeEntity[] { - let list = this.dao.list(options); - return list; - } - - public findById(id: number, options: PaymentTypeEntityOptions = {}): PaymentTypeEntity | undefined { - const entity = this.dao.find(id); - return entity ?? undefined; - } - - public create(entity: PaymentTypeCreateEntity): number { - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_PAYMENTTYPE", - entity: entity, - key: { - name: "Id", - column: "PAYMENTTYPE_ID", - value: id - } - }); - return id; - } - - public update(entity: PaymentTypeUpdateEntity): void { - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_PAYMENTTYPE", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "PAYMENTTYPE_ID", - value: entity.Id - } - }); - } - - public upsert(entity: PaymentTypeCreateEntity | PaymentTypeUpdateEntity): number { - const id = (entity as PaymentTypeUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as PaymentTypeUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_PAYMENTTYPE", - entity: entity, - key: { - name: "Id", - column: "PAYMENTTYPE_ID", - value: id - } - }); - } - - public count(options?: PaymentTypeEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_PAYMENTTYPE"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: PaymentTypeEntityEvent | PaymentTypeUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-payments-Settings-PaymentType", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-payments-Settings-PaymentType").send(JSON.stringify(data)); - } -} diff --git a/codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPayment.extensionpoint b/codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPayment.extensionpoint deleted file mode 100644 index b8295aa..0000000 --- a/codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPayment.extensionpoint +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "codbex-payments-SupplierPayment-SupplierPayment", - "description": "Extension Point for the codbex-payments-SupplierPayment-SupplierPayment entity" -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPaymentRepository.ts b/codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPaymentRepository.ts deleted file mode 100644 index bbcf276..0000000 --- a/codbex-payments/gen/codbex-payments/dao/SupplierPayment/SupplierPaymentRepository.ts +++ /dev/null @@ -1,422 +0,0 @@ -import { sql, query } from "@aerokit/sdk/db"; -import { producer } from "@aerokit/sdk/messaging"; -import { extensions } from "@aerokit/sdk/extensions"; -import { dao as daoApi } from "@aerokit/sdk/db"; -import { EntityUtils } from "../utils/EntityUtils"; -// custom imports -import { NumberGeneratorService } from "/codbex-number-generator/service/generator"; - -export interface SupplierPaymentEntity { - readonly Id: number; - Supplier: number; - Date: Date; - Valor: Date; - OurPartyIBAN: string; - CounterpartyIBAN: string; - CounterpartyName?: string; - Amount: number; - Currency: number; - Reason: string; - Description?: string; - Company?: number; - Name?: string; - UUID: string; - Reference?: string; - PaymentMethod: number; -} - -export interface SupplierPaymentCreateEntity { - readonly Supplier: number; - readonly Date: Date; - readonly Valor: Date; - readonly OurPartyIBAN: string; - readonly CounterpartyIBAN: string; - readonly CounterpartyName?: string; - readonly Amount: number; - readonly Currency: number; - readonly Reason: string; - readonly Description?: string; - readonly Company?: number; - readonly Reference?: string; - readonly PaymentMethod: number; -} - -export interface SupplierPaymentUpdateEntity extends SupplierPaymentCreateEntity { - readonly Id: number; -} - -export interface SupplierPaymentEntityOptions { - $filter?: { - equals?: { - Id?: number | number[]; - Supplier?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - Name?: string | string[]; - UUID?: string | string[]; - Reference?: string | string[]; - PaymentMethod?: number | number[]; - }; - notEquals?: { - Id?: number | number[]; - Supplier?: number | number[]; - Date?: Date | Date[]; - Valor?: Date | Date[]; - OurPartyIBAN?: string | string[]; - CounterpartyIBAN?: string | string[]; - CounterpartyName?: string | string[]; - Amount?: number | number[]; - Currency?: number | number[]; - Reason?: string | string[]; - Description?: string | string[]; - Company?: number | number[]; - Name?: string | string[]; - UUID?: string | string[]; - Reference?: string | string[]; - PaymentMethod?: number | number[]; - }; - contains?: { - Id?: number; - Supplier?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - greaterThan?: { - Id?: number; - Supplier?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - greaterThanOrEqual?: { - Id?: number; - Supplier?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - lessThan?: { - Id?: number; - Supplier?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - lessThanOrEqual?: { - Id?: number; - Supplier?: number; - Date?: Date; - Valor?: Date; - OurPartyIBAN?: string; - CounterpartyIBAN?: string; - CounterpartyName?: string; - Amount?: number; - Currency?: number; - Reason?: string; - Description?: string; - Company?: number; - Name?: string; - UUID?: string; - Reference?: string; - PaymentMethod?: number; - }; - }, - $select?: (keyof SupplierPaymentEntity)[], - $sort?: string | (keyof SupplierPaymentEntity)[], - $order?: 'ASC' | 'DESC', - $offset?: number, - $limit?: number, - $language?: string -} - -export interface SupplierPaymentEntityEvent { - readonly operation: 'create' | 'update' | 'delete'; - readonly table: string; - readonly entity: Partial; - readonly key: { - name: string; - column: string; - value: number; - } -} - -export interface SupplierPaymentUpdateEntityEvent extends SupplierPaymentEntityEvent { - readonly previousEntity: SupplierPaymentEntity; -} - -export class SupplierPaymentRepository { - - private static readonly DEFINITION = { - table: "CODBEX_SUPPLIERPAYMENT", - properties: [ - { - name: "Id", - column: "SUPPLIERPAYMENT_ID", - type: "INTEGER", - id: true, - autoIncrement: true, - }, - { - name: "Supplier", - column: "SUPPLIERPAYMENT_SUPPLIER", - type: "INTEGER", - required: true - }, - { - name: "Date", - column: "SUPPLIERPAYMENT_DATE", - type: "DATE", - required: true - }, - { - name: "Valor", - column: "SUPPLIERPAYMENT_VALOR", - type: "DATE", - required: true - }, - { - name: "OurPartyIBAN", - column: "SUPPLIERPAYMENT_OURPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyIBAN", - column: "SUPPLIERPAYMENT_COUNTERPARTYIBAN", - type: "VARCHAR", - required: true - }, - { - name: "CounterpartyName", - column: "SUPPLIERPAYMENT_COUNTERPARTYNAME", - type: "VARCHAR", - }, - { - name: "Amount", - column: "SUPPLIERPAYMENT_AMOUNT", - type: "DECIMAL", - required: true - }, - { - name: "Currency", - column: "SUPPLIERPAYMENT_CURRENCY", - type: "INTEGER", - required: true - }, - { - name: "Reason", - column: "SUPPLIERPAYMENT_REASON", - type: "VARCHAR", - required: true - }, - { - name: "Description", - column: "SUPPLIERPAYMENT_DESCRIPTION", - type: "VARCHAR", - }, - { - name: "Company", - column: "SUPPLIERPAYMENT_COMPANY", - type: "INTEGER", - }, - { - name: "Name", - column: "SUPPLIERPAYMENT_NAME", - type: "VARCHAR", - }, - { - name: "UUID", - column: "SUPPLIERPAYMENT_UUID", - type: "VARCHAR", - required: true - }, - { - name: "Reference", - column: "SUPPLIERPAYMENT_REFERENCE", - type: "VARCHAR", - }, - { - name: "PaymentMethod", - column: "SUPPLIERPAYMENT_PAYMENTMETHOD", - type: "INTEGER", - required: true - } - ] - }; - - private readonly dao; - - constructor(dataSource = "DefaultDB") { - this.dao = daoApi.create(SupplierPaymentRepository.DEFINITION, undefined, dataSource); - } - - public findAll(options: SupplierPaymentEntityOptions = {}): SupplierPaymentEntity[] { - if (options.$sort === undefined && options.$order === undefined) { - options.$sort = "Date"; - options.$order = "DESC"; - } - let list = this.dao.list(options).map((e: SupplierPaymentEntity) => { - EntityUtils.setDate(e, "Date"); - EntityUtils.setDate(e, "Valor"); - return e; - }); - return list; - } - - public findById(id: number, options: SupplierPaymentEntityOptions = {}): SupplierPaymentEntity | undefined { - const entity = this.dao.find(id); - EntityUtils.setDate(entity, "Date"); - EntityUtils.setDate(entity, "Valor"); - return entity ?? undefined; - } - - public create(entity: SupplierPaymentCreateEntity): number { - EntityUtils.setLocalDate(entity, "Date"); - EntityUtils.setLocalDate(entity, "Valor"); - // @ts-ignore - (entity as SupplierPaymentEntity).Name = new NumberGeneratorService().generate(19); - // @ts-ignore - (entity as SupplierPaymentEntity).UUID = require("sdk/utils/uuid").random(); - const id = this.dao.insert(entity); - this.triggerEvent({ - operation: "create", - table: "CODBEX_SUPPLIERPAYMENT", - entity: entity, - key: { - name: "Id", - column: "SUPPLIERPAYMENT_ID", - value: id - } - }); - return id; - } - - public update(entity: SupplierPaymentUpdateEntity): void { - // EntityUtils.setLocalDate(entity, "Date"); - // EntityUtils.setLocalDate(entity, "Valor"); - const previousEntity = this.findById(entity.Id); - this.dao.update(entity); - this.triggerEvent({ - operation: "update", - table: "CODBEX_SUPPLIERPAYMENT", - entity: entity, - previousEntity: previousEntity, - key: { - name: "Id", - column: "SUPPLIERPAYMENT_ID", - value: entity.Id - } - }); - } - - public upsert(entity: SupplierPaymentCreateEntity | SupplierPaymentUpdateEntity): number { - const id = (entity as SupplierPaymentUpdateEntity).Id; - if (!id) { - return this.create(entity); - } - - const existingEntity = this.findById(id); - if (existingEntity) { - this.update(entity as SupplierPaymentUpdateEntity); - return id; - } else { - return this.create(entity); - } - } - - public deleteById(id: number): void { - const entity = this.dao.find(id); - this.dao.remove(id); - this.triggerEvent({ - operation: "delete", - table: "CODBEX_SUPPLIERPAYMENT", - entity: entity, - key: { - name: "Id", - column: "SUPPLIERPAYMENT_ID", - value: id - } - }); - } - - public count(options?: SupplierPaymentEntityOptions): number { - return this.dao.count(options); - } - - public customDataCount(): number { - const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_SUPPLIERPAYMENT"'); - if (resultSet !== null && resultSet[0] !== null) { - if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { - return resultSet[0].COUNT; - } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { - return resultSet[0].count; - } - } - return 0; - } - - private async triggerEvent(data: SupplierPaymentEntityEvent | SupplierPaymentUpdateEntityEvent) { - const triggerExtensions = await extensions.loadExtensionModules("codbex-payments-SupplierPayment-SupplierPayment", ["trigger"]); - triggerExtensions.forEach(triggerExtension => { - try { - triggerExtension.trigger(data); - } catch (error) { - console.error(error); - } - }); - producer.topic("codbex-payments-SupplierPayment-SupplierPayment").send(JSON.stringify(data)); - } -} diff --git a/codbex-payments/gen/codbex-payments/dao/utils/EntityUtils.ts b/codbex-payments/gen/codbex-payments/dao/utils/EntityUtils.ts deleted file mode 100644 index 0f8815d..0000000 --- a/codbex-payments/gen/codbex-payments/dao/utils/EntityUtils.ts +++ /dev/null @@ -1,20 +0,0 @@ -export class EntityUtils { - - public static setDate(obj: any, property: string): void { - if (obj && obj[property]) { - obj[property] = new Date(obj[property]).getTime(); - } - } - - public static setLocalDate(obj: any, property: string): void { - if (obj && obj[property]) { - obj[property] = new Date(new Date(obj[property]).setHours(-(new Date().getTimezoneOffset() / 60), 0, 0, 0)).toISOString(); - } - } - - public static setBoolean(obj: any, property: string): void { - if (obj && obj[property] !== undefined) { - obj[property] = obj[property] ? true : false; - } - } -} \ No newline at end of file diff --git a/codbex-payments/gen/codbex-payments/data/CustomerPayment/CustomerPaymentRepository.ts b/codbex-payments/gen/codbex-payments/data/CustomerPayment/CustomerPaymentRepository.ts index c9b4705..aea064b 100644 --- a/codbex-payments/gen/codbex-payments/data/CustomerPayment/CustomerPaymentRepository.ts +++ b/codbex-payments/gen/codbex-payments/data/CustomerPayment/CustomerPaymentRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' @@ -13,6 +13,24 @@ export class CustomerPaymentRepository extends Repository super((CustomerPaymentEntity as EntityConstructor)); } + public override findById(id: string | number, options?: Options): CustomerPaymentEntity | undefined { + const entity = super.findById(id, options); + if (entity) { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + } + return entity; + } + + public override findAll(options?: Options): CustomerPaymentEntity[] { + const entities = super.findAll(options); + entities.forEach(entity => { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + }); + return entities; + } + public override create(entity: CustomerPaymentEntity): string | number { entity.Name = new NumberGeneratorService().generate(18); entity.UUID = require("sdk/utils/uuid").random(); diff --git a/codbex-payments/gen/codbex-payments/data/EmployeePayment/EmployeePaymentRepository.ts b/codbex-payments/gen/codbex-payments/data/EmployeePayment/EmployeePaymentRepository.ts index 4b3c526..ca0161c 100644 --- a/codbex-payments/gen/codbex-payments/data/EmployeePayment/EmployeePaymentRepository.ts +++ b/codbex-payments/gen/codbex-payments/data/EmployeePayment/EmployeePaymentRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' @@ -13,6 +13,24 @@ export class EmployeePaymentRepository extends Repository super((EmployeePaymentEntity as EntityConstructor)); } + public override findById(id: string | number, options?: Options): EmployeePaymentEntity | undefined { + const entity = super.findById(id, options); + if (entity) { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + } + return entity; + } + + public override findAll(options?: Options): EmployeePaymentEntity[] { + const entities = super.findAll(options); + entities.forEach(entity => { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + }); + return entities; + } + public override create(entity: EmployeePaymentEntity): string | number { entity.Name = new NumberGeneratorService().generate(20); entity.UUID = require("sdk/utils/uuid").random(); diff --git a/codbex-payments/gen/codbex-payments/data/PaymentAdjustment/PaymentAdjustmentRepository.ts b/codbex-payments/gen/codbex-payments/data/PaymentAdjustment/PaymentAdjustmentRepository.ts index e72bae2..1f1ea96 100644 --- a/codbex-payments/gen/codbex-payments/data/PaymentAdjustment/PaymentAdjustmentRepository.ts +++ b/codbex-payments/gen/codbex-payments/data/PaymentAdjustment/PaymentAdjustmentRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' @@ -11,6 +11,24 @@ export class PaymentAdjustmentRepository extends Repository { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + }); + return entities; + } + public override create(entity: PaymentAdjustmentEntity): string | number { entity.UUID = require("sdk/utils/uuid").random(); return super.create(entity); diff --git a/codbex-payments/gen/codbex-payments/data/PaymentRecord/PaymentRecordRepository.ts b/codbex-payments/gen/codbex-payments/data/PaymentRecord/PaymentRecordRepository.ts index 42d5761..3e684b7 100644 --- a/codbex-payments/gen/codbex-payments/data/PaymentRecord/PaymentRecordRepository.ts +++ b/codbex-payments/gen/codbex-payments/data/PaymentRecord/PaymentRecordRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' @@ -11,6 +11,26 @@ export class PaymentRecordRepository extends Repository { super((PaymentRecordEntity as EntityConstructor)); } + public override findById(id: string | number, options?: Options): PaymentRecordEntity | undefined { + const entity = super.findById(id, options); + if (entity) { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + entity.DeletedAt = entity.DeletedAt ? new Date(entity.DeletedAt) : undefined; + } + return entity; + } + + public override findAll(options?: Options): PaymentRecordEntity[] { + const entities = super.findAll(options); + entities.forEach(entity => { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + entity.DeletedAt = entity.DeletedAt ? new Date(entity.DeletedAt) : undefined; + }); + return entities; + } + public override create(entity: PaymentRecordEntity): string | number { entity.UUID = require("sdk/utils/uuid").random(); return super.create(entity); diff --git a/codbex-payments/gen/codbex-payments/data/Settings/PaymentDirectionRepository.ts b/codbex-payments/gen/codbex-payments/data/Settings/PaymentDirectionRepository.ts index 353f921..f6967a9 100644 --- a/codbex-payments/gen/codbex-payments/data/Settings/PaymentDirectionRepository.ts +++ b/codbex-payments/gen/codbex-payments/data/Settings/PaymentDirectionRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' diff --git a/codbex-payments/gen/codbex-payments/data/Settings/PaymentTypeRepository.ts b/codbex-payments/gen/codbex-payments/data/Settings/PaymentTypeRepository.ts index b8ac15c..b089429 100644 --- a/codbex-payments/gen/codbex-payments/data/Settings/PaymentTypeRepository.ts +++ b/codbex-payments/gen/codbex-payments/data/Settings/PaymentTypeRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' diff --git a/codbex-payments/gen/codbex-payments/data/SupplierPayment/SupplierPaymentRepository.ts b/codbex-payments/gen/codbex-payments/data/SupplierPayment/SupplierPaymentRepository.ts index b783480..a800a9a 100644 --- a/codbex-payments/gen/codbex-payments/data/SupplierPayment/SupplierPaymentRepository.ts +++ b/codbex-payments/gen/codbex-payments/data/SupplierPayment/SupplierPaymentRepository.ts @@ -1,4 +1,4 @@ -import { Repository, EntityEvent, EntityConstructor } from '@aerokit/sdk/db' +import { Repository, EntityEvent, EntityConstructor, Options } from '@aerokit/sdk/db' import { Component } from '@aerokit/sdk/component' import { Producer } from '@aerokit/sdk/messaging' import { Extensions } from '@aerokit/sdk/extensions' @@ -13,6 +13,24 @@ export class SupplierPaymentRepository extends Repository super((SupplierPaymentEntity as EntityConstructor)); } + public override findById(id: string | number, options?: Options): SupplierPaymentEntity | undefined { + const entity = super.findById(id, options); + if (entity) { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + } + return entity; + } + + public override findAll(options?: Options): SupplierPaymentEntity[] { + const entities = super.findAll(options); + entities.forEach(entity => { + entity.Date = entity.Date ? new Date(entity.Date) : undefined; + entity.Valor = entity.Valor ? new Date(entity.Valor) : undefined; + }); + return entities; + } + public override create(entity: SupplierPaymentEntity): string | number { entity.Name = new NumberGeneratorService().generate(19); entity.UUID = require("sdk/utils/uuid").random(); diff --git a/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/dialog-window/index.html b/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/dialog-window/index.html index 3ee43f2..9a63c8f 100644 --- a/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/dialog-window/index.html +++ b/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/dialog-window/index.html @@ -76,7 +76,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -97,7 +98,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> diff --git a/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/main-details/index.html b/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/main-details/index.html index d89ced1..5e516d1 100644 --- a/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/main-details/index.html +++ b/codbex-payments/gen/codbex-payments/ui/CustomerPayment/CustomerPayment/main-details/index.html @@ -78,7 +78,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -99,7 +100,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> diff --git a/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/dialog-window/index.html b/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/dialog-window/index.html index 05cbf8e..ef9583b 100644 --- a/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/dialog-window/index.html +++ b/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/dialog-window/index.html @@ -76,7 +76,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -97,7 +98,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> diff --git a/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/main-details/index.html b/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/main-details/index.html index d5b2765..5ecaa1f 100644 --- a/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/main-details/index.html +++ b/codbex-payments/gen/codbex-payments/ui/EmployeePayment/EmployeePayment/main-details/index.html @@ -78,7 +78,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -99,7 +100,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> diff --git a/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/dialog-window/index.html b/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/dialog-window/index.html index 0749e89..2e84454 100644 --- a/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/dialog-window/index.html +++ b/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/dialog-window/index.html @@ -59,7 +59,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -80,7 +81,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> diff --git a/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/main-details/index.html b/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/main-details/index.html index f5a1442..8624285 100644 --- a/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/main-details/index.html +++ b/codbex-payments/gen/codbex-payments/ui/PaymentRecord/PaymentRecord/main-details/index.html @@ -57,7 +57,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -78,7 +79,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> diff --git a/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/dialog-window/index.html b/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/dialog-window/index.html index bcbe4c4..bbfd58a 100644 --- a/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/dialog-window/index.html +++ b/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/dialog-window/index.html @@ -76,7 +76,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -97,7 +98,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> diff --git a/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/main-details/index.html b/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/main-details/index.html index 6400207..287b1fd 100644 --- a/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/main-details/index.html +++ b/codbex-payments/gen/codbex-payments/ui/SupplierPayment/SupplierPayment/main-details/index.html @@ -78,7 +78,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}"> @@ -99,7 +100,7 @@
+ text="{{ 'codbex-payments:codbex-payments-model.messages.error.pattern' | t:{'rule':'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'} }}">