@design.estate/dees-document 5.2.0 → 5.4.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.
Files changed (37) hide show
  1. package/dist_bundle/bundle.js +420 -410
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/bundle.js.third-party-notices.json +27 -1
  4. package/dist_bundle/bundle.js.third-party-notices.txt +58 -2
  5. package/dist_ts/00_commitinfo_data.js +1 -1
  6. package/dist_ts/classes.pdfservice.d.ts +2 -1
  7. package/dist_ts/classes.pdfservice.js +5 -2
  8. package/dist_ts_shared/appearance.d.ts +29 -0
  9. package/dist_ts_shared/appearance.js +53 -0
  10. package/dist_ts_shared/index.d.ts +1 -0
  11. package/dist_ts_shared/index.js +2 -1
  12. package/dist_ts_shared/paymentcode.d.ts +30 -3
  13. package/dist_ts_shared/paymentcode.js +33 -3
  14. package/dist_ts_shared/plugins.d.ts +2 -0
  15. package/dist_ts_shared/plugins.js +4 -1
  16. package/dist_ts_shared/translation.d.ts +1 -0
  17. package/dist_ts_shared/translation.js +3 -1
  18. package/dist_ts_web/00_commitinfo_data.js +1 -1
  19. package/dist_ts_web/elements/contentinvoice.d.ts +5 -1
  20. package/dist_ts_web/elements/contentinvoice.js +18 -7
  21. package/dist_ts_web/elements/document.js +7 -3
  22. package/dist_ts_web/elements/page.js +5 -3
  23. package/dist_ts_web/elements/pagefooter.js +1 -2
  24. package/dist_ts_web/elements/paymentcode.d.ts +2 -0
  25. package/dist_ts_web/elements/paymentcode.js +14 -2
  26. package/dist_ts_web/style.js +1 -1
  27. package/package.json +4 -3
  28. package/readme.md +4 -2
  29. package/ts/00_commitinfo_data.ts +1 -1
  30. package/ts/classes.pdfservice.ts +4 -1
  31. package/ts_web/00_commitinfo_data.ts +1 -1
  32. package/ts_web/elements/contentinvoice.ts +21 -8
  33. package/ts_web/elements/document.ts +6 -2
  34. package/ts_web/elements/page.ts +4 -2
  35. package/ts_web/elements/pagefooter.ts +0 -1
  36. package/ts_web/elements/paymentcode.ts +7 -0
  37. package/ts_web/style.ts +1 -1
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '5.2.0',
6
+ version: '5.4.0',
7
7
  description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.'
8
8
  }
@@ -44,7 +44,8 @@ export class PdfService {
44
44
  * creates an letter
45
45
  *
46
46
  * An accounting document whose advance payments do not add up to its paid
47
- * amount is refused before anything is rendered: this rejects.
47
+ * amount, and a letter whose accent colour (`appearance.accentColor`) is no
48
+ * hex colour, are refused before anything is rendered: this rejects.
48
49
  */
49
50
  public async createPdfFromLetterObject(optionsArg: {
50
51
  letterData: plugins.tsclass.business.TLetter;
@@ -52,6 +53,8 @@ export class PdfService {
52
53
  }): Promise<plugins.smartpdf.IPdf> {
53
54
  plugins.shared.assertPaidAmountMatchesAdvancePayments(optionsArg.letterData);
54
55
  plugins.shared.assertWithoutVatStatesNoTax(optionsArg.letterData, optionsArg.documentSettings);
56
+ // a letter's accent colour that is no hex colour is refused before anything is rendered
57
+ plugins.shared.resolvedAccentOf(optionsArg.documentSettings.theme, optionsArg.letterData);
55
58
  const html = `
56
59
  <script type="module">
57
60
  ${await helpers.getBundleAsString()}
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '5.2.0',
6
+ version: '5.4.0',
7
7
  description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.'
8
8
  }
@@ -907,7 +907,11 @@ export class DeContentInvoice extends DeesElement {
907
907
  /**
908
908
  * The QR pay box. It is printed only when the payment has a valid EPC QR
909
909
  * code: a euro amount to the sender's IBAN, which a document in another
910
- * currency or without the sender's IBAN does not have.
910
+ * currency or without the sender's IBAN does not have. The code carries the
911
+ * reference the document states (`paymentOptions.paymentReference`): an ISO
912
+ * 11649 creditor reference in line 10, any other as free text, and where it
913
+ * states none, the letter's number (`epcRemittanceOf`). A stated reference
914
+ * is printed beside the code, so a payer who types the transfer quotes it.
911
915
  */
912
916
  private renderPaymentInfo(optionsArg: {
913
917
  /** the sender, who is paid */
@@ -915,15 +919,17 @@ export class DeContentInvoice extends DeesElement {
915
919
  currency: string;
916
920
  /** the amount to pay */
917
921
  amount: number;
918
- /** the number of the letter, the remittance information */
919
- reference: string;
922
+ /** the number of the letter, the remittance information where the document states no reference */
923
+ number: string;
924
+ /** the reference the document states for its payment (EN 16931 BT-83) */
925
+ statedReference?: string;
920
926
  }): TemplateResult | null {
921
927
  const bic = optionsArg.from.sepaConnection?.bic;
922
928
  const name = optionsArg.from.name;
923
929
  const iban = optionsArg.from.sepaConnection?.iban;
924
930
  const currency = optionsArg.currency;
925
931
  const totalGross = optionsArg.amount;
926
- const reference = optionsArg.reference;
932
+ const remittance = plugins.shared.epcRemittanceOf(optionsArg.statedReference, optionsArg.number);
927
933
  if (
928
934
  typeof iban !== "string" ||
929
935
  plugins.shared.buildEpcQrPayload({
@@ -932,7 +938,8 @@ export class DeContentInvoice extends DeesElement {
932
938
  iban,
933
939
  currency,
934
940
  amount: totalGross,
935
- remittanceInformation: reference,
941
+ remittanceInformation: remittance.remittanceInformation,
942
+ ...(remittance.creditorReference ? { creditorReference: remittance.creditorReference } : {}),
936
943
  }) === null
937
944
  ) {
938
945
  return null;
@@ -943,6 +950,9 @@ export class DeContentInvoice extends DeesElement {
943
950
  <div>
944
951
  <div class="label">${this.translateKey("invoice@@payment.qr")}</div>
945
952
  <span> ${this.translateKey("invoice@@payment.qr.description")} </span>
953
+ ${remittance.printedReference
954
+ ? html`<div>${this.translateKey("invoice@@payment.reference")}: ${remittance.printedReference}</div>`
955
+ : ""}
946
956
  </div>
947
957
  <dedocument-paymentcode
948
958
  bic="${bic}"
@@ -950,7 +960,8 @@ export class DeContentInvoice extends DeesElement {
950
960
  iban="${iban}"
951
961
  currency="${currency}"
952
962
  totalGross="${totalGross}"
953
- reference="${reference}"
963
+ reference="${remittance.remittanceInformation}"
964
+ creditorReference="${remittance.creditorReference ?? ""}"
954
965
  />
955
966
  </div>
956
967
  </div>`;
@@ -1060,7 +1071,8 @@ export class DeContentInvoice extends DeesElement {
1060
1071
  from: accountingDocArg.from,
1061
1072
  currency: accountingDocArg.currency,
1062
1073
  amount: summaryArg ? summaryArg.amountDue : this.getTotalGross(),
1063
- reference: accountingDocArg.id,
1074
+ number: accountingDocArg.id,
1075
+ statedReference: accountingDocArg.paymentOptions?.paymentReference,
1064
1076
  })}
1065
1077
  `;
1066
1078
  }
@@ -1405,7 +1417,8 @@ export class DeContentInvoice extends DeesElement {
1405
1417
  from: reminderArg.from,
1406
1418
  currency: reminderArg.currency,
1407
1419
  amount: totals.payable,
1408
- reference: reminderArg.id,
1420
+ number: reminderArg.id,
1421
+ statedReference: reminderArg.paymentOptions?.paymentReference,
1409
1422
  })}
1410
1423
  `;
1411
1424
  }
@@ -151,10 +151,14 @@ export class DeDocument extends DeesElement {
151
151
  public paginationInfo: IPagePaginationInfo[] = [];
152
152
 
153
153
  public async renderDocument() {
154
- // a document whose advance payments do not add up to its paid amount is
155
- // refused: no page of it, and none of the letter before it, stays on screen
154
+ // a document whose advance payments do not add up to its paid amount, or
155
+ // whose accent colour is no hex colour, is refused: no page of it, and none
156
+ // of the letter before it, stays on screen. The accent is checked here,
157
+ // before any page is built: a page that threw in its render would never be
158
+ // ready, and the render would never settle
156
159
  try {
157
160
  plugins.shared.assertPaidAmountMatchesAdvancePayments(this.letterData);
161
+ plugins.shared.resolvedAccentOf(this.documentSettings?.theme, this.letterData);
158
162
  } catch (error) {
159
163
  this.latestDocumentSettings = this.documentSettings;
160
164
  this.latestRenderedLetterData = this.letterData;
@@ -136,13 +136,15 @@ export class DePage extends DeesElement {
136
136
 
137
137
  public render(): TemplateResult {
138
138
  const theme = this.documentSettings.theme;
139
+ // the theme's accent, else the letter's own (`appearance.accentColor`), with text that reads on it
140
+ const accent = plugins.shared.resolvedAccentOf(theme, this.letterData);
139
141
  return html`
140
142
  <style>
141
143
  :host {
142
144
  ${theme?.colorPrimaryForeground ? `--theme-color-primary-fg: ${theme.colorPrimaryForeground};` : ''}
143
145
  ${theme?.colorPrimaryBackground ? `--theme-color-primary-bg: ${theme.colorPrimaryBackground};` : ''}
144
- ${theme?.colorAccentForeground ? `--theme-color-accent-fg: ${theme.colorAccentForeground};` : ''}
145
- ${theme?.colorAccentBackground ? `--theme-color-accent-bg: ${theme.colorAccentBackground};` : ''}
146
+ ${accent.foreground ? `--theme-color-accent-fg: ${accent.foreground};` : ''}
147
+ ${accent.background ? `--theme-color-accent-bg: ${accent.background};` : ''}
146
148
  }
147
149
 
148
150
  .page {
@@ -83,7 +83,6 @@ export class DePageFooter extends DeesElement {
83
83
  background: var(--footer-separator-bg-color, #e4002b);
84
84
  padding: 3px;
85
85
  font-size: 9px;
86
- color: #fff;
87
86
  border-bottom-left-radius: 3px;
88
87
  border-bottom-right-radius: 3px;
89
88
  }
@@ -53,6 +53,10 @@ export class DedocumentPaymentCode extends DeesElement {
53
53
  @property()
54
54
  accessor reference!: string;
55
55
 
56
+ /** an ISO 11649 creditor reference for line 10; the reference (line 11) is empty beside it */
57
+ @property()
58
+ accessor creditorReference: string | undefined;
59
+
56
60
  /** The EPC QR code content, or null when the payment has no valid code (see buildEpcQrPayload). */
57
61
  private get payload(): string | null {
58
62
  if (
@@ -71,6 +75,9 @@ export class DedocumentPaymentCode extends DeesElement {
71
75
  currency: this.currency,
72
76
  amount: this.totalGross,
73
77
  remittanceInformation: this.reference,
78
+ ...(typeof this.creditorReference === "string" && this.creditorReference.length > 0
79
+ ? { creditorReference: this.creditorReference }
80
+ : {}),
74
81
  });
75
82
  }
76
83
 
package/ts_web/style.ts CHANGED
@@ -22,7 +22,7 @@ export const dedocumentSharedStyle = css`
22
22
  --label-fg: var(--color-dark);
23
23
  --label-bg: var(--color-grey);
24
24
  --footer-separator-bg-color: var(--color-accent-bg);
25
- --footer-separator-fg-color: var(--color-light);
25
+ --footer-separator-fg-color: var(--color-accent-fg);
26
26
 
27
27
  /* Functional variables */
28
28
  --DPI-FACTOR: ${plugins.shared.cmToPx(1)}px;