ztechno_core 0.0.105 → 0.0.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/crypto_service.d.ts +23 -0
- package/lib/core/crypto_service.js +100 -0
- package/lib/core/engine_base.d.ts +11 -0
- package/lib/core/engine_base.js +9 -0
- package/lib/core/index.d.ts +14 -0
- package/lib/core/index.js +101 -0
- package/lib/core/mail_service.d.ts +85 -0
- package/lib/core/mail_service.js +156 -0
- package/lib/core/orm/mail_blacklist_orm.d.ts +21 -0
- package/lib/core/orm/mail_blacklist_orm.js +79 -0
- package/lib/core/orm/orm.d.ts +27 -0
- package/lib/core/orm/orm.js +67 -0
- package/lib/core/sql_service.d.ts +195 -0
- package/lib/core/sql_service.js +333 -0
- package/lib/core/translate_service.d.ts +48 -0
- package/lib/core/translate_service.js +913 -0
- package/lib/core/types/crypto_types.d.ts +4 -0
- package/lib/core/types/crypto_types.js +2 -0
- package/lib/core/types/mail_types.d.ts +95 -0
- package/lib/core/types/mail_types.js +2 -0
- package/lib/core/types/site_config.d.ts +46 -0
- package/lib/core/types/site_config.js +2 -0
- package/lib/core/types/translate_types.d.ts +69 -0
- package/lib/core/types/translate_types.js +46 -0
- package/lib/core/types/user_types.d.ts +41 -0
- package/lib/core/types/user_types.js +2 -0
- package/lib/core/user_service.d.ts +87 -0
- package/lib/core/user_service.js +216 -0
- package/lib/express/index.d.ts +1 -0
- package/lib/express/index.js +18 -0
- package/lib/index.d.ts +17 -8
- package/lib/index.js +60 -16
- package/lib/mollie/index.d.ts +5 -0
- package/lib/mollie/index.js +62 -0
- package/lib/mollie/orm/customers_orm.d.ts +16 -0
- package/lib/mollie/orm/customers_orm.js +115 -0
- package/lib/mollie/orm/invoice_items_orm.d.ts +9 -0
- package/lib/mollie/orm/invoice_items_orm.js +71 -0
- package/lib/mollie/orm/invoice_payments_orm.d.ts +10 -0
- package/lib/mollie/orm/invoice_payments_orm.js +70 -0
- package/lib/mollie/orm/invoices_orm.d.ts +40 -0
- package/lib/mollie/orm/invoices_orm.js +172 -0
- package/lib/mollie/orm/subscription_items_orm.d.ts +9 -0
- package/lib/mollie/orm/subscription_items_orm.js +45 -0
- package/lib/mollie/orm/subscriptions_orm.d.ts +17 -0
- package/lib/mollie/orm/subscriptions_orm.js +122 -0
- package/lib/mollie/services/customer_service.d.ts +14 -0
- package/lib/mollie/services/customer_service.js +53 -0
- package/lib/mollie/services/invoice_service.d.ts +102 -0
- package/lib/mollie/services/invoice_service.js +866 -0
- package/lib/mollie/services/mollie_service.d.ts +42 -0
- package/lib/mollie/services/mollie_service.js +370 -0
- package/lib/mollie/services/subscription_service.d.ts +32 -0
- package/lib/mollie/services/subscription_service.js +134 -0
- package/lib/mollie/types/internal_types.d.ts +19 -0
- package/lib/mollie/types/internal_types.js +2 -0
- package/lib/mollie/types/mollie_types.d.ts +187 -0
- package/lib/mollie/types/mollie_types.js +3 -0
- package/lib/mollie/util/subscription_utils.d.ts +8 -0
- package/lib/mollie/util/subscription_utils.js +37 -0
- package/lib/schema/MySQLSchemaExtractor.d.ts +1 -1
- package/lib/schema/MySQLSchemaImporter.d.ts +1 -1
- package/package.json +3 -1
package/lib/index.js
CHANGED
|
@@ -26,57 +26,103 @@ var __exportStar =
|
|
|
26
26
|
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.middleware =
|
|
30
|
+
exports.SubscriptionService =
|
|
31
|
+
exports.MollieService =
|
|
32
|
+
exports.CustomerService =
|
|
33
|
+
exports.InvoiceService =
|
|
34
|
+
exports.ZMailBlacklistOrm =
|
|
35
|
+
exports.ZOrm =
|
|
36
|
+
exports.ZUserService =
|
|
30
37
|
exports.ZTranslateService =
|
|
31
38
|
exports.ZSQLService =
|
|
32
39
|
exports.ZMailService =
|
|
33
40
|
exports.ZCryptoService =
|
|
34
41
|
exports.ZEngineBase =
|
|
35
|
-
exports.middleware =
|
|
36
42
|
void 0;
|
|
37
43
|
// Core services
|
|
38
|
-
|
|
44
|
+
var core_1 = require('./core');
|
|
39
45
|
Object.defineProperty(exports, 'ZEngineBase', {
|
|
40
46
|
enumerable: true,
|
|
41
47
|
get: function () {
|
|
42
|
-
return
|
|
48
|
+
return core_1.ZEngineBase;
|
|
43
49
|
},
|
|
44
50
|
});
|
|
45
|
-
const crypto_service_1 = require('./crypto_service');
|
|
46
51
|
Object.defineProperty(exports, 'ZCryptoService', {
|
|
47
52
|
enumerable: true,
|
|
48
53
|
get: function () {
|
|
49
|
-
return
|
|
54
|
+
return core_1.ZCryptoService;
|
|
50
55
|
},
|
|
51
56
|
});
|
|
52
|
-
const mail_service_1 = require('./mail_service');
|
|
53
57
|
Object.defineProperty(exports, 'ZMailService', {
|
|
54
58
|
enumerable: true,
|
|
55
59
|
get: function () {
|
|
56
|
-
return
|
|
60
|
+
return core_1.ZMailService;
|
|
57
61
|
},
|
|
58
62
|
});
|
|
59
|
-
const sql_service_1 = require('./sql_service');
|
|
60
63
|
Object.defineProperty(exports, 'ZSQLService', {
|
|
61
64
|
enumerable: true,
|
|
62
65
|
get: function () {
|
|
63
|
-
return
|
|
66
|
+
return core_1.ZSQLService;
|
|
64
67
|
},
|
|
65
68
|
});
|
|
66
|
-
const translate_service_1 = require('./translate_service');
|
|
67
69
|
Object.defineProperty(exports, 'ZTranslateService', {
|
|
68
70
|
enumerable: true,
|
|
69
71
|
get: function () {
|
|
70
|
-
return
|
|
72
|
+
return core_1.ZTranslateService;
|
|
71
73
|
},
|
|
72
74
|
});
|
|
73
|
-
const user_service_1 = require('./user_service');
|
|
74
75
|
Object.defineProperty(exports, 'ZUserService', {
|
|
75
76
|
enumerable: true,
|
|
76
77
|
get: function () {
|
|
77
|
-
return
|
|
78
|
+
return core_1.ZUserService;
|
|
78
79
|
},
|
|
79
80
|
});
|
|
81
|
+
Object.defineProperty(exports, 'ZOrm', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return core_1.ZOrm;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, 'ZMailBlacklistOrm', {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return core_1.ZMailBlacklistOrm;
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
// Core types
|
|
94
|
+
__exportStar(require('./core/types/crypto_types'), exports);
|
|
95
|
+
__exportStar(require('./core/types/mail_types'), exports);
|
|
96
|
+
__exportStar(require('./core/types/translate_types'), exports);
|
|
97
|
+
__exportStar(require('./core/types/user_types'), exports);
|
|
98
|
+
__exportStar(require('./core/types/site_config'), exports);
|
|
99
|
+
// Mollie services & types
|
|
100
|
+
var mollie_1 = require('./mollie');
|
|
101
|
+
Object.defineProperty(exports, 'InvoiceService', {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return mollie_1.InvoiceService;
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, 'CustomerService', {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return mollie_1.CustomerService;
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, 'MollieService', {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return mollie_1.MollieService;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, 'SubscriptionService', {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () {
|
|
122
|
+
return mollie_1.SubscriptionService;
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
__exportStar(require('./mollie/types/mollie_types'), exports);
|
|
80
126
|
// Express middleware
|
|
81
127
|
var express_1 = require('./express');
|
|
82
128
|
Object.defineProperty(exports, 'middleware', {
|
|
@@ -85,7 +131,5 @@ Object.defineProperty(exports, 'middleware', {
|
|
|
85
131
|
return express_1.middleware;
|
|
86
132
|
},
|
|
87
133
|
});
|
|
88
|
-
// Re-export all types from typings barrel
|
|
89
|
-
__exportStar(require('./typings'), exports);
|
|
90
134
|
// Re-export all schema-related modules
|
|
91
135
|
__exportStar(require('./schema'), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MollieService } from './services/mollie_service';
|
|
2
|
+
export { CustomerService } from './services/customer_service';
|
|
3
|
+
export { InvoiceService } from './services/invoice_service';
|
|
4
|
+
export { SubscriptionService } from './services/subscription_service';
|
|
5
|
+
export * from './types/mollie_types';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
});
|
|
22
|
+
var __exportStar =
|
|
23
|
+
(this && this.__exportStar) ||
|
|
24
|
+
function (m, exports) {
|
|
25
|
+
for (var p in m)
|
|
26
|
+
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
29
|
+
exports.SubscriptionService = exports.InvoiceService = exports.CustomerService = exports.MollieService = void 0;
|
|
30
|
+
// Services
|
|
31
|
+
var mollie_service_1 = require('./services/mollie_service');
|
|
32
|
+
Object.defineProperty(exports, 'MollieService', {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return mollie_service_1.MollieService;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
var customer_service_1 = require('./services/customer_service');
|
|
39
|
+
Object.defineProperty(exports, 'CustomerService', {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return customer_service_1.CustomerService;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
var invoice_service_1 = require('./services/invoice_service');
|
|
46
|
+
Object.defineProperty(exports, 'InvoiceService', {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return invoice_service_1.InvoiceService;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
var subscription_service_1 = require('./services/subscription_service');
|
|
53
|
+
Object.defineProperty(exports, 'SubscriptionService', {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () {
|
|
56
|
+
return subscription_service_1.SubscriptionService;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
// Public types (entities, inputs, outputs)
|
|
60
|
+
__exportStar(require('./types/mollie_types'), exports);
|
|
61
|
+
// internal_types.ts is intentionally NOT exported —
|
|
62
|
+
// it contains Mollie SDK wrapper types used only within this module.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ZOrm } from '../../core/orm/orm';
|
|
2
|
+
import { ZSQLService } from '../../core/sql_service';
|
|
3
|
+
import { ZCustomer } from '../types/mollie_types';
|
|
4
|
+
export declare class CustomersOrm extends ZOrm {
|
|
5
|
+
constructor(opt: { sqlService: ZSQLService; alias?: string; hashSalt?: string });
|
|
6
|
+
create(customer: Omit<ZCustomer, 'id' | 'created_at' | 'updated_at'>): Promise<{
|
|
7
|
+
insertId: number;
|
|
8
|
+
affectedRows: number;
|
|
9
|
+
}>;
|
|
10
|
+
findByEmail(email: string): Promise<ZCustomer>;
|
|
11
|
+
findById(id: number): Promise<ZCustomer>;
|
|
12
|
+
findByMollieCustomerId(mollie_customer_id: string): Promise<ZCustomer>;
|
|
13
|
+
findAll(): Promise<ZCustomer[]>;
|
|
14
|
+
update(id: number, customer: Partial<Omit<ZCustomer, 'id' | 'created_at' | 'updated_at'>>): Promise<void>;
|
|
15
|
+
createTable(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.CustomersOrm = void 0;
|
|
4
|
+
const orm_1 = require('../../core/orm/orm');
|
|
5
|
+
class CustomersOrm extends orm_1.ZOrm {
|
|
6
|
+
constructor(opt) {
|
|
7
|
+
super({ sqlService: opt.sqlService, alias: opt.alias ?? 'mollie_customers' });
|
|
8
|
+
}
|
|
9
|
+
async create(customer) {
|
|
10
|
+
const res = await this.sqlService.query(
|
|
11
|
+
/*SQL*/ `
|
|
12
|
+
INSERT INTO \`${this.alias}\`
|
|
13
|
+
(mollie_customer_id, email, name, company, phone, btw_nummer, address_line1, address_line2, postal_code, city, country, locale, metadata)
|
|
14
|
+
VALUES
|
|
15
|
+
(:mollie_customer_id, :email, :name, :company, :phone, :btw_nummer, :address_line1, :address_line2, :postal_code, :city, :country, :locale, :metadata)
|
|
16
|
+
ON DUPLICATE KEY UPDATE
|
|
17
|
+
name=VALUES(name),
|
|
18
|
+
company=VALUES(company),
|
|
19
|
+
phone=VALUES(phone),
|
|
20
|
+
btw_nummer=VALUES(btw_nummer),
|
|
21
|
+
address_line1=VALUES(address_line1),
|
|
22
|
+
address_line2=VALUES(address_line2),
|
|
23
|
+
postal_code=VALUES(postal_code),
|
|
24
|
+
city=VALUES(city),
|
|
25
|
+
country=VALUES(country),
|
|
26
|
+
locale=VALUES(locale),
|
|
27
|
+
metadata=VALUES(metadata),
|
|
28
|
+
updated_at=NOW()
|
|
29
|
+
`,
|
|
30
|
+
customer,
|
|
31
|
+
);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
async findByEmail(email) {
|
|
35
|
+
const res = await this.sqlService.exec({
|
|
36
|
+
query: `SELECT * FROM \`${this.alias}\` WHERE email=:email LIMIT 1`,
|
|
37
|
+
params: { email },
|
|
38
|
+
});
|
|
39
|
+
return res[0];
|
|
40
|
+
}
|
|
41
|
+
async findById(id) {
|
|
42
|
+
const res = await this.sqlService.exec({
|
|
43
|
+
query: `SELECT * FROM \`${this.alias}\` WHERE id=:id LIMIT 1`,
|
|
44
|
+
params: { id },
|
|
45
|
+
});
|
|
46
|
+
return res[0];
|
|
47
|
+
}
|
|
48
|
+
async findByMollieCustomerId(mollie_customer_id) {
|
|
49
|
+
const res = await this.sqlService.exec({
|
|
50
|
+
query: `SELECT * FROM \`${this.alias}\` WHERE mollie_customer_id=:mollie_customer_id LIMIT 1`,
|
|
51
|
+
params: { mollie_customer_id },
|
|
52
|
+
});
|
|
53
|
+
return res[0];
|
|
54
|
+
}
|
|
55
|
+
async findAll() {
|
|
56
|
+
return await this.sqlService.exec({ query: `SELECT * FROM \`${this.alias}\` ORDER BY created_at DESC` });
|
|
57
|
+
}
|
|
58
|
+
async update(id, customer) {
|
|
59
|
+
const fields = [];
|
|
60
|
+
const params = { id };
|
|
61
|
+
const allowedFields = [
|
|
62
|
+
'name',
|
|
63
|
+
'email',
|
|
64
|
+
'company',
|
|
65
|
+
'phone',
|
|
66
|
+
'btw_nummer',
|
|
67
|
+
'address_line1',
|
|
68
|
+
'address_line2',
|
|
69
|
+
'postal_code',
|
|
70
|
+
'city',
|
|
71
|
+
'country',
|
|
72
|
+
'locale',
|
|
73
|
+
'metadata',
|
|
74
|
+
];
|
|
75
|
+
for (const field of allowedFields) {
|
|
76
|
+
if (field in customer) {
|
|
77
|
+
fields.push(`${field}=:${field}`);
|
|
78
|
+
params[field] = customer[field];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (fields.length === 0) return;
|
|
82
|
+
await this.sqlService.query(
|
|
83
|
+
/*SQL*/ `
|
|
84
|
+
UPDATE \`${this.alias}\`
|
|
85
|
+
SET ${fields.join(', ')}, updated_at=NOW()
|
|
86
|
+
WHERE id=:id
|
|
87
|
+
`,
|
|
88
|
+
params,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
async createTable() {
|
|
92
|
+
await this.sqlService.query(/*SQL*/ `
|
|
93
|
+
CREATE TABLE IF NOT EXISTS \`${this.alias}\` (
|
|
94
|
+
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
95
|
+
mollie_customer_id VARCHAR(64) UNIQUE,
|
|
96
|
+
email VARCHAR(255) NOT NULL,
|
|
97
|
+
name VARCHAR(255) NOT NULL,
|
|
98
|
+
company VARCHAR(255),
|
|
99
|
+
phone VARCHAR(64),
|
|
100
|
+
btw_nummer VARCHAR(32),
|
|
101
|
+
address_line1 VARCHAR(255),
|
|
102
|
+
address_line2 VARCHAR(255),
|
|
103
|
+
postal_code VARCHAR(32),
|
|
104
|
+
city VARCHAR(128),
|
|
105
|
+
country CHAR(2),
|
|
106
|
+
locale VARCHAR(10),
|
|
107
|
+
metadata JSON NULL,
|
|
108
|
+
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
109
|
+
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
110
|
+
UNIQUE KEY uq_customers_email (email)
|
|
111
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
112
|
+
`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.CustomersOrm = CustomersOrm;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ZSQLService } from '../..';
|
|
2
|
+
import { ZOrm } from '../../core/orm/orm';
|
|
3
|
+
import { ZInvoiceItem } from '../types/mollie_types';
|
|
4
|
+
export declare class InvoiceItemsOrm extends ZOrm {
|
|
5
|
+
constructor(opt: { sqlService: ZSQLService; alias?: string; hashSalt?: string });
|
|
6
|
+
bulkInsert(items: ZInvoiceItem[]): Promise<void>;
|
|
7
|
+
findByInvoice(invoice_id: number): Promise<ZInvoiceItem[]>;
|
|
8
|
+
createTable(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.InvoiceItemsOrm = void 0;
|
|
4
|
+
const orm_1 = require('../../core/orm/orm');
|
|
5
|
+
class InvoiceItemsOrm extends orm_1.ZOrm {
|
|
6
|
+
constructor(opt) {
|
|
7
|
+
super({ sqlService: opt.sqlService, alias: opt.alias ?? 'mollie_invoice_items' });
|
|
8
|
+
}
|
|
9
|
+
async bulkInsert(items) {
|
|
10
|
+
if (items.length === 0) return;
|
|
11
|
+
const fields = [
|
|
12
|
+
'invoice_id',
|
|
13
|
+
'item_type',
|
|
14
|
+
'description',
|
|
15
|
+
'quantity',
|
|
16
|
+
'unit_price',
|
|
17
|
+
'vat_rate',
|
|
18
|
+
'total_ex_vat',
|
|
19
|
+
'total_inc_vat',
|
|
20
|
+
'sort_order',
|
|
21
|
+
];
|
|
22
|
+
const placeholder = `(${fields.map(() => '?').join(', ')})`;
|
|
23
|
+
const values = [];
|
|
24
|
+
for (const item of items) {
|
|
25
|
+
values.push(
|
|
26
|
+
item.invoice_id,
|
|
27
|
+
item.item_type ?? 'service',
|
|
28
|
+
item.description,
|
|
29
|
+
item.quantity,
|
|
30
|
+
item.unit_price,
|
|
31
|
+
item.vat_rate,
|
|
32
|
+
item.total_ex_vat,
|
|
33
|
+
item.total_inc_vat,
|
|
34
|
+
item.sort_order ?? 0,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
await this.sqlService.query(
|
|
38
|
+
/*SQL*/ `
|
|
39
|
+
INSERT INTO \`${this.alias}\`
|
|
40
|
+
(${fields.join(', ')})
|
|
41
|
+
VALUES
|
|
42
|
+
${items.map(() => placeholder).join(',\n ')}
|
|
43
|
+
`,
|
|
44
|
+
values,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
async findByInvoice(invoice_id) {
|
|
48
|
+
return await this.sqlService.exec({
|
|
49
|
+
query: `SELECT * FROM \`${this.alias}\` WHERE invoice_id=:invoice_id ORDER BY sort_order, id`,
|
|
50
|
+
params: { invoice_id },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async createTable() {
|
|
54
|
+
await this.sqlService.query(/*SQL*/ `
|
|
55
|
+
CREATE TABLE IF NOT EXISTS \`${this.alias}\` (
|
|
56
|
+
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
57
|
+
invoice_id BIGINT UNSIGNED NOT NULL,
|
|
58
|
+
item_type ENUM('service','subsidy') NOT NULL DEFAULT 'service',
|
|
59
|
+
description VARCHAR(255) NOT NULL,
|
|
60
|
+
quantity DECIMAL(10,2) NOT NULL DEFAULT 1,
|
|
61
|
+
unit_price DECIMAL(12,2) NOT NULL,
|
|
62
|
+
vat_rate DECIMAL(5,2) NOT NULL DEFAULT 0.00,
|
|
63
|
+
total_ex_vat DECIMAL(12,2) NOT NULL,
|
|
64
|
+
total_inc_vat DECIMAL(12,2) NOT NULL,
|
|
65
|
+
sort_order SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
|
66
|
+
KEY idx_items_invoice (invoice_id)
|
|
67
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
68
|
+
`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.InvoiceItemsOrm = InvoiceItemsOrm;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ZOrm } from '../../core/orm/orm';
|
|
2
|
+
import { ZSQLService } from '../../core/sql_service';
|
|
3
|
+
import { ZInvoicePayment } from '../types/mollie_types';
|
|
4
|
+
export declare class InvoicePaymentsOrm extends ZOrm {
|
|
5
|
+
constructor(opt: { sqlService: ZSQLService; alias?: string });
|
|
6
|
+
upsert(payment: Omit<ZInvoicePayment, 'id' | 'created_at' | 'updated_at'>): Promise<void>;
|
|
7
|
+
findByPaymentId(mollie_payment_id: string): Promise<ZInvoicePayment>;
|
|
8
|
+
findByInvoice(invoice_id: number): Promise<ZInvoicePayment[]>;
|
|
9
|
+
createTable(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.InvoicePaymentsOrm = void 0;
|
|
4
|
+
const orm_1 = require('../../core/orm/orm');
|
|
5
|
+
class InvoicePaymentsOrm extends orm_1.ZOrm {
|
|
6
|
+
constructor(opt) {
|
|
7
|
+
super({ sqlService: opt.sqlService, alias: opt.alias ?? 'mollie_invoice_payments' });
|
|
8
|
+
}
|
|
9
|
+
async upsert(payment) {
|
|
10
|
+
await this.sqlService.query(
|
|
11
|
+
/*SQL*/ `
|
|
12
|
+
INSERT INTO \`${this.alias}\`
|
|
13
|
+
(invoice_id, mollie_payment_id, status, sequence_type, mollie_subscription_id, method, amount, currency, checkout_url, paid_at, expires_at, mandate_id)
|
|
14
|
+
VALUES
|
|
15
|
+
(:invoice_id, :mollie_payment_id, :status, :sequence_type, :mollie_subscription_id, :method, :amount, :currency, :checkout_url, :paid_at, :expires_at, :mandate_id)
|
|
16
|
+
ON DUPLICATE KEY UPDATE
|
|
17
|
+
status=VALUES(status),
|
|
18
|
+
sequence_type=VALUES(sequence_type),
|
|
19
|
+
mollie_subscription_id=VALUES(mollie_subscription_id),
|
|
20
|
+
method=VALUES(method),
|
|
21
|
+
amount=VALUES(amount),
|
|
22
|
+
currency=VALUES(currency),
|
|
23
|
+
checkout_url=VALUES(checkout_url),
|
|
24
|
+
paid_at=VALUES(paid_at),
|
|
25
|
+
expires_at=VALUES(expires_at),
|
|
26
|
+
mandate_id=VALUES(mandate_id),
|
|
27
|
+
updated_at=NOW()
|
|
28
|
+
`,
|
|
29
|
+
payment,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
async findByPaymentId(mollie_payment_id) {
|
|
33
|
+
const res = await this.sqlService.exec({
|
|
34
|
+
query: `SELECT * FROM \`${this.alias}\` WHERE mollie_payment_id=:mollie_payment_id LIMIT 1`,
|
|
35
|
+
params: { mollie_payment_id },
|
|
36
|
+
});
|
|
37
|
+
return res[0];
|
|
38
|
+
}
|
|
39
|
+
async findByInvoice(invoice_id) {
|
|
40
|
+
return await this.sqlService.exec({
|
|
41
|
+
query: `SELECT * FROM \`${this.alias}\` WHERE invoice_id=:invoice_id ORDER BY created_at DESC`,
|
|
42
|
+
params: { invoice_id },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async createTable() {
|
|
46
|
+
await this.sqlService.query(/*SQL*/ `
|
|
47
|
+
CREATE TABLE IF NOT EXISTS \`${this.alias}\` (
|
|
48
|
+
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
49
|
+
invoice_id BIGINT UNSIGNED NOT NULL,
|
|
50
|
+
mollie_payment_id VARCHAR(64) NOT NULL,
|
|
51
|
+
status ENUM('open','pending','authorized','paid','canceled','expired','failed','refunded') NOT NULL,
|
|
52
|
+
sequence_type ENUM('oneoff','first','recurring') NULL,
|
|
53
|
+
mollie_subscription_id VARCHAR(64),
|
|
54
|
+
method VARCHAR(64),
|
|
55
|
+
amount DECIMAL(12,2) NOT NULL,
|
|
56
|
+
currency CHAR(3) NOT NULL DEFAULT 'EUR',
|
|
57
|
+
checkout_url VARCHAR(512),
|
|
58
|
+
paid_at DATETIME,
|
|
59
|
+
expires_at DATETIME,
|
|
60
|
+
mandate_id VARCHAR(64),
|
|
61
|
+
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
62
|
+
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
63
|
+
UNIQUE KEY uq_payment_mollie (mollie_payment_id),
|
|
64
|
+
KEY idx_payments_invoice (invoice_id),
|
|
65
|
+
KEY idx_payments_subscription (mollie_subscription_id)
|
|
66
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
67
|
+
`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.InvoicePaymentsOrm = InvoicePaymentsOrm;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ZOrm } from '../../core/orm/orm';
|
|
2
|
+
import { ZSQLService } from '../../core/sql_service';
|
|
3
|
+
import { ZInvoice, ZInvoiceStatus } from '../types/mollie_types';
|
|
4
|
+
export declare class InvoicesOrm extends ZOrm {
|
|
5
|
+
constructor(opt: { sqlService: ZSQLService; alias?: string });
|
|
6
|
+
create(invoice: Omit<ZInvoice, 'id' | 'created_at' | 'updated_at'>): Promise<{
|
|
7
|
+
insertId: number;
|
|
8
|
+
affectedRows: number;
|
|
9
|
+
}>;
|
|
10
|
+
findById(id: number): Promise<ZInvoice>;
|
|
11
|
+
findByInvoiceNumber(invoice_number: string): Promise<ZInvoice>;
|
|
12
|
+
findByPayTokenHash(pay_token_hash: string): Promise<ZInvoice>;
|
|
13
|
+
findAll(): Promise<ZInvoice[]>;
|
|
14
|
+
findLastByYear(year: number): Promise<ZInvoice | undefined>;
|
|
15
|
+
updateStatus(id: number, status: ZInvoiceStatus, amount_paid?: number, paid_at?: string | null): Promise<void>;
|
|
16
|
+
updatePaymentRef(
|
|
17
|
+
id: number,
|
|
18
|
+
payload: {
|
|
19
|
+
mollie_payment_id?: string | null;
|
|
20
|
+
checkout_url?: string | null;
|
|
21
|
+
},
|
|
22
|
+
): Promise<void>;
|
|
23
|
+
updateSubscriptionPeriod(
|
|
24
|
+
id: number,
|
|
25
|
+
payload: {
|
|
26
|
+
subscription_id?: number | null;
|
|
27
|
+
subscription_period_start?: string | null;
|
|
28
|
+
subscription_period_end?: string | null;
|
|
29
|
+
},
|
|
30
|
+
): Promise<void>;
|
|
31
|
+
setPayToken(
|
|
32
|
+
id: number,
|
|
33
|
+
payload: {
|
|
34
|
+
pay_token_hash: string;
|
|
35
|
+
pay_token_expires_at: string;
|
|
36
|
+
},
|
|
37
|
+
): Promise<void>;
|
|
38
|
+
finalizePayToken(id: number): Promise<void>;
|
|
39
|
+
createTable(): Promise<void>;
|
|
40
|
+
}
|