@driveflux/pdf 1.3.15 → 1.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 (27) hide show
  1. package/dist/__mocks__/quotation.d.ts.map +1 -1
  2. package/dist/__mocks__/quotation.js +49 -76
  3. package/dist/__mocks__/subscription.js +1 -1
  4. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts +2 -2
  5. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts.map +1 -1
  6. package/dist/templates/QuotationPdf/GFV.d.ts +2 -2
  7. package/dist/templates/QuotationPdf/GFV.d.ts.map +1 -1
  8. package/dist/templates/QuotationPdf/GFV.js +24 -10
  9. package/dist/templates/QuotationPdf/Pricing.d.ts +2 -2
  10. package/dist/templates/QuotationPdf/Pricing.d.ts.map +1 -1
  11. package/dist/templates/QuotationPdf/Pricing.js +362 -69
  12. package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts +2 -2
  13. package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts.map +1 -1
  14. package/dist/templates/QuotationPdf/SectionBoxNew.d.ts +1 -1
  15. package/dist/templates/QuotationPdf/SectionBoxNew.d.ts.map +1 -1
  16. package/dist/templates/QuotationPdf/SectionBoxNew.js +16 -12
  17. package/dist/templates/QuotationPdf/index.d.ts +5 -2
  18. package/dist/templates/QuotationPdf/index.d.ts.map +1 -1
  19. package/dist/templates/QuotationPdf/index.js +37 -25
  20. package/dist/templates/QuotationPdf/translations.d.ts +3 -0
  21. package/dist/templates/QuotationPdf/translations.d.ts.map +1 -1
  22. package/dist/templates/QuotationPdf/translations.js +6 -2
  23. package/dist/templates/QuotationPdf/utils.d.ts +6 -1
  24. package/dist/templates/QuotationPdf/utils.d.ts.map +1 -1
  25. package/dist/templates/QuotationPdf/utils.js +18 -0
  26. package/package.json +4 -4
  27. package/dist/cjs/package.json +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"quotation.d.ts","sourceRoot":"","sources":["../../src/__mocks__/quotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,eAAO,MAAM,SAAS,EAAE,SAoIvB,CAAA"}
1
+ {"version":3,"file":"quotation.d.ts","sourceRoot":"","sources":["../../src/__mocks__/quotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,SAAS,EAAE,SAqGvB,CAAA"}
@@ -1,124 +1,97 @@
1
1
  export var quotation = {
2
- id: 'QCRR5ZJN3',
3
- vehicleId: 'V5JP2VS',
2
+ id: 'QU9HLAPJ9',
3
+ vehicleId: 'V8AR2D4ZC',
4
4
  plan: 'plan36',
5
5
  mileagePackage: 'lite',
6
- cycleFluxCoefficient: 'flux15',
7
- customerName: 'af',
8
- vehicleName: 'Perodua Myvi 1.5 AV 2018',
6
+ cycleFluxCoefficient: 15,
7
+ customerName: 'dddd',
8
+ vehicleName: 'Honda WR-V 1.5 V 2024',
9
+ couponId: 'coupon_Zg4SUy-wTiRCD7Rd1LqNx',
10
+ couponCode: 'KF23FLUX50',
9
11
  createdById: 'U2R88JRVL',
10
- createdAt: new Date('2024-10-17T12:04:44.420Z'),
11
- updatedAt: new Date('2024-10-17T12:04:44.700Z'),
12
+ createdAt: new Date('2024-11-14T06:09:04.927Z'),
13
+ updatedAt: new Date('2024-11-14T06:09:05.411Z'),
12
14
  metadata: {},
13
15
  customer: {
14
16
  type: 'user',
15
- name: 'af',
16
- email: '',
17
- address: {}
17
+ name: 'dddd',
18
+ email: null,
19
+ address: null
18
20
  },
19
21
  fees: {
20
- subscriptionFee: 1080,
21
- reservationFee: 45.371,
22
- startFee: 686.4,
23
- deposit: 2160,
22
+ subscriptionFee: 1610,
23
+ reservationFee: 0,
24
+ startFee: 1085,
25
+ deposit: 3220,
26
+ cycle: null,
27
+ couponType: null,
28
+ gfv: null,
24
29
  depositMonths: 2,
25
30
  extraCharges: [],
26
31
  discountAmount: 0,
27
- appliedDiscountId: '',
28
- couponCode: '',
29
- couponType: '',
30
- amountBeforeTax: 3971.771,
31
- taxAmount: 317.74,
32
- amountAfterTax: 4289.511,
33
- excessMileageFee: 0.65,
34
- cycle: null,
35
- gfv: null
32
+ amountBeforeTax: 5915,
33
+ taxAmount: 473.2,
34
+ amountAfterTax: 6388.2,
35
+ excessMileageFee: 0.84,
36
+ quotedPrices: {
37
+ startFee: 1000,
38
+ deposit: 322,
39
+ subscriptionFee: 1000,
40
+ extraCharges: [],
41
+ amountBeforeTax: 2322,
42
+ taxAmount: 185.76,
43
+ amountAfterTax: 2507.76
44
+ }
36
45
  },
37
46
  images: [
38
47
  {
39
- default: 'https://s3.ap-southeast-1.amazonaws.com/flux-site-files/static%2Fraw%2FV5JP2VS%2FNefMGTxvxdFmaZvy9An7T-1-edited.jpg',
40
- blurBase64: null,
41
- thumbnail: null,
42
- small: null,
43
- medium: null,
44
- large: null,
45
- description: null,
48
+ default: 'https://flux-site-files.s3.ap-southeast-1.amazonaws.com/vehicles-v8-ar2-d4-zc-images-whats-app-image-2024-09-19-at-12-45-27-pm.jpeg',
46
49
  inspection: true,
47
50
  inspectionType: 'exterior',
48
- notActualPhoto: false
49
- },
50
- {
51
- default: 'https://s3.ap-southeast-1.amazonaws.com/flux-site-files/static%2Fraw%2FV5JP2VS%2Fjeb6Okl1rXSDfeSeBY4-D-2-edited.jpg',
51
+ notActualPhoto: false,
52
52
  blurBase64: null,
53
53
  thumbnail: null,
54
54
  small: null,
55
55
  medium: null,
56
56
  large: null,
57
- description: null,
58
- inspection: false,
59
- inspectionType: null,
60
- notActualPhoto: false
57
+ description: null
61
58
  },
62
59
  {
63
- default: 'https://s3.ap-southeast-1.amazonaws.com/flux-site-files/static%2Fraw%2FV5JP2VS%2F4a21uc2_H_Y3yfBGuLeR9-5.JPG',
64
- blurBase64: null,
65
- thumbnail: null,
66
- small: null,
67
- medium: null,
68
- large: null,
69
- description: null,
60
+ default: 'https://flux-site-files.s3.ap-southeast-1.amazonaws.com/vehicles-v8-ar2-d4-zc-images-whats-app-image-2024-09-19-at-12-47-23-pm.jpeg',
70
61
  inspection: true,
71
62
  inspectionType: 'frame',
72
- notActualPhoto: false
73
- },
74
- {
75
- default: 'https://s3.ap-southeast-1.amazonaws.com/flux-site-files/static%2Fraw%2FV5JP2VS%2FGAQS5MFE_wy9HURTui6vd-9.JPG',
76
- blurBase64: null,
77
- thumbnail: null,
78
- small: null,
79
- medium: null,
80
- large: null,
81
- description: null,
82
- inspection: true,
83
- inspectionType: 'interior',
84
- notActualPhoto: false
85
- },
86
- {
87
- default: 'https://s3.ap-southeast-1.amazonaws.com/flux-site-files/static%2Fraw%2FV5JP2VS%2FeRxfs0-i7CS3HzT0y5nFo-10.JPG',
63
+ notActualPhoto: false,
88
64
  blurBase64: null,
89
65
  thumbnail: null,
90
66
  small: null,
91
67
  medium: null,
92
68
  large: null,
93
- description: null,
94
- inspection: false,
95
- inspectionType: null,
96
- notActualPhoto: false
69
+ description: null
97
70
  },
98
71
  {
99
- default: 'https://s3.ap-southeast-1.amazonaws.com/flux-site-files/static%2Fraw%2FV5JP2VS%2Fb6J6P0hDNuVGjDhQvf7_w-11.JPG',
72
+ default: 'https://flux-site-files.s3.ap-southeast-1.amazonaws.com/vehicles-v8-ar2-d4-zc-images-whats-app-image-2024-09-19-at-12-48-30-pm-1.jpeg',
73
+ inspection: true,
74
+ inspectionType: 'interior',
75
+ notActualPhoto: false,
100
76
  blurBase64: null,
101
77
  thumbnail: null,
102
78
  small: null,
103
79
  medium: null,
104
80
  large: null,
105
- description: null,
106
- inspection: false,
107
- inspectionType: null,
108
- notActualPhoto: false
81
+ description: null
109
82
  },
110
83
  {
111
- default: 'https://s3.ap-southeast-1.amazonaws.com/flux-site-files/static%2Fraw%2FV5JP2VS%2Fk9myRzc4U4JxyQ-IQfKGS-15.JPG',
84
+ default: 'https://flux-site-files.s3.ap-southeast-1.amazonaws.com/vehicles-v8-ar2-d4-zc-images-whats-app-image-2024-09-19-at-12-48-31-pm.jpeg',
85
+ inspection: true,
86
+ inspectionType: 'engine',
87
+ notActualPhoto: false,
112
88
  blurBase64: null,
113
89
  thumbnail: null,
114
90
  small: null,
115
91
  medium: null,
116
92
  large: null,
117
- description: null,
118
- inspection: true,
119
- inspectionType: 'engine',
120
- notActualPhoto: false
93
+ description: null
121
94
  }
122
95
  ],
123
- quotationPdf: 'https://dev-flux-admin.s3.ap-southeast-1.amazonaws.com/quotations/QCRR5ZJN3.pdf'
96
+ quotationPdf: 'https://dev-flux-admin.s3.ap-southeast-1.amazonaws.com/quotations/QU9HLAPJ9.pdf'
124
97
  };
@@ -581,7 +581,7 @@ export var subscription = {
581
581
  },
582
582
  fluxPrice: {
583
583
  add: null,
584
- coefficient: 'flux10',
584
+ coefficient: 10,
585
585
  excessMileage: 1.4,
586
586
  originalExcessMileage: 1.8,
587
587
  matrix: {
@@ -1,8 +1,8 @@
1
- import type { Quotation } from '@driveflux/db';
2
1
  import type { FC } from 'react';
2
+ import type { QuotationWithCoupon } from './index.js';
3
3
  import type { QuotationPdfTranslation } from './translations.js';
4
4
  type Props = {
5
- quotation: Quotation;
5
+ quotation: QuotationWithCoupon;
6
6
  t: QuotationPdfTranslation;
7
7
  };
8
8
  declare const CustomerSubscriptionSection: FC<Props>;
@@ -1 +1 @@
1
- {"version":3,"file":"CustomerSubscriptionSection.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/CustomerSubscriptionSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAOhE,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,SAAS,CAAA;IACpB,CAAC,EAAE,uBAAuB,CAAA;CAC1B,CAAA;AAED,QAAA,MAAM,2BAA2B,EAAE,EAAE,CAAC,KAAK,CA4I1C,CAAA;AAED,eAAe,2BAA2B,CAAA"}
1
+ {"version":3,"file":"CustomerSubscriptionSection.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/CustomerSubscriptionSection.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAOhE,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,mBAAmB,CAAA;IAC9B,CAAC,EAAE,uBAAuB,CAAA;CAC1B,CAAA;AAED,QAAA,MAAM,2BAA2B,EAAE,EAAE,CAAC,KAAK,CA4I1C,CAAA;AAED,eAAe,2BAA2B,CAAA"}
@@ -1,8 +1,8 @@
1
- import type { Quotation } from '@driveflux/db';
2
1
  import type { FC } from 'react';
2
+ import type { QuotationWithCoupon } from './index.js';
3
3
  import type { QuotationPdfTranslation } from './translations';
4
4
  type Props = {
5
- quotation: Quotation;
5
+ quotation: QuotationWithCoupon;
6
6
  t?: QuotationPdfTranslation['pricing'];
7
7
  };
8
8
  declare const GFV: FC<Props>;
@@ -1 +1 @@
1
- {"version":3,"file":"GFV.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/GFV.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAE7D,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,SAAS,CAAA;IACpB,CAAC,CAAC,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAA;CACtC,CAAA;AAED,QAAA,MAAM,GAAG,EAAE,EAAE,CAAC,KAAK,CA+BlB,CAAA;AAED,eAAe,GAAG,CAAA"}
1
+ {"version":3,"file":"GFV.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/GFV.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAE7D,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,mBAAmB,CAAA;IAC9B,CAAC,CAAC,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAA;CACtC,CAAA;AAED,QAAA,MAAM,GAAG,EAAE,EAAE,CAAC,KAAK,CAwClB,CAAA;AAED,eAAe,GAAG,CAAA"}
@@ -14,31 +14,45 @@ var GFV = function(param) {
14
14
  children: [
15
15
  /*#__PURE__*/ _jsx(Text, {
16
16
  style: {
17
- color: colors.primary3,
17
+ color: colors.black,
18
18
  fontWeight: 'bold',
19
19
  letterSpacing: 1,
20
- textTransform: 'uppercase'
20
+ textTransform: 'uppercase',
21
+ flexWrap: 'nowrap'
21
22
  },
22
23
  children: t === null || t === void 0 ? void 0 : t.fees.gfv.title
23
24
  }),
24
- /*#__PURE__*/ _jsxs(Text, {
25
+ /*#__PURE__*/ _jsxs(View, {
25
26
  style: {
26
- color: colors.primary3,
27
- letterSpacing: 1
27
+ display: 'flex',
28
+ flexDirection: 'row',
29
+ flexWrap: 'wrap'
28
30
  },
29
31
  children: [
30
- "You have the option to purchase this vehicle with GFV amount of",
31
32
  /*#__PURE__*/ _jsxs(Text, {
32
33
  style: {
33
- fontWeight: 'bold'
34
+ color: colors.primary3,
35
+ letterSpacing: 1
34
36
  },
35
37
  children: [
36
- ' ',
37
- formatMoney(quotation.fees.gfv),
38
+ "You have the option to purchase this vehicle with GFV amount of",
38
39
  ' '
39
40
  ]
40
41
  }),
41
- "at the end of your subscription."
42
+ /*#__PURE__*/ _jsx(Text, {
43
+ style: {
44
+ fontWeight: 'bold',
45
+ color: colors.primary3
46
+ },
47
+ children: formatMoney(quotation.fees.gfv)
48
+ }),
49
+ /*#__PURE__*/ _jsx(Text, {
50
+ style: {
51
+ color: colors.primary3,
52
+ letterSpacing: 1
53
+ },
54
+ children: "at the end of your subscription."
55
+ })
42
56
  ]
43
57
  })
44
58
  ]
@@ -1,8 +1,8 @@
1
- import type { Quotation } from '@driveflux/db';
2
1
  import type { FC } from 'react';
2
+ import type { QuotationWithCoupon } from './index.js';
3
3
  import type { QuotationPdfTranslation } from './translations.js';
4
4
  type Props = {
5
- quotation: Quotation;
5
+ quotation: QuotationWithCoupon;
6
6
  t?: QuotationPdfTranslation['pricing'];
7
7
  };
8
8
  declare const Pricing: FC<Props>;
@@ -1 +1 @@
1
- {"version":3,"file":"Pricing.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/Pricing.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAEhE,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,SAAS,CAAA;IACpB,CAAC,CAAC,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAA;CACtC,CAAA;AAED,QAAA,MAAM,OAAO,EAAE,EAAE,CAAC,KAAK,CAyVtB,CAAA;AAED,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"Pricing.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/Pricing.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAEhE,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,mBAAmB,CAAA;IAC9B,CAAC,CAAC,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAA;CACtC,CAAA;AAED,QAAA,MAAM,OAAO,EAAE,EAAE,CAAC,KAAK,CAwtBtB,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -6,39 +6,70 @@ import SectionBoxNew from './SectionBoxNew.js';
6
6
  var Pricing = function(param) {
7
7
  var quotation = param.quotation, t = param.t;
8
8
  var _quotation_fees_discountAmount, _quotation_fees_discountAmount1;
9
- var _quotation_fees = quotation.fees, startFee = _quotation_fees.startFee, reservationFee = _quotation_fees.reservationFee, deposit = _quotation_fees.deposit, subscriptionFee = _quotation_fees.subscriptionFee, extraCharges = _quotation_fees.extraCharges, couponCode = _quotation_fees.couponCode, couponType = _quotation_fees.couponType, discountAmount = _quotation_fees.discountAmount;
10
- var totalUpfrontFee = startFee + (reservationFee || 0) + deposit;
11
- var totalMonthlyFee = subscriptionFee;
12
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13
- try {
14
- for(var _iterator = extraCharges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
15
- var charge = _step.value;
16
- if (charge.type === 'upfront') {
17
- totalUpfrontFee += charge.amount;
18
- } else if (charge.type === 'monthly') {
19
- totalMonthlyFee += charge.amount;
9
+ var _quotation_fees = quotation.fees, startFee = _quotation_fees.startFee, reservationFee = _quotation_fees.reservationFee, deposit = _quotation_fees.deposit, subscriptionFee = _quotation_fees.subscriptionFee, extraCharges = _quotation_fees.extraCharges, couponType = _quotation_fees.couponType, discountAmount = _quotation_fees.discountAmount, quotedPrices = _quotation_fees.quotedPrices;
10
+ var hasDiscounts = quotedPrices !== null && quotedPrices !== undefined;
11
+ var totalUpfrontFee = hasDiscounts ? ((quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.startFee) || 0) + (reservationFee || 0) + ((quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.deposit) || 0) : startFee + (reservationFee || 0) + deposit;
12
+ var totalMonthlyFee = hasDiscounts ? (quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.subscriptionFee) || 0 : subscriptionFee;
13
+ if (hasDiscounts) {
14
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
15
+ try {
16
+ for(var _iterator = quotedPrices.extraCharges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
17
+ var charge = _step.value;
18
+ if (charge.type === 'upfront') {
19
+ totalUpfrontFee += charge.amount;
20
+ } else if (charge.type === 'monthly') {
21
+ totalMonthlyFee += charge.amount;
22
+ }
23
+ }
24
+ } catch (err) {
25
+ _didIteratorError = true;
26
+ _iteratorError = err;
27
+ } finally{
28
+ try {
29
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
30
+ _iterator.return();
31
+ }
32
+ } finally{
33
+ if (_didIteratorError) {
34
+ throw _iteratorError;
35
+ }
20
36
  }
21
37
  }
22
- } catch (err) {
23
- _didIteratorError = true;
24
- _iteratorError = err;
25
- } finally{
38
+ } else {
39
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
26
40
  try {
27
- if (!_iteratorNormalCompletion && _iterator.return != null) {
28
- _iterator.return();
41
+ for(var _iterator1 = extraCharges[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
42
+ var charge1 = _step1.value;
43
+ if (charge1.type === 'upfront') {
44
+ totalUpfrontFee += charge1.amount;
45
+ } else if (charge1.type === 'monthly') {
46
+ totalMonthlyFee += charge1.amount;
47
+ }
29
48
  }
49
+ } catch (err) {
50
+ _didIteratorError1 = true;
51
+ _iteratorError1 = err;
30
52
  } finally{
31
- if (_didIteratorError) {
32
- throw _iteratorError;
53
+ try {
54
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
55
+ _iterator1.return();
56
+ }
57
+ } finally{
58
+ if (_didIteratorError1) {
59
+ throw _iteratorError1;
60
+ }
33
61
  }
34
62
  }
35
63
  }
36
- if (couponCode && couponType === 'upfront') {
37
- totalUpfrontFee -= discountAmount || 0;
38
- }
39
- if (couponCode && couponType === 'monthly') {
40
- totalMonthlyFee -= discountAmount || 0;
64
+ if (quotation.couponCode) {
65
+ if (couponType === 'upfront') {
66
+ totalUpfrontFee -= discountAmount || 0;
67
+ } else if (couponType === 'monthly') {
68
+ totalMonthlyFee -= discountAmount || 0;
69
+ }
41
70
  }
71
+ var serviceMonthlyFee = totalMonthlyFee * 0.08;
72
+ var serviceUpfrontFee = (totalUpfrontFee * 0.08).toFixed(2);
42
73
  var getFeeValue = function(key) {
43
74
  switch(key){
44
75
  case 'startFee':
@@ -53,6 +84,43 @@ var Pricing = function(param) {
53
84
  return null;
54
85
  }
55
86
  };
87
+ var getQuotedFeeValue = function(key) {
88
+ switch(key){
89
+ case 'startFee':
90
+ return quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.startFee;
91
+ case 'deposit':
92
+ return quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.deposit;
93
+ case 'subscriptionFee':
94
+ return quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.subscriptionFee;
95
+ case 'reservationFee':
96
+ return reservationFee;
97
+ default:
98
+ return null;
99
+ }
100
+ };
101
+ var upfrontTotalDiscount = function() {
102
+ var _quotedPrices_extraCharges;
103
+ // Calculate base fees total (startFee + deposit)
104
+ var originalBaseTotal = startFee + deposit;
105
+ var quotedBaseTotal = ((quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.startFee) || 0) + ((quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.deposit) || 0);
106
+ // Calculate original upfront extra charges
107
+ var originalExtraCharges = extraCharges.filter(function(charge) {
108
+ return charge.type === 'upfront';
109
+ }).reduce(function(sum, charge) {
110
+ return sum + charge.amount;
111
+ }, 0);
112
+ // Calculate quoted upfront extra charges
113
+ var quotedExtraCharges = (quotedPrices === null || quotedPrices === void 0 ? void 0 : (_quotedPrices_extraCharges = quotedPrices.extraCharges) === null || _quotedPrices_extraCharges === void 0 ? void 0 : _quotedPrices_extraCharges.filter(function(charge) {
114
+ return charge.type === 'upfront';
115
+ }).reduce(function(sum, charge) {
116
+ return sum + charge.amount;
117
+ }, 0)) || originalExtraCharges;
118
+ var originalTotal = originalBaseTotal + originalExtraCharges;
119
+ var quotedTotal = quotedBaseTotal + quotedExtraCharges;
120
+ // Calculate total discount (original - quoted)
121
+ var totalDiscount = originalTotal - quotedTotal;
122
+ return totalDiscount;
123
+ };
56
124
  return /*#__PURE__*/ _jsx(View, {
57
125
  children: /*#__PURE__*/ _jsx(SectionBoxNew, {
58
126
  topContent: /*#__PURE__*/ _jsxs(_Fragment, {
@@ -74,8 +142,10 @@ var Pricing = function(param) {
74
142
  children: t === null || t === void 0 ? void 0 : t.fees.upfront.title
75
143
  }),
76
144
  t === null || t === void 0 ? void 0 : t.fees.upfront.content.map(function(fee) {
77
- var _getFeeValue;
145
+ var _getFeeValue, _getQuotedFeeValue;
78
146
  var feeValue = (_getFeeValue = getFeeValue(fee.key)) === null || _getFeeValue === void 0 ? void 0 : _getFeeValue.toFixed(2);
147
+ var _getQuotedFeeValue_toFixed;
148
+ var quotedFeeValue = (_getQuotedFeeValue_toFixed = (_getQuotedFeeValue = getQuotedFeeValue(fee.key)) === null || _getQuotedFeeValue === void 0 ? void 0 : _getQuotedFeeValue.toFixed(2)) !== null && _getQuotedFeeValue_toFixed !== void 0 ? _getQuotedFeeValue_toFixed : undefined;
79
149
  if (feeValue === '0.00') {
80
150
  return null;
81
151
  }
@@ -94,6 +164,38 @@ var Pricing = function(param) {
94
164
  },
95
165
  children: fee.title
96
166
  }),
167
+ hasDiscounts && fee.key !== 'reservationFee' ? // Only show strikethrough if quoted value is different from original value
168
+ feeValue !== quotedFeeValue ? /*#__PURE__*/ _jsxs(View, {
169
+ style: {
170
+ justifyContent: 'flex-end',
171
+ flexDirection: 'row'
172
+ },
173
+ children: [
174
+ /*#__PURE__*/ _jsx(Text, {
175
+ style: {
176
+ color: colors.primary2,
177
+ letterSpacing: 1,
178
+ textDecoration: 'line-through',
179
+ marginRight: 4
180
+ },
181
+ children: feeValue !== null ? feeValue : ''
182
+ }),
183
+ /*#__PURE__*/ _jsx(Text, {
184
+ style: {
185
+ color: colors.primary3,
186
+ letterSpacing: 1
187
+ },
188
+ children: quotedFeeValue
189
+ })
190
+ ]
191
+ }) : // When values are the same, just show the single value
192
+ /*#__PURE__*/ _jsx(Text, {
193
+ style: {
194
+ color: colors.primary3,
195
+ letterSpacing: 1
196
+ },
197
+ children: feeValue !== null ? feeValue : ''
198
+ }) : // When no discounts or it's a reservation fee
97
199
  /*#__PURE__*/ _jsx(Text, {
98
200
  style: {
99
201
  color: colors.primary3,
@@ -116,19 +218,53 @@ var Pricing = function(param) {
116
218
  rowGap: 8
117
219
  },
118
220
  children: [
119
- /*#__PURE__*/ _jsxs(Text, {
221
+ /*#__PURE__*/ _jsx(Text, {
120
222
  style: {
121
223
  paddingRight: 4,
122
224
  letterSpacing: 1,
123
225
  color: colors.primary3
124
226
  },
125
- children: [
126
- t === null || t === void 0 ? void 0 : t.fees.extraCharge,
127
- " - ",
128
- charge.description
129
- ]
227
+ children: charge.description
130
228
  }),
131
- /*#__PURE__*/ _jsx(Text, {
229
+ hasDiscounts ? function() {
230
+ var quotedCharge = quotedPrices.extraCharges.find(function(extraCharge) {
231
+ return extraCharge.description === charge.description;
232
+ });
233
+ var originalAmount = charge.amount.toFixed(2);
234
+ var quotedAmount = quotedCharge === null || quotedCharge === void 0 ? void 0 : quotedCharge.amount.toFixed(2);
235
+ // Only show strikethrough if amounts are different
236
+ return originalAmount !== quotedAmount ? /*#__PURE__*/ _jsxs(View, {
237
+ style: {
238
+ justifyContent: 'flex-end',
239
+ flexDirection: 'row'
240
+ },
241
+ children: [
242
+ /*#__PURE__*/ _jsx(Text, {
243
+ style: {
244
+ color: colors.primary2,
245
+ letterSpacing: 1,
246
+ textDecoration: 'line-through',
247
+ marginRight: 4
248
+ },
249
+ children: originalAmount
250
+ }),
251
+ /*#__PURE__*/ _jsx(Text, {
252
+ style: {
253
+ color: colors.primary3,
254
+ letterSpacing: 1
255
+ },
256
+ children: quotedAmount
257
+ })
258
+ ]
259
+ }) : // When amounts are the same, show single value
260
+ /*#__PURE__*/ _jsx(Text, {
261
+ style: {
262
+ color: colors.primary3,
263
+ letterSpacing: 1
264
+ },
265
+ children: originalAmount
266
+ });
267
+ }() : /*#__PURE__*/ _jsx(Text, {
132
268
  style: {
133
269
  color: colors.primary3,
134
270
  letterSpacing: 1
@@ -138,7 +274,7 @@ var Pricing = function(param) {
138
274
  ]
139
275
  }, i);
140
276
  }),
141
- quotation.fees.couponCode !== null && quotation.fees.couponType === 'upfront' && /*#__PURE__*/ _jsxs(View, {
277
+ quotation.couponCode !== null && couponType === 'upfront' && /*#__PURE__*/ _jsxs(View, {
142
278
  style: {
143
279
  justifyContent: 'space-between',
144
280
  flexDirection: 'row',
@@ -154,15 +290,77 @@ var Pricing = function(param) {
154
290
  children: [
155
291
  t === null || t === void 0 ? void 0 : t.fees.promo,
156
292
  " - ",
157
- quotation.fees.couponCode
293
+ quotation.couponCode
158
294
  ]
159
295
  }),
296
+ /*#__PURE__*/ _jsxs(Text, {
297
+ style: {
298
+ color: colors.success4,
299
+ letterSpacing: 1,
300
+ fontWeight: 'bold'
301
+ },
302
+ children: [
303
+ "- ",
304
+ (_quotation_fees_discountAmount = quotation.fees.discountAmount) === null || _quotation_fees_discountAmount === void 0 ? void 0 : _quotation_fees_discountAmount.toFixed(2)
305
+ ]
306
+ })
307
+ ]
308
+ }),
309
+ hasDiscounts && /*#__PURE__*/ _jsxs(View, {
310
+ style: {
311
+ justifyContent: 'space-between',
312
+ flexDirection: 'row',
313
+ rowGap: 8
314
+ },
315
+ children: [
160
316
  /*#__PURE__*/ _jsx(Text, {
161
317
  style: {
162
- color: colors.accent4,
318
+ color: colors.primary3,
319
+ letterSpacing: 1,
320
+ paddingRight: 4
321
+ },
322
+ children: t === null || t === void 0 ? void 0 : t.fees.totalDiscount
323
+ }),
324
+ /*#__PURE__*/ _jsxs(Text, {
325
+ style: {
326
+ color: colors.success4,
327
+ fontWeight: 'bold',
163
328
  letterSpacing: 1
164
329
  },
165
- children: (_quotation_fees_discountAmount = quotation.fees.discountAmount) === null || _quotation_fees_discountAmount === void 0 ? void 0 : _quotation_fees_discountAmount.toFixed(2)
330
+ children: [
331
+ "- ",
332
+ upfrontTotalDiscount()
333
+ ]
334
+ })
335
+ ]
336
+ }),
337
+ /*#__PURE__*/ _jsxs(View, {
338
+ style: {
339
+ justifyContent: 'space-between',
340
+ flexDirection: 'row',
341
+ rowGap: 8
342
+ },
343
+ children: [
344
+ /*#__PURE__*/ _jsx(Text, {
345
+ style: {
346
+ color: colors.primary3,
347
+ letterSpacing: 1,
348
+ paddingRight: 4
349
+ },
350
+ children: t === null || t === void 0 ? void 0 : t.fees.upfront.serviceFee
351
+ }),
352
+ quotedPrices !== undefined ? /*#__PURE__*/ _jsx(Text, {
353
+ style: {
354
+ color: colors.primary3,
355
+ letterSpacing: 1
356
+ },
357
+ children: serviceUpfrontFee
358
+ }) : /*#__PURE__*/ _jsx(Text, {
359
+ style: {
360
+ color: colors.primary3,
361
+ letterSpacing: 1
362
+ },
363
+ children: serviceUpfrontFee
166
364
  })
167
365
  ]
168
366
  }),
@@ -178,15 +376,17 @@ var Pricing = function(param) {
178
376
  /*#__PURE__*/ _jsx(Text, {
179
377
  style: {
180
378
  letterSpacing: 1,
181
- paddingRight: 4
379
+ paddingRight: 4,
380
+ fontWeight: 'bold'
182
381
  },
183
382
  children: "Total"
184
383
  }),
185
384
  /*#__PURE__*/ _jsx(Text, {
186
385
  style: {
187
- letterSpacing: 1
386
+ letterSpacing: 1,
387
+ fontWeight: 'bold'
188
388
  },
189
- children: formatMoney(totalUpfrontFee)
389
+ children: formatMoney(totalUpfrontFee + Number.parseFloat(serviceUpfrontFee))
190
390
  })
191
391
  ]
192
392
  }),
@@ -204,8 +404,13 @@ var Pricing = function(param) {
204
404
  children: t === null || t === void 0 ? void 0 : t.fees.monthly.title
205
405
  }),
206
406
  t === null || t === void 0 ? void 0 : t.fees.monthly.content.map(function(fee) {
207
- var _getFeeValue;
407
+ var _getFeeValue, _getQuotedFeeValue;
208
408
  var feeValue = (_getFeeValue = getFeeValue(fee.key)) === null || _getFeeValue === void 0 ? void 0 : _getFeeValue.toFixed(2);
409
+ var _getQuotedFeeValue_toFixed;
410
+ var quotedFeeValue = (_getQuotedFeeValue_toFixed = (_getQuotedFeeValue = getQuotedFeeValue(fee.key)) === null || _getQuotedFeeValue === void 0 ? void 0 : _getQuotedFeeValue.toFixed(2)) !== null && _getQuotedFeeValue_toFixed !== void 0 ? _getQuotedFeeValue_toFixed : undefined;
411
+ if (feeValue === '0.00') {
412
+ return null;
413
+ }
209
414
  return /*#__PURE__*/ _jsxs(View, {
210
415
  style: {
211
416
  justifyContent: 'space-between',
@@ -221,19 +426,49 @@ var Pricing = function(param) {
221
426
  },
222
427
  children: fee.title
223
428
  }),
429
+ hasDiscounts ? feeValue !== quotedFeeValue ? /*#__PURE__*/ _jsxs(View, {
430
+ style: {
431
+ justifyContent: 'flex-end',
432
+ flexDirection: 'row'
433
+ },
434
+ children: [
435
+ /*#__PURE__*/ _jsx(Text, {
436
+ style: {
437
+ color: colors.primary2,
438
+ letterSpacing: 1,
439
+ textDecoration: 'line-through',
440
+ marginRight: 4
441
+ },
442
+ children: feeValue !== null ? feeValue : ''
443
+ }),
444
+ /*#__PURE__*/ _jsx(Text, {
445
+ style: {
446
+ color: colors.primary3,
447
+ letterSpacing: 1
448
+ },
449
+ children: quotedFeeValue
450
+ })
451
+ ]
452
+ }) : // When values are the same, just show the single value
224
453
  /*#__PURE__*/ _jsx(Text, {
225
454
  style: {
226
455
  color: colors.primary3,
227
456
  letterSpacing: 1
228
457
  },
229
458
  children: feeValue !== null ? feeValue : ''
459
+ }) : /*#__PURE__*/ _jsx(Text, {
460
+ style: {
461
+ color: colors.primary3,
462
+ letterSpacing: 1
463
+ },
464
+ children: feeValue !== null ? feeValue : ''
230
465
  })
231
466
  ]
232
467
  }, fee.key);
233
468
  }),
234
469
  quotation.fees.extraCharges.length > 0 && quotation.fees.extraCharges.filter(function(charge) {
235
470
  return charge.type === 'monthly';
236
- }).map(function(charge, i) {
471
+ }).map(function(charge) {
237
472
  return /*#__PURE__*/ _jsxs(View, {
238
473
  style: {
239
474
  justifyContent: 'space-between',
@@ -241,19 +476,53 @@ var Pricing = function(param) {
241
476
  rowGap: 8
242
477
  },
243
478
  children: [
244
- /*#__PURE__*/ _jsxs(Text, {
479
+ /*#__PURE__*/ _jsx(Text, {
245
480
  style: {
246
481
  paddingRight: 4,
247
482
  letterSpacing: 1,
248
483
  color: colors.primary3
249
484
  },
250
- children: [
251
- t === null || t === void 0 ? void 0 : t.fees.extraCharge,
252
- " - ",
253
- charge.description
254
- ]
485
+ children: charge.description
255
486
  }),
256
- /*#__PURE__*/ _jsx(Text, {
487
+ hasDiscounts ? function() {
488
+ var quotedCharge = quotedPrices.extraCharges.find(function(extraCharge) {
489
+ return extraCharge.description === charge.description;
490
+ });
491
+ var originalAmount = charge.amount.toFixed(2);
492
+ var quotedAmount = quotedCharge === null || quotedCharge === void 0 ? void 0 : quotedCharge.amount.toFixed(2);
493
+ // Only show strikethrough if amounts are different
494
+ return originalAmount !== quotedAmount ? /*#__PURE__*/ _jsxs(View, {
495
+ style: {
496
+ justifyContent: 'flex-end',
497
+ flexDirection: 'row'
498
+ },
499
+ children: [
500
+ /*#__PURE__*/ _jsx(Text, {
501
+ style: {
502
+ color: colors.primary2,
503
+ letterSpacing: 1,
504
+ textDecoration: 'line-through',
505
+ marginRight: 4
506
+ },
507
+ children: originalAmount
508
+ }),
509
+ /*#__PURE__*/ _jsx(Text, {
510
+ style: {
511
+ color: colors.primary3,
512
+ letterSpacing: 1
513
+ },
514
+ children: quotedAmount
515
+ })
516
+ ]
517
+ }) : // When amounts are the same, show single value
518
+ /*#__PURE__*/ _jsx(Text, {
519
+ style: {
520
+ color: colors.primary3,
521
+ letterSpacing: 1
522
+ },
523
+ children: originalAmount
524
+ });
525
+ }() : /*#__PURE__*/ _jsx(Text, {
257
526
  style: {
258
527
  color: colors.primary3,
259
528
  letterSpacing: 1
@@ -261,9 +530,9 @@ var Pricing = function(param) {
261
530
  children: charge.amount.toFixed(2)
262
531
  })
263
532
  ]
264
- }, i);
533
+ }, charge.description);
265
534
  }),
266
- quotation.fees.couponCode !== null && quotation.fees.couponType === 'monthly' && /*#__PURE__*/ _jsxs(View, {
535
+ quotation.couponCode !== null && couponType === 'monthly' && /*#__PURE__*/ _jsxs(View, {
267
536
  style: {
268
537
  justifyContent: 'space-between',
269
538
  flexDirection: 'row',
@@ -279,15 +548,43 @@ var Pricing = function(param) {
279
548
  children: [
280
549
  t === null || t === void 0 ? void 0 : t.fees.promo,
281
550
  " - ",
282
- quotation.fees.couponCode
551
+ quotation.couponCode
552
+ ]
553
+ }),
554
+ /*#__PURE__*/ _jsxs(Text, {
555
+ style: {
556
+ color: colors.success4,
557
+ letterSpacing: 1,
558
+ fontWeight: 'bold'
559
+ },
560
+ children: [
561
+ "- ",
562
+ (_quotation_fees_discountAmount1 = quotation.fees.discountAmount) === null || _quotation_fees_discountAmount1 === void 0 ? void 0 : _quotation_fees_discountAmount1.toFixed(2)
283
563
  ]
564
+ })
565
+ ]
566
+ }),
567
+ /*#__PURE__*/ _jsxs(View, {
568
+ style: {
569
+ justifyContent: 'space-between',
570
+ flexDirection: 'row',
571
+ rowGap: 8
572
+ },
573
+ children: [
574
+ /*#__PURE__*/ _jsx(Text, {
575
+ style: {
576
+ color: colors.primary3,
577
+ letterSpacing: 1,
578
+ paddingRight: 4
579
+ },
580
+ children: t === null || t === void 0 ? void 0 : t.fees.monthly.serviceFee
284
581
  }),
285
582
  /*#__PURE__*/ _jsx(Text, {
286
583
  style: {
287
- color: colors.accent4,
584
+ color: colors.primary3,
288
585
  letterSpacing: 1
289
586
  },
290
- children: (_quotation_fees_discountAmount1 = quotation.fees.discountAmount) === null || _quotation_fees_discountAmount1 === void 0 ? void 0 : _quotation_fees_discountAmount1.toFixed(2)
587
+ children: serviceMonthlyFee.toFixed(2)
291
588
  })
292
589
  ]
293
590
  }),
@@ -303,15 +600,17 @@ var Pricing = function(param) {
303
600
  /*#__PURE__*/ _jsx(Text, {
304
601
  style: {
305
602
  letterSpacing: 1,
306
- paddingRight: 4
603
+ paddingRight: 4,
604
+ fontWeight: 'bold'
307
605
  },
308
606
  children: "Total"
309
607
  }),
310
608
  /*#__PURE__*/ _jsx(Text, {
311
609
  style: {
312
- letterSpacing: 1
610
+ letterSpacing: 1,
611
+ fontWeight: 'bold'
313
612
  },
314
- children: formatMoney(totalMonthlyFee)
613
+ children: formatMoney(totalMonthlyFee + serviceMonthlyFee)
315
614
  })
316
615
  ]
317
616
  })
@@ -344,22 +643,19 @@ var Pricing = function(param) {
344
643
  flexDirection: 'row'
345
644
  },
346
645
  children: [
347
- /*#__PURE__*/ _jsxs(Text, {
646
+ /*#__PURE__*/ _jsx(Text, {
348
647
  style: {
349
648
  letterSpacing: 1,
350
649
  color: colors.primary3
351
650
  },
352
- children: [
353
- ' ',
354
- t === null || t === void 0 ? void 0 : t.fees.dueToday.subTotal
355
- ]
651
+ children: t === null || t === void 0 ? void 0 : t.fees.dueToday.subTotal
356
652
  }),
357
653
  /*#__PURE__*/ _jsx(Text, {
358
654
  style: {
359
655
  letterSpacing: 1,
360
656
  color: colors.primary3
361
657
  },
362
- children: quotation.fees.amountBeforeTax.toFixed(2)
658
+ children: hasDiscounts ? quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.amountBeforeTax.toFixed(2) : quotation.fees.amountBeforeTax.toFixed(2)
363
659
  })
364
660
  ]
365
661
  }),
@@ -369,22 +665,19 @@ var Pricing = function(param) {
369
665
  flexDirection: 'row'
370
666
  },
371
667
  children: [
372
- /*#__PURE__*/ _jsxs(Text, {
668
+ /*#__PURE__*/ _jsx(Text, {
373
669
  style: {
374
670
  letterSpacing: 1,
375
671
  color: colors.primary3
376
672
  },
377
- children: [
378
- ' ',
379
- t === null || t === void 0 ? void 0 : t.fees.dueToday.serviceFee
380
- ]
673
+ children: t === null || t === void 0 ? void 0 : t.fees.dueToday.serviceFee
381
674
  }),
382
675
  /*#__PURE__*/ _jsx(Text, {
383
676
  style: {
384
677
  letterSpacing: 1,
385
678
  color: colors.primary3
386
679
  },
387
- children: quotation.fees.taxAmount.toFixed(2)
680
+ children: hasDiscounts ? quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.taxAmount.toFixed(2) : quotation.fees.taxAmount.toFixed(2)
388
681
  })
389
682
  ]
390
683
  }),
@@ -410,7 +703,7 @@ var Pricing = function(param) {
410
703
  letterSpacing: 1,
411
704
  fontWeight: 'bold'
412
705
  },
413
- children: formatMoney(quotation.fees.amountAfterTax)
706
+ children: hasDiscounts ? quotedPrices === null || quotedPrices === void 0 ? void 0 : quotedPrices.amountAfterTax.toFixed(2) : quotation.fees.amountAfterTax.toFixed(2)
414
707
  })
415
708
  ]
416
709
  })
@@ -1,7 +1,7 @@
1
- import type { Quotation } from '@driveflux/db';
2
1
  import type { FC, PropsWithChildren } from 'react';
2
+ import type { QuotationWithCoupon } from './index.js';
3
3
  type Props = {
4
- quotation: Quotation;
4
+ quotation: QuotationWithCoupon;
5
5
  };
6
6
  declare const QuotationPdfPage: FC<PropsWithChildren<Props>>;
7
7
  export default QuotationPdfPage;
@@ -1 +1 @@
1
- {"version":3,"file":"QuotationPdfPage.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/QuotationPdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAIlD,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,QAAA,MAAM,gBAAgB,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAclD,CAAA;AAED,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"QuotationPdfPage.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/QuotationPdfPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAGlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,KAAK,KAAK,GAAG;IACZ,SAAS,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,QAAA,MAAM,gBAAgB,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAclD,CAAA;AAED,eAAe,gBAAgB,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import type { FC, ReactNode } from 'react';
2
2
  type Props = {
3
3
  topContent: ReactNode;
4
- bottomContent: ReactNode;
4
+ bottomContent?: ReactNode;
5
5
  children?: ReactNode;
6
6
  };
7
7
  declare const SectionBoxNew: FC<Props>;
@@ -1 +1 @@
1
- {"version":3,"file":"SectionBoxNew.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/SectionBoxNew.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAG1C,KAAK,KAAK,GAAG;IACZ,UAAU,EAAE,SAAS,CAAA;IACrB,aAAa,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,KAAK,CAS5B,CAAA;AAED,eAAe,aAAa,CAAA"}
1
+ {"version":3,"file":"SectionBoxNew.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/SectionBoxNew.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAG1C,KAAK,KAAK,GAAG;IACZ,UAAU,EAAE,SAAS,CAAA;IACrB,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,KAAK,CAa5B,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { View } from '@react-pdf/renderer';
3
3
  import { colors } from '../../theme/colors.js';
4
4
  var SectionBoxNew = function(param) {
@@ -15,17 +15,21 @@ var SectionBoxNew = function(param) {
15
15
  },
16
16
  children: topContent
17
17
  }),
18
- /*#__PURE__*/ _jsx(View, {
19
- style: {
20
- borderBottom: "1px solid ".concat(colors.primary2)
21
- }
22
- }),
23
- /*#__PURE__*/ _jsx(View, {
24
- style: {
25
- padding: 16,
26
- rowGap: 16
27
- },
28
- children: bottomContent
18
+ bottomContent && /*#__PURE__*/ _jsxs(_Fragment, {
19
+ children: [
20
+ /*#__PURE__*/ _jsx(View, {
21
+ style: {
22
+ borderBottom: "1px solid ".concat(colors.primary2)
23
+ }
24
+ }),
25
+ /*#__PURE__*/ _jsx(View, {
26
+ style: {
27
+ padding: 16,
28
+ rowGap: 16
29
+ },
30
+ children: bottomContent
31
+ })
32
+ ]
29
33
  }),
30
34
  children
31
35
  ]
@@ -1,8 +1,11 @@
1
- import type { Quotation } from '@driveflux/db';
1
+ import type { Coupon, Quotation } from '@driveflux/db';
2
2
  import type { PdfTemplatesSupportedLocales } from '../../types.js';
3
+ export type QuotationWithCoupon = Quotation & {
4
+ coupon?: Coupon;
5
+ };
3
6
  type Options = {
4
7
  locale?: PdfTemplatesSupportedLocales;
5
- quotation: Quotation;
8
+ quotation: QuotationWithCoupon;
6
9
  };
7
10
  export declare const generateQuotationPdf: ({ locale, quotation }: Options, fileName?: string) => Promise<Buffer>;
8
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAelE,KAAK,OAAO,GAAG;IACd,MAAM,CAAC,EAAE,4BAA4B,CAAA;IACrC,SAAS,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,oBAAoB,0BACF,OAAO,aAC1B,MAAM,oBAMjB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAItD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAUlE,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,KAAK,OAAO,GAAG;IACd,MAAM,CAAC,EAAE,4BAA4B,CAAA;IACrC,SAAS,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,oBAAoB,0BACF,OAAO,aAC1B,MAAM,oBAMjB,CAAA"}
@@ -125,6 +125,7 @@ function _ts_generator(thisArg, body) {
125
125
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
126
126
  import { Document } from '@react-pdf/renderer';
127
127
  import { useMemo } from 'react';
128
+ import StandardPage from '../../components/StandardPage.js';
128
129
  import { toPdf } from '../../utils.js';
129
130
  import CustomerSubscriptionSection from './CustomerSubscriptionSection.js';
130
131
  import GFV from './GFV.js';
@@ -172,31 +173,42 @@ var QuotationPDF = function(param) {
172
173
  quotation
173
174
  ]);
174
175
  var t = pageProps.t;
175
- return /*#__PURE__*/ _jsx(Document, {
176
+ return /*#__PURE__*/ _jsxs(Document, {
176
177
  language: locale,
177
- children: /*#__PURE__*/ _jsxs(QuotationPdfPage, {
178
- quotation: quotation,
179
- children: [
180
- /*#__PURE__*/ _jsx(CustomerSubscriptionSection, {
181
- quotation: quotation,
182
- t: t
183
- }),
184
- /*#__PURE__*/ _jsx(Pricing, {
185
- quotation: quotation,
186
- t: t.pricing
187
- }),
188
- quotation.fees.gfv && /*#__PURE__*/ _jsx(GFV, {
189
- quotation: quotation,
190
- t: t.pricing
191
- }),
192
- /*#__PURE__*/ _jsx(VehiclePhotos, {
193
- quotation: quotation,
194
- t: t.vehiclePhotos
195
- }),
196
- /*#__PURE__*/ _jsx(TermsSection, {
197
- t: t.terms
198
- })
199
- ]
200
- })
178
+ children: [
179
+ /*#__PURE__*/ _jsxs(QuotationPdfPage, {
180
+ quotation: quotation,
181
+ children: [
182
+ /*#__PURE__*/ _jsx(CustomerSubscriptionSection, {
183
+ quotation: quotation,
184
+ t: t
185
+ }),
186
+ /*#__PURE__*/ _jsx(Pricing, {
187
+ quotation: quotation,
188
+ t: t.pricing
189
+ }),
190
+ quotation.fees.gfv && /*#__PURE__*/ _jsx(GFV, {
191
+ quotation: quotation,
192
+ t: t.pricing
193
+ })
194
+ ]
195
+ }),
196
+ /*#__PURE__*/ _jsxs(StandardPage, {
197
+ style: {
198
+ padding: 40,
199
+ fontSize: 10,
200
+ gap: 16
201
+ },
202
+ children: [
203
+ /*#__PURE__*/ _jsx(VehiclePhotos, {
204
+ quotation: quotation,
205
+ t: t.vehiclePhotos
206
+ }),
207
+ /*#__PURE__*/ _jsx(TermsSection, {
208
+ t: t.terms
209
+ })
210
+ ]
211
+ })
212
+ ]
201
213
  });
202
214
  };
@@ -26,6 +26,7 @@ declare const enTranslation: {
26
26
  fees: {
27
27
  upfront: {
28
28
  title: string;
29
+ serviceFee: string;
29
30
  content: {
30
31
  title: string;
31
32
  key: string;
@@ -33,6 +34,7 @@ declare const enTranslation: {
33
34
  };
34
35
  monthly: {
35
36
  title: string;
37
+ serviceFee: string;
36
38
  content: {
37
39
  title: string;
38
40
  key: string;
@@ -50,6 +52,7 @@ declare const enTranslation: {
50
52
  gfv: {
51
53
  title: string;
52
54
  };
55
+ totalDiscount: string;
53
56
  };
54
57
  };
55
58
  terms: {
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/translations.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;yCA+Ba,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDrC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,aAAa,CAAA;AAE1D,eAAO,MAAM,eAAe,WAAY,IAAI,KAAG,uBAK9C,CAAA"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/translations.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;yCA+Ba,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDrC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,aAAa,CAAA;AAE1D,eAAO,MAAM,eAAe,WAAY,IAAI,KAAG,uBAK9C,CAAA"}
@@ -39,6 +39,7 @@ var enTranslation = {
39
39
  fees: {
40
40
  upfront: {
41
41
  title: 'Upfront Fees',
42
+ serviceFee: 'Service Fee (8%)',
42
43
  content: [
43
44
  {
44
45
  title: 'Booking Fee',
@@ -56,6 +57,7 @@ var enTranslation = {
56
57
  },
57
58
  monthly: {
58
59
  title: 'Monthly Fees',
60
+ serviceFee: 'Service Fee (8%)',
59
61
  content: [
60
62
  {
61
63
  title: 'Subscription Fee',
@@ -74,7 +76,8 @@ var enTranslation = {
74
76
  promo: 'Promo',
75
77
  gfv: {
76
78
  title: 'Guaranteed Future Value (GFV)'
77
- }
79
+ },
80
+ totalDiscount: 'Total Discount'
78
81
  }
79
82
  },
80
83
  terms: {
@@ -87,7 +90,8 @@ var enTranslation = {
87
90
  'Subscription starts on the date of the car delivery.',
88
91
  'The upfront fees are billed one-time per subscription, before the subscription starts.',
89
92
  'All monthly recurring fees are billed on the same date as the delivery of the vehicle.',
90
- 'Scheduling delivery will only commence Grand Total is fully paid, 7 - 30+ days after payment and subject to vehicle availability.'
93
+ 'Scheduling delivery will only commence Grand Total is fully paid, 7 - 30+ days after payment and subject to vehicle availability.',
94
+ 'Guaranteed Future Value prices are not inclusive of processing fees'
91
95
  ]
92
96
  },
93
97
  vehiclePhotos: {
@@ -1,9 +1,14 @@
1
- import type { MileagePackage, PlanType, VehicleType } from '@driveflux/db';
1
+ import type { DiscountType, MileagePackage, PlanType, VehicleType } from '@driveflux/db';
2
2
  import type { INSPECTION_TYPES } from '@driveflux/db/models/vehicle';
3
3
  import type { Address } from '@driveflux/db/types/helpers';
4
4
  export declare const formatAddress: (originalAddress: Address) => string;
5
5
  export declare const getSimplifiedPlanTranslation: (plan: PlanType) => "60 Months" | "36 Months" | "24 Months" | "12 Months" | "Weekly" | "Unknown Plan" | "Monthly";
6
6
  export declare const getMileagePackageTranslation: (mileagePackage?: MileagePackage) => "Unlimited" | "Unknown Mileage Package" | "Lite" | "Standard" | "Plus";
7
7
  export declare const getFullMileagePackageTranslation: (plan?: MileagePackage | null) => "Lite - 1,250KM" | "Standard - 2,000KM" | "Plus - 2,750KM" | "Unlimited" | "Unknown Mileage Package";
8
+ export declare const getPromoNotes: (amount: number, discount: {
9
+ discountType: DiscountType;
10
+ discountValue: number;
11
+ maxRedemptions: number;
12
+ }) => string;
8
13
  export declare const getInspectionTypeTranslation: (inspectionType?: (typeof INSPECTION_TYPES)[VehicleType][number]) => "Exterior" | "Interior" | "Engine" | "Frame" | "Dashboard" | undefined;
9
14
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAE1D,eAAO,MAAM,aAAa,oBAAqB,OAAO,WAMrD,CAAA;AAED,eAAO,MAAM,4BAA4B,SAAU,QAAQ,kGAiB1D,CAAA;AAED,eAAO,MAAM,4BAA4B,oBACvB,cAAc,2EAc/B,CAAA;AAED,eAAO,MAAM,gCAAgC,UACrC,cAAc,GAAG,IAAI,yGAc5B,CAAA;AAED,eAAO,MAAM,4BAA4B,oBACvB,CAAC,OAAO,gBAAgB,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC,2EAgB/D,CAAA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,WAAW,EACX,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAG1D,eAAO,MAAM,aAAa,oBAAqB,OAAO,WAMrD,CAAA;AAED,eAAO,MAAM,4BAA4B,SAAU,QAAQ,kGAiB1D,CAAA;AAED,eAAO,MAAM,4BAA4B,oBACvB,cAAc,2EAc/B,CAAA;AAED,eAAO,MAAM,gCAAgC,UACrC,cAAc,GAAG,IAAI,yGAc5B,CAAA;AACD,eAAO,MAAM,aAAa,WACjB,MAAM,YACJ;IACT,YAAY,EAAE,YAAY,CAAA;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;CACtB,WAkBD,CAAA;AAED,eAAO,MAAM,4BAA4B,oBACvB,CAAC,OAAO,gBAAgB,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC,2EAgB/D,CAAA"}
@@ -25,6 +25,7 @@ function _object_without_properties_loose(source, excluded) {
25
25
  }
26
26
  return target;
27
27
  }
28
+ import { formatMoney } from '@driveflux/format-money';
28
29
  export var formatAddress = function(originalAddress) {
29
30
  var coordinates = originalAddress.coordinates, metadata = originalAddress.metadata, address = _object_without_properties(originalAddress, [
30
31
  "coordinates",
@@ -82,6 +83,23 @@ export var getFullMileagePackageTranslation = function(plan) {
82
83
  return 'Unknown Mileage Package';
83
84
  }
84
85
  };
86
+ export var getPromoNotes = function(amount, discount) {
87
+ var discountType = discount.discountType, discountValue = discount.discountValue, maxRedemptions = discount.maxRedemptions;
88
+ switch(discountType){
89
+ case 'percentage':
90
+ return "Enjoy ".concat(discountValue * 100, "% off for ").concat(maxRedemptions, " month(s) for this vehicle.");
91
+ case 'fixed':
92
+ {
93
+ var money = formatMoney(discountValue);
94
+ return amount <= 0 ? "Enjoy free for ".concat(maxRedemptions, " month(s).") : "Enjoy ".concat(money, " off for the first ").concat(maxRedemptions, " month(s), then your subscription will switch to the regular price.");
95
+ }
96
+ case 'forceAmount':
97
+ {
98
+ var money1 = formatMoney(Math.min(amount, discountValue));
99
+ return "Enjoy only ".concat(money1, " for ").concat(maxRedemptions, " month(s), then your subscription will switch to the regular price.");
100
+ }
101
+ }
102
+ };
85
103
  export var getInspectionTypeTranslation = function(inspectionType) {
86
104
  switch(inspectionType){
87
105
  case 'exterior':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/pdf",
3
- "version": "1.3.15",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -12,10 +12,10 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@driveflux/db": "1.9.4",
15
+ "@driveflux/db": "1.10.0",
16
16
  "@driveflux/env": "1.3.0",
17
- "@driveflux/format-money": "5.3.1",
18
- "@driveflux/time": "4.3.1",
17
+ "@driveflux/format-money": "5.3.2",
18
+ "@driveflux/time": "4.3.2",
19
19
  "@react-pdf/renderer": "^4.0.0",
20
20
  "date-fns": "^3.6.0",
21
21
  "nodemon": "^3.1.7",
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }