@dvrd/dvr-controls 1.0.33 → 1.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvrd/dvr-controls",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "Custom web controls",
5
5
  "main": "index.ts",
6
6
  "files": [
@@ -25,6 +25,7 @@ interface Props {
25
25
  height?: number;
26
26
  persistent?: PDFElementPersist;
27
27
  mainFont: PdfFont;
28
+ subExclVat?: boolean;
28
29
  }
29
30
 
30
31
  interface State {
@@ -148,13 +149,9 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
148
149
  };
149
150
 
150
151
  render = () => {
151
- const {dragging, settings} = this.state, {
152
- draggable,
153
- defaultPosition,
154
- width,
155
- height,
156
- onSaveHistory
157
- } = this.props;
152
+ const {dragging, settings} = this.state;
153
+ const {draggable, defaultPosition, width, height, onSaveHistory, subExclVat} = this.props;
154
+ const subTotalLabel = `Subtotaal ${subExclVat ? 'excl.' : 'incl.'} BTW`;
158
155
  return (
159
156
  <WithEvents events={this.event}>
160
157
  <PDFDraggable dragging={dragging} draggable={draggable} onDragStart={this.onDragStart}
@@ -173,7 +170,7 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
173
170
  <span>Aantal</span>
174
171
  <span>Bedrag</span>
175
172
  <span>BTW</span>
176
- <span className='end'>Subtotaal incl. BTW</span>
173
+ <span className='end'>{subTotalLabel}</span>
177
174
  </div>
178
175
  {[1, 2].map(this.renderInvoiceLine)}
179
176
  {this.renderTotals()}
@@ -49,6 +49,7 @@ interface Props {
49
49
  options?: PDFOptions;
50
50
  singleImage: boolean;
51
51
  headerButtons?: Array<ReactElement>;
52
+ subExclVat?: boolean;
52
53
  }
53
54
 
54
55
  interface State {
@@ -203,7 +204,7 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
203
204
  };
204
205
  const width = dimensions?.width;
205
206
  const height = dimensions?.height;
206
- const {values, mainFont} = this.props;
207
+ const {values, mainFont, subExclVat} = this.props;
207
208
  const key: string = generateUUID();
208
209
  const sharedProps = {
209
210
  defaultPosition: position,
@@ -230,7 +231,7 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
230
231
  break;
231
232
  case PDFElementType.INVOICE_TABLE:
232
233
  element = <PdfInvoiceTable {...sharedProps} width={width} height={height} mainFont={mainFont}
233
- persistent={PDFElementPersist.PERSISTENT}/>;
234
+ persistent={PDFElementPersist.PERSISTENT} subExclVat={subExclVat}/>;
234
235
  break;
235
236
  }
236
237
  return {element, config};
@@ -136,8 +136,13 @@ export const shuffleArray = (arr: any[]): any[] => {
136
136
  return arr;
137
137
  };
138
138
 
139
- export const nullify = <T extends string | Array<any>>(value?: T | null): T | null => {
140
- return value?.length ? value : null;
139
+ export const nullify = <T extends string | Array<any> | Set<any>>(value?: T | null): T | null => {
140
+ if (!value) return null;
141
+ else if (Array.isArray(value) || typeof value === 'string')
142
+ return value.length ? value : null;
143
+ else if (value instanceof Set)
144
+ return value.size ? value : null;
145
+ return null;
141
146
  };
142
147
 
143
148
  export const undefine = (value?: string | null): string | undefined => {