ztechno_core 0.0.107 → 0.0.109

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.
@@ -1,8 +1,7 @@
1
1
  export type Coordinates = [number, number];
2
2
  export type CompanyInfo = {
3
- baseUrl: string;
4
- website: string;
5
3
  company: string;
4
+ companyShort: string;
6
5
  copyright: string;
7
6
  kvk: string;
8
7
  kvkUrl: string;
@@ -38,6 +37,7 @@ export type RenderContext = {
38
37
  projectsHtml: string;
39
38
  };
40
39
  export type RenderData = {
40
+ baseUrl: string;
41
41
  company: CompanyInfo;
42
42
  address: Address;
43
43
  contact: ContactInfo;
@@ -22,7 +22,7 @@ class InvoiceService {
22
22
  return this.opt.siteConfig;
23
23
  }
24
24
  get baseUrl() {
25
- return this.opt.siteConfig.company.website;
25
+ return this.opt.siteConfig.baseUrl;
26
26
  }
27
27
  constructor(opt) {
28
28
  this.opt = opt;
@@ -834,18 +834,18 @@ class InvoiceService {
834
834
  const subject = isReceipt ? `Betalingsbevestiging ${invoice.invoice_number}` : `Factuur ${invoice.invoice_number}`;
835
835
  const title = isReceipt ? `Betaling ontvangen ${invoice.invoice_number}` : `Factuur ${invoice.invoice_number}`;
836
836
  const content = isReceipt
837
- ? `<br>Beste ${customer.name},<br><br>We hebben uw betaling ontvangen. De factuur vindt u in de bijlage.<br><br>Dank u wel, ${cfg.company.website}<br>`
838
- : `<br>Beste ${customer.name},<br><br>U vindt uw factuur in de bijlage.<br><br><a href="${pay?.payUrl}" style="display:inline-block;padding:10px 16px;background:#0d6efd;color:#fff;text-decoration:none;border-radius:6px;">Betaal nu</a><br><br>Dank u wel, ${cfg.company.website}<br>`;
837
+ ? `<br>Beste ${customer.name},<br><br>We hebben uw betaling ontvangen. De factuur vindt u in de bijlage.<br><br>Dank u wel, ${cfg.company.companyShort}<br>`
838
+ : `<br>Beste ${customer.name},<br><br>U vindt uw factuur in de bijlage.<br><br><a href="${pay?.payUrl}" style="display:inline-block;padding:10px 16px;background:#0d6efd;color:#fff;text-decoration:none;border-radius:6px;">Betaal nu</a><br><br>Dank u wel, ${cfg.company.companyShort}<br>`;
839
839
  await this.mailService.sendAdvanced({
840
- from: `${cfg.company.website} <${cfg.contact.contact}>`,
840
+ from: `${cfg.company.company} <${cfg.contact.contact}>`,
841
841
  recipient: to,
842
842
  subject,
843
843
  template: 'template.html',
844
844
  inject: {
845
845
  title,
846
846
  content,
847
- logoSrc: `${cfg.company.website}/img/logo-small.png`,
848
- baseUrl: cfg.company.website,
847
+ logoSrc: `${cfg.baseUrl}/img/logo-small.png`,
848
+ baseUrl: cfg.baseUrl,
849
849
  },
850
850
  attachments: [
851
851
  {
@@ -13,6 +13,10 @@ export declare class MollieService {
13
13
  webhookUrl: string;
14
14
  });
15
15
  private get client();
16
+ resetDatabase(options?: { dryRun?: boolean }): Promise<{
17
+ dryRun: boolean;
18
+ deleted: Record<string, number>;
19
+ }>;
16
20
  recoverFromMollie(options?: { dryRun?: boolean }): Promise<RecoveryStats>;
17
21
  createCustomer(payload: {
18
22
  name: string;
@@ -36,6 +36,36 @@ class MollieService {
36
36
  }
37
37
  return (0, api_client_1.createMollieClient)({ apiKey });
38
38
  }
39
+ async resetDatabase(options) {
40
+ const customersOrm = new customers_orm_1.CustomersOrm({ sqlService: this.opt.sqlService });
41
+ const subscriptionsOrm = new subscriptions_orm_1.SubscriptionsOrm({ sqlService: this.opt.sqlService });
42
+ const subscriptionItemsOrm = new subscription_items_orm_1.SubscriptionItemsOrm({ sqlService: this.opt.sqlService });
43
+ const invoicesOrm = new invoices_orm_1.InvoicesOrm({ sqlService: this.opt.sqlService });
44
+ const invoiceItemsOrm = new invoice_items_orm_1.InvoiceItemsOrm({ sqlService: this.opt.sqlService });
45
+ const paymentsOrm = new invoice_payments_orm_1.InvoicePaymentsOrm({ sqlService: this.opt.sqlService });
46
+ // Child tables first, then parent tables (respect FK ordering)
47
+ const orms = [invoiceItemsOrm, paymentsOrm, invoicesOrm, subscriptionItemsOrm, subscriptionsOrm, customersOrm];
48
+ if (options?.dryRun) {
49
+ const counts = {};
50
+ for (const orm of orms) {
51
+ const rows = await this.opt.sqlService.exec({
52
+ query: `SELECT COUNT(*) AS cnt FROM \`${orm.alias}\``,
53
+ });
54
+ counts[orm.alias] = rows[0]?.cnt ?? 0;
55
+ }
56
+ return { dryRun: true, deleted: counts };
57
+ }
58
+ return await this.opt.sqlService.transaction(async (trx) => {
59
+ const deleted = {};
60
+ trx.query('SET FOREIGN_KEY_CHECKS = 0');
61
+ for (const orm of orms) {
62
+ const res = await trx.query(`DELETE FROM \`${orm.alias}\``);
63
+ deleted[orm.alias] = res?.affectedRows ?? 0;
64
+ }
65
+ await trx.query('SET FOREIGN_KEY_CHECKS = 1');
66
+ return { dryRun: false, deleted };
67
+ });
68
+ }
39
69
  async recoverFromMollie(options) {
40
70
  const dryRun = options?.dryRun ?? false;
41
71
  const mollie = this.client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.107",
3
+ "version": "0.0.109",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",