@design.estate/dees-document 1.0.101 → 1.1.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.
@@ -8,8 +8,12 @@ import {
8
8
  css,
9
9
  cssManager,
10
10
  unsafeCSS,
11
+ domtools,
11
12
  } from '@design.estate/dees-element';
12
- import * as domtools from '@design.estate/dees-domtools';
13
+
14
+ import * as interfaces from '../../ts/interfaces/index.js';
15
+
16
+ import { defaultDocumentSettings } from './document.js';
13
17
 
14
18
  import * as shared from './shared/index.js';
15
19
 
@@ -23,10 +27,14 @@ declare global {
23
27
  export class DePage extends DeesElement {
24
28
  public static demo = () => html` <dedocument-page .format="${'a4'}"></dedocument-page> `;
25
29
 
26
- @property()
30
+ @property({
31
+ type: Number,
32
+ })
27
33
  viewWidth: number = null;
28
34
 
29
- @property()
35
+ @property({
36
+ type: Number,
37
+ })
30
38
  viewHeight: number = null;
31
39
 
32
40
  @property({
@@ -55,6 +63,12 @@ export class DePage extends DeesElement {
55
63
  })
56
64
  printMode = false;
57
65
 
66
+ @property({
67
+ type: Object,
68
+ reflect: true,
69
+ })
70
+ public documentSettings: interfaces.IDocumentSettings = defaultDocumentSettings;
71
+
58
72
  constructor() {
59
73
  super();
60
74
  domtools.DomTools.setupDomTools();
@@ -109,11 +123,15 @@ export class DePage extends DeesElement {
109
123
  <dedocument-pagecontainer .printMode=${this.printMode}>
110
124
  ${this.letterData
111
125
  ? html`
112
- <dedocument-pageheader
113
- .letterData=${this.letterData}
114
- .pageNumber="${this.pageNumber}"
115
- .pageTotalNumber="${this.pageTotalNumber}"
116
- ></dedocument-pageheader>
126
+ ${this.documentSettings.enableDefaultHeader
127
+ ? html`
128
+ <dedocument-pageheader
129
+ .letterData=${this.letterData}
130
+ .pageNumber="${this.pageNumber}"
131
+ .pageTotalNumber="${this.pageTotalNumber}"
132
+ ></dedocument-pageheader>
133
+ `
134
+ : ``}
117
135
  ${this.pageNumber === 1
118
136
  ? html`
119
137
  <dedocument-letterheader
@@ -129,26 +147,33 @@ export class DePage extends DeesElement {
129
147
  .letterData=${this.letterData}
130
148
  ><slot></slot
131
149
  ></dedocument-pagecontent>
132
- <dedocument-pagefooter
133
- .letterData=${this.letterData}
134
- .pageNumber="${this.pageNumber}"
135
- .pageTotalNumber="${this.pageTotalNumber}"
136
- ></dedocument-pagefooter>
150
+ ${this.documentSettings.enableDefaultFooter
151
+ ? html`
152
+ <dedocument-pagefooter
153
+ .letterData=${this.letterData}
154
+ .pageNumber="${this.pageNumber}"
155
+ .pageTotalNumber="${this.pageTotalNumber}"
156
+ ></dedocument-pagefooter>
157
+ `
158
+ : ``}
137
159
  <div class="versionOverlay">
138
160
  ${this.letterData.versionInfo.type === 'draft'
139
161
  ? html`
140
- <div class="topInfo">
141
- Please note: THIS IS A DRAFT ONLY. NO RIGHTS CAN BE DERIVED FROM THIS.<br />
142
- -> Revision/Document version: ${this.letterData.versionInfo.version}
143
- </div>
162
+ ${this.documentSettings.enableTopDraftText
163
+ ? html`
164
+ <div class="topInfo">
165
+ Please note: THIS IS A DRAFT ONLY. NO RIGHTS CAN BE DERIVED FROM
166
+ THIS.<br />
167
+ -> Revision/Document version: ${this.letterData.versionInfo.version}
168
+ </div>
169
+ `
170
+ : ``}
144
171
  <div class="bigDraftText">DRAFT</div>
145
172
  `
146
173
  : html``}
147
174
  </div>
148
175
  `
149
- : html`
150
- <slot></slot>
151
- `}
176
+ : html` <slot></slot> `}
152
177
  </dedocument-pagecontainer>
153
178
  </div>
154
179
  `;
@@ -74,13 +74,17 @@ export class DePageHeader extends DeesElement {
74
74
  color: #333;
75
75
  font-size: 10px;
76
76
  }
77
- .topstripe img {
78
- filter: invert(1);
77
+ .topstripe .logo {
79
78
  position: absolute;
80
79
  bottom: 10px;
81
80
  height: 25px;
82
81
  left: auto;
83
82
  right: ${unsafeCSS(shared.rightMargin + 'px')};
83
+ font-family: 'Courier New', Courier, monospace;
84
+ }
85
+ .topstripe .logo img {
86
+ position: relative;
87
+ height: 25px;
84
88
  }
85
89
  `,
86
90
  ];
@@ -88,7 +92,9 @@ export class DePageHeader extends DeesElement {
88
92
  public render(): TemplateResult {
89
93
  return html`
90
94
  <div class="topstripe">
91
- <img src="https://assetbroker.lossless.one/brandfiles/lossless/svg-minimal-bright.svg" />
95
+ <div class="logo">
96
+ No logo set!
97
+ </div>
92
98
  </div>
93
99
  <div class="topstripe2">${this.letterData?.from?.description || '[no letterData.from.description set]'}</div>
94
100
  `;
@@ -59,11 +59,13 @@ export const demoLetter: tsclass.business.ILetter = {
59
59
  deliveryDate: new Date().getTime(),
60
60
  periodOfPerformance: null,
61
61
  printResult: null,
62
-
62
+ currency: 'EUR',
63
+ notes: [],
64
+ type: 'debitnote',
63
65
  items: [
64
66
  {
65
67
  name: 'Item with 19% VAT',
66
- unitQuantity: 1,
68
+ unitQuantity: 2,
67
69
  unitNetPrice: 100,
68
70
  unitType: 'hours',
69
71
  vatPercentage: 19,
@@ -71,7 +73,7 @@ export const demoLetter: tsclass.business.ILetter = {
71
73
  },
72
74
  {
73
75
  name: 'Item with 7% VAT',
74
- unitQuantity: 1,
76
+ unitQuantity: 4,
75
77
  unitNetPrice: 100,
76
78
  unitType: 'hours',
77
79
  vatPercentage: 7,
@@ -79,7 +81,7 @@ export const demoLetter: tsclass.business.ILetter = {
79
81
  },
80
82
  {
81
83
  name: 'Item with 7% VAT',
82
- unitQuantity: 1,
84
+ unitQuantity: 3,
83
85
  unitNetPrice: 230,
84
86
  unitType: 'hours',
85
87
  vatPercentage: 7,
@@ -95,14 +97,14 @@ export const demoLetter: tsclass.business.ILetter = {
95
97
  },
96
98
  {
97
99
  name: 'Item with 0% VAT',
98
- unitQuantity: 1,
100
+ unitQuantity: 6,
99
101
  unitNetPrice: 230,
100
102
  unitType: 'hours',
101
103
  vatPercentage: 0,
102
104
  position: 4,
103
105
  },{
104
106
  name: 'Item with 19% VAT',
105
- unitQuantity: 1,
107
+ unitQuantity: 8,
106
108
  unitNetPrice: 100,
107
109
  unitType: 'hours',
108
110
  vatPercentage: 19,
@@ -110,7 +112,7 @@ export const demoLetter: tsclass.business.ILetter = {
110
112
  },
111
113
  {
112
114
  name: 'Item with 7% VAT',
113
- unitQuantity: 1,
115
+ unitQuantity: 9,
114
116
  unitNetPrice: 100,
115
117
  unitType: 'hours',
116
118
  vatPercentage: 7,
@@ -118,7 +120,7 @@ export const demoLetter: tsclass.business.ILetter = {
118
120
  },
119
121
  {
120
122
  name: 'Item with 7% VAT',
121
- unitQuantity: 1,
123
+ unitQuantity: 4,
122
124
  unitNetPrice: 230,
123
125
  unitType: 'hours',
124
126
  vatPercentage: 7,
@@ -126,7 +128,7 @@ export const demoLetter: tsclass.business.ILetter = {
126
128
  },
127
129
  {
128
130
  name: 'Item with 21% VAT',
129
- unitQuantity: 1,
131
+ unitQuantity: 3,
130
132
  unitNetPrice: 230,
131
133
  unitType: 'hours',
132
134
  vatPercentage: 21,
@@ -140,6 +142,54 @@ export const demoLetter: tsclass.business.ILetter = {
140
142
  vatPercentage: 0,
141
143
  position: 10,
142
144
  },
145
+ {
146
+ name: 'Item with 0% VAT',
147
+ unitQuantity: 1,
148
+ unitNetPrice: 230,
149
+ unitType: 'hours',
150
+ vatPercentage: 0,
151
+ position: 10,
152
+ },
153
+ {
154
+ name: 'Item with 0% VAT',
155
+ unitQuantity: 1,
156
+ unitNetPrice: 230,
157
+ unitType: 'hours',
158
+ vatPercentage: 0,
159
+ position: 10,
160
+ },
161
+ {
162
+ name: 'Item with 0% VAT',
163
+ unitQuantity: 1,
164
+ unitNetPrice: 230,
165
+ unitType: 'hours',
166
+ vatPercentage: 0,
167
+ position: 10,
168
+ },
169
+ {
170
+ name: 'Item with 0% VAT',
171
+ unitQuantity: 1,
172
+ unitNetPrice: 230,
173
+ unitType: 'hours',
174
+ vatPercentage: 0,
175
+ position: 10,
176
+ },
177
+ {
178
+ name: 'Item with 0% VAT',
179
+ unitQuantity: 1,
180
+ unitNetPrice: 230,
181
+ unitType: 'hours',
182
+ vatPercentage: 0,
183
+ position: 10,
184
+ },
185
+ {
186
+ name: 'Item with 0% VAT',
187
+ unitQuantity: 1,
188
+ unitNetPrice: 230,
189
+ unitType: 'hours',
190
+ vatPercentage: 0,
191
+ position: 10,
192
+ },
143
193
  ],
144
194
  }
145
195
  },
@@ -3,4 +3,7 @@ export const a4Width = 794;
3
3
  export const rightMargin = 70;
4
4
  export const leftMargin = 90;
5
5
 
6
+ import * as translation from './translation.js';
7
+ export { translation };
8
+
6
9
  export * from './demoletter.js';
@@ -0,0 +1,31 @@
1
+ import * as interfaces from '../../../ts/interfaces/index.js';
2
+
3
+ type TTranslationImplementation = {
4
+ [key in keyof interfaces.IDeDocumentTranslations]: string;
5
+ }
6
+
7
+ export const EN_translations: TTranslationImplementation = {
8
+ invoice: 'Invoice',
9
+ quantity: 'Quantity',
10
+ };
11
+
12
+ export const DE_translations: TTranslationImplementation = {
13
+ invoice: 'Rechnung',
14
+ quantity: 'Anzahl',
15
+ };
16
+
17
+ export const languageCodeMap = {
18
+ 'DE': DE_translations,
19
+ 'EN': EN_translations,
20
+ };
21
+
22
+ export type TLanguageCode = keyof typeof languageCodeMap;
23
+
24
+ export const translate = (languageCode: TLanguageCode, key: string, defaultValue: string) => {
25
+ const translations = languageCodeMap[languageCode] || EN_translations;
26
+ if (translations && translations[key]) {
27
+ return translations[key];
28
+ } else {
29
+ return defaultValue;
30
+ }
31
+ };