@design.estate/dees-document 3.1.2 → 3.3.0

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.
@@ -24,6 +24,7 @@ const documentNumberLabels: Record<
24
24
  plugins.shared.translation.TranslationKey
25
25
  > = {
26
26
  invoice: "letterhead@@invoice.number",
27
+ "corrected-invoice": "letterhead@@correctedInvoice.number",
27
28
  creditnote: "letterhead@@creditnote.number",
28
29
  debitnote: "letterhead@@debitnote.number",
29
30
  "self-billed-invoice": "letterhead@@selfBilledInvoice.number",
@@ -125,6 +126,9 @@ export class DeLetterHeader extends DeesElement {
125
126
 
126
127
  /** The number row, under the label of the document type. */
127
128
  private renderDocumentNumber(): TemplateResult | null {
129
+ if (plugins.shared.isPaymentReminder(this.letterData)) {
130
+ return this.renderPaymentReminderNumber(this.letterData);
131
+ }
128
132
  const accountingDoc = this.accountingDoc;
129
133
  if (!accountingDoc?.id) return null;
130
134
  return html`<div class="label">
@@ -138,6 +142,30 @@ export class DeLetterHeader extends DeesElement {
138
142
  ${accountingDoc.id}`;
139
143
  }
140
144
 
145
+ /** A reminder's number and, when the issuer counts its reminders, its level. */
146
+ private renderPaymentReminderNumber(
147
+ reminderArg: plugins.tsclass.finance.TPaymentReminder
148
+ ): TemplateResult {
149
+ return html`${reminderArg.id
150
+ ? html`<div class="label">
151
+ ${plugins.shared.translation.translate(
152
+ this.documentSettings.languageCode,
153
+ "letterhead@@paymentReminder.number"
154
+ )}
155
+ </div>
156
+ ${reminderArg.id}`
157
+ : null}
158
+ ${reminderArg.reminderLevel !== undefined
159
+ ? html`<div class="label">
160
+ ${plugins.shared.translation.translate(
161
+ this.documentSettings.languageCode,
162
+ "letterhead@@paymentReminder.level"
163
+ )}
164
+ </div>
165
+ ${reminderArg.reminderLevel}`
166
+ : null}`;
167
+ }
168
+
141
169
  /** The period of performance row, gated like the number row. */
142
170
  private renderPeriodOfPerformance(): TemplateResult | null {
143
171
  const periodOfPerformance = this.accountingDoc?.periodOfPerformance;
@@ -53,25 +53,34 @@ export class DedocumentPaymentCode extends DeesElement {
53
53
  @property()
54
54
  accessor reference!: string;
55
55
 
56
+ /** The EPC QR code content, or null when the payment has no valid code (see buildEpcQrPayload). */
57
+ private get payload(): string | null {
58
+ if (
59
+ typeof this.name !== "string" ||
60
+ typeof this.iban !== "string" ||
61
+ typeof this.currency !== "string" ||
62
+ typeof this.totalGross !== "number" ||
63
+ typeof this.reference !== "string"
64
+ ) {
65
+ return null;
66
+ }
67
+ return plugins.shared.buildEpcQrPayload({
68
+ bic: typeof this.bic === "string" ? this.bic : undefined,
69
+ name: this.name,
70
+ iban: this.iban,
71
+ currency: this.currency,
72
+ amount: this.totalGross,
73
+ remittanceInformation: this.reference,
74
+ });
75
+ }
76
+
56
77
  private updateQRCode(): void {
57
- if (!this.canvasEl) return;
78
+ const payload = this.payload;
79
+ if (!this.canvasEl || payload === null) return;
58
80
 
59
- plugins.qrcode.toCanvas(
60
- this.canvasEl,
61
- `BCD
62
- 001
63
- 1
64
- SCT
65
- ${this.bic}
66
- ${this.name}
67
- ${this.iban}
68
- ${this.currency}${this.totalGross?.toFixed?.(2)}
69
-
70
- ${this.reference}`,
71
- (error) => {
72
- if (error) console.error(error);
73
- }
74
- );
81
+ plugins.qrcode.toCanvas(this.canvasEl, payload, (error) => {
82
+ if (error) console.error(error);
83
+ });
75
84
  }
76
85
 
77
86
  public override update(
@@ -82,14 +91,6 @@ ${this.reference}`,
82
91
  }
83
92
 
84
93
  public render(): TemplateResult | null {
85
- const allDataAvailable =
86
- typeof this.bic === "string" &&
87
- typeof this.name === "string" &&
88
- typeof this.iban === "string" &&
89
- typeof this.currency === "string" &&
90
- typeof this.totalGross === "number" &&
91
- typeof this.reference === "string";
92
-
93
- return allDataAvailable ? html`<canvas></canvas>` : null;
94
+ return this.payload === null ? null : html`<canvas></canvas>`;
94
95
  }
95
96
  }