@driveflux/pdf 1.0.1 → 1.0.2

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 (67) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +8 -0
  3. package/dist/__mocks__/quotation.d.ts +3 -0
  4. package/dist/__mocks__/quotation.d.ts.map +1 -0
  5. package/dist/__mocks__/quotation.js +59 -0
  6. package/dist/cjs/__mocks__/quotation.js +69 -0
  7. package/dist/cjs/debug.js +33 -1
  8. package/dist/cjs/templates/QuotationPdf/CustomerSubscriptionSection.js +147 -0
  9. package/dist/cjs/templates/QuotationPdf/GFV.js +57 -0
  10. package/dist/cjs/templates/QuotationPdf/Header.js +86 -0
  11. package/dist/cjs/templates/QuotationPdf/Pricing.js +430 -0
  12. package/dist/cjs/templates/QuotationPdf/QuotationPdfPage.js +45 -0
  13. package/dist/cjs/templates/QuotationPdf/SectionBoxNew.js +43 -0
  14. package/dist/cjs/templates/QuotationPdf/TermsSection.js +60 -0
  15. package/dist/cjs/templates/QuotationPdf/index.js +208 -0
  16. package/dist/cjs/templates/QuotationPdf/translations.js +103 -0
  17. package/dist/cjs/templates/QuotationPdf/utils.js +91 -0
  18. package/dist/cjs/templates/index.js +1 -0
  19. package/dist/debug.js +33 -1
  20. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts +10 -0
  21. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts.map +1 -0
  22. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.js +132 -0
  23. package/dist/templates/QuotationPdf/GFV.d.ts +10 -0
  24. package/dist/templates/QuotationPdf/GFV.d.ts.map +1 -0
  25. package/dist/templates/QuotationPdf/GFV.js +47 -0
  26. package/dist/templates/QuotationPdf/Header.d.ts +9 -0
  27. package/dist/templates/QuotationPdf/Header.d.ts.map +1 -0
  28. package/dist/templates/QuotationPdf/Header.js +71 -0
  29. package/dist/templates/QuotationPdf/Pricing.d.ts +10 -0
  30. package/dist/templates/QuotationPdf/Pricing.d.ts.map +1 -0
  31. package/dist/templates/QuotationPdf/Pricing.js +415 -0
  32. package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts +8 -0
  33. package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts.map +1 -0
  34. package/dist/templates/QuotationPdf/QuotationPdfPage.js +30 -0
  35. package/dist/templates/QuotationPdf/SectionBoxNew.d.ts +8 -0
  36. package/dist/templates/QuotationPdf/SectionBoxNew.d.ts.map +1 -0
  37. package/dist/templates/QuotationPdf/SectionBoxNew.js +33 -0
  38. package/dist/templates/QuotationPdf/TermsSection.d.ts +8 -0
  39. package/dist/templates/QuotationPdf/TermsSection.d.ts.map +1 -0
  40. package/dist/templates/QuotationPdf/TermsSection.js +50 -0
  41. package/dist/templates/QuotationPdf/index.d.ts +9 -0
  42. package/dist/templates/QuotationPdf/index.d.ts.map +1 -0
  43. package/dist/templates/QuotationPdf/index.js +193 -0
  44. package/dist/templates/QuotationPdf/translations.d.ts +59 -0
  45. package/dist/templates/QuotationPdf/translations.d.ts.map +1 -0
  46. package/dist/templates/QuotationPdf/translations.js +93 -0
  47. package/dist/templates/QuotationPdf/utils.d.ts +6 -0
  48. package/dist/templates/QuotationPdf/utils.d.ts.map +1 -0
  49. package/dist/templates/QuotationPdf/utils.js +70 -0
  50. package/dist/templates/index.d.ts +1 -0
  51. package/dist/templates/index.d.ts.map +1 -1
  52. package/dist/templates/index.js +1 -0
  53. package/package.json +2 -2
  54. package/src/__mocks__/quotation.ts +62 -0
  55. package/src/debug.ts +12 -3
  56. package/src/templates/QuotationPdf/CustomerSubscriptionSection.tsx +65 -0
  57. package/src/templates/QuotationPdf/GFV.tsx +29 -0
  58. package/src/templates/QuotationPdf/Header.tsx +31 -0
  59. package/src/templates/QuotationPdf/Pricing.tsx +214 -0
  60. package/src/templates/QuotationPdf/QuotationPdfPage.tsx +25 -0
  61. package/src/templates/QuotationPdf/SectionBoxNew.tsx +20 -0
  62. package/src/templates/QuotationPdf/TermsSection.tsx +28 -0
  63. package/src/templates/QuotationPdf/index.tsx +46 -0
  64. package/src/templates/QuotationPdf/translations.ts +82 -0
  65. package/src/templates/QuotationPdf/utils.ts +44 -0
  66. package/src/templates/index.ts +1 -0
  67. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAc7D,KAAK,OAAO,GAAG;IACb,MAAM,CAAC,EAAE,4BAA4B,CAAA;IACrC,SAAS,EAAE,SAAS,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,oBAAoB,0BAAwC,OAAO,YAAY,MAAM,kBAEjG,CAAA"}
@@ -0,0 +1,193 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _ts_generator(thisArg, body) {
31
+ var f, y, t, g, _ = {
32
+ label: 0,
33
+ sent: function() {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
39
+ };
40
+ return g = {
41
+ next: verb(0),
42
+ "throw": verb(1),
43
+ "return": verb(2)
44
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
45
+ return this;
46
+ }), g;
47
+ function verb(n) {
48
+ return function(v) {
49
+ return step([
50
+ n,
51
+ v
52
+ ]);
53
+ };
54
+ }
55
+ function step(op) {
56
+ if (f) throw new TypeError("Generator is already executing.");
57
+ while(_)try {
58
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
59
+ if (y = 0, t) op = [
60
+ op[0] & 2,
61
+ t.value
62
+ ];
63
+ switch(op[0]){
64
+ case 0:
65
+ case 1:
66
+ t = op;
67
+ break;
68
+ case 4:
69
+ _.label++;
70
+ return {
71
+ value: op[1],
72
+ done: false
73
+ };
74
+ case 5:
75
+ _.label++;
76
+ y = op[1];
77
+ op = [
78
+ 0
79
+ ];
80
+ continue;
81
+ case 7:
82
+ op = _.ops.pop();
83
+ _.trys.pop();
84
+ continue;
85
+ default:
86
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
87
+ _ = 0;
88
+ continue;
89
+ }
90
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
91
+ _.label = op[1];
92
+ break;
93
+ }
94
+ if (op[0] === 6 && _.label < t[1]) {
95
+ _.label = t[1];
96
+ t = op;
97
+ break;
98
+ }
99
+ if (t && _.label < t[2]) {
100
+ _.label = t[2];
101
+ _.ops.push(op);
102
+ break;
103
+ }
104
+ if (t[2]) _.ops.pop();
105
+ _.trys.pop();
106
+ continue;
107
+ }
108
+ op = body.call(thisArg, _);
109
+ } catch (e) {
110
+ op = [
111
+ 6,
112
+ e
113
+ ];
114
+ y = 0;
115
+ } finally{
116
+ f = t = 0;
117
+ }
118
+ if (op[0] & 5) throw op[1];
119
+ return {
120
+ value: op[0] ? op[1] : void 0,
121
+ done: true
122
+ };
123
+ }
124
+ }
125
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
126
+ import { Document } from '@react-pdf/renderer';
127
+ import { useMemo } from 'react';
128
+ import { toPdf } from '../../utils.js';
129
+ import CustomerSubscriptionSection from './CustomerSubscriptionSection.js';
130
+ import GFV from './GFV.js';
131
+ import Pricing from './Pricing.js';
132
+ import QuotationPdfPage from './QuotationPdfPage.js';
133
+ import TermsSection from './TermsSection.js';
134
+ import { useTranslations } from './translations.js';
135
+ export var generateQuotationPdf = function() {
136
+ var _ref = _async_to_generator(function(param, fileName) {
137
+ var _param_locale, locale, quotation;
138
+ return _ts_generator(this, function(_state) {
139
+ switch(_state.label){
140
+ case 0:
141
+ _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, quotation = param.quotation;
142
+ return [
143
+ 4,
144
+ toPdf(/*#__PURE__*/ _jsx(QuotationPDF, {
145
+ locale: locale,
146
+ quotation: quotation
147
+ }), fileName)
148
+ ];
149
+ case 1:
150
+ return [
151
+ 2,
152
+ _state.sent()
153
+ ];
154
+ }
155
+ });
156
+ });
157
+ return function generateQuotationPdf(_, fileName) {
158
+ return _ref.apply(this, arguments);
159
+ };
160
+ }();
161
+ var QuotationPDF = function(param) {
162
+ var _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, quotation = param.quotation;
163
+ var pageProps = useMemo(function() {
164
+ return {
165
+ t: useTranslations(locale),
166
+ quotation: quotation
167
+ };
168
+ }, []);
169
+ var t = pageProps.t;
170
+ return /*#__PURE__*/ _jsx(Document, {
171
+ language: locale,
172
+ children: /*#__PURE__*/ _jsxs(QuotationPdfPage, {
173
+ quotation: quotation,
174
+ children: [
175
+ /*#__PURE__*/ _jsx(CustomerSubscriptionSection, {
176
+ quotation: quotation,
177
+ t: t
178
+ }),
179
+ /*#__PURE__*/ _jsx(Pricing, {
180
+ quotation: quotation,
181
+ t: t.pricing
182
+ }),
183
+ quotation.fees.gfv && /*#__PURE__*/ _jsx(GFV, {
184
+ quotation: quotation,
185
+ t: t.pricing
186
+ }),
187
+ /*#__PURE__*/ _jsx(TermsSection, {
188
+ t: t.terms
189
+ })
190
+ ]
191
+ })
192
+ });
193
+ };
@@ -0,0 +1,59 @@
1
+ declare const enTranslation: {
2
+ quotation: string;
3
+ date: string;
4
+ customer: {
5
+ title: string;
6
+ name: string;
7
+ email: string;
8
+ address: string;
9
+ };
10
+ subscription: {
11
+ title: string;
12
+ vehicleName: string;
13
+ plan: string;
14
+ mileagePackage: string;
15
+ };
16
+ subIncludes: {
17
+ title: string;
18
+ content: string[];
19
+ };
20
+ pricing: {
21
+ title: string;
22
+ fees: {
23
+ upfront: {
24
+ title: string;
25
+ content: {
26
+ title: string;
27
+ key: string;
28
+ }[];
29
+ };
30
+ monthly: {
31
+ title: string;
32
+ content: {
33
+ title: string;
34
+ key: string;
35
+ }[];
36
+ };
37
+ dueToday: {
38
+ title: string;
39
+ description: string;
40
+ subTotal: string;
41
+ serviceFee: string;
42
+ grandTotal: string;
43
+ };
44
+ extraCharge: string;
45
+ promo: string;
46
+ gfv: {
47
+ title: string;
48
+ };
49
+ };
50
+ };
51
+ terms: {
52
+ title: string;
53
+ content: string[];
54
+ };
55
+ };
56
+ export type QuotationPdfTranslation = typeof enTranslation;
57
+ export declare const useTranslations: (locale: 'en') => QuotationPdfTranslation;
58
+ export {};
59
+ //# sourceMappingURL=translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/translations.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwElB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,aAAa,CAAA;AAE1D,eAAO,MAAM,eAAe,WAAY,IAAI,KAAG,uBAK9C,CAAA"}
@@ -0,0 +1,93 @@
1
+ var enTranslation = {
2
+ quotation: "Quotation",
3
+ date: 'Date',
4
+ customer: {
5
+ title: "Customer",
6
+ name: "Name",
7
+ email: "Email",
8
+ address: "Address"
9
+ },
10
+ subscription: {
11
+ title: "Subscription",
12
+ vehicleName: "Vehicle",
13
+ plan: "Subscription Plan",
14
+ mileagePackage: "Mileage Package"
15
+ },
16
+ subIncludes: {
17
+ title: "What's Included:",
18
+ content: [
19
+ "Comprehensive insurance",
20
+ "Road tax",
21
+ "Regularly scheduled maintenance",
22
+ "Selective wear & tear",
23
+ "Ability to swap vehicles",
24
+ "Doorstep delivery",
25
+ "24/7 nationwide roadside assistance",
26
+ "Theft recovery services",
27
+ "Independently rated vehicle inspection",
28
+ "Option to purchase the vehicle at the end of the subscription"
29
+ ]
30
+ },
31
+ pricing: {
32
+ title: "Pricing",
33
+ fees: {
34
+ upfront: {
35
+ title: "Upfront Fees",
36
+ content: [
37
+ {
38
+ title: "Booking Fee",
39
+ key: 'reservationFee'
40
+ },
41
+ {
42
+ title: "Activation Fee",
43
+ key: 'startFee'
44
+ },
45
+ {
46
+ title: "Refundable Deposit",
47
+ key: 'deposit'
48
+ }
49
+ ]
50
+ },
51
+ monthly: {
52
+ title: "Monthly Fees",
53
+ content: [
54
+ {
55
+ title: "Subscription Fee",
56
+ key: 'subscriptionFee'
57
+ }
58
+ ]
59
+ },
60
+ dueToday: {
61
+ title: "Due Today",
62
+ description: "Grand Total is due before your subscription start. Monthly fee is due on the first day of every cycle period.",
63
+ subTotal: "Upfront Fees + Monthly Fee",
64
+ serviceFee: "Service Fee (8%)",
65
+ grandTotal: "Grand Total"
66
+ },
67
+ extraCharge: "Extra Charge",
68
+ promo: "Promo",
69
+ gfv: {
70
+ title: "Guaranteed Future Value (GFV)"
71
+ }
72
+ }
73
+ },
74
+ terms: {
75
+ title: "Terms",
76
+ content: [
77
+ "This quotation is valid for 7 days.",
78
+ "All vehicles proposed are unique and are available to our customers on a first come first served basis.",
79
+ "The Mileage Package is the monthly mileage cap for the vehicle. If you exceed this cap for any given month, excess mileage charges will be incurred.",
80
+ "Initial payment to be made within 7 days of the invoice date.",
81
+ "Subscription starts on the date of the car delivery.",
82
+ "The upfront fees are billed one-time per subscription, before the subscription starts.",
83
+ "All monthly recurring fees are billed on the same date as the delivery of the vehicle.",
84
+ "Scheduling delivery will only commence Grand Total is fully paid, 7 - 30+ days after payment and subject to vehicle availability."
85
+ ]
86
+ }
87
+ };
88
+ export var useTranslations = function(locale) {
89
+ var translation = {
90
+ en: enTranslation
91
+ };
92
+ return translation[locale];
93
+ };
@@ -0,0 +1,6 @@
1
+ import { MileagePackage, PlanType } from '@driveflux/db';
2
+ import { Address } from '@driveflux/db/types';
3
+ export declare const formatAddress: (originalAddress: Address) => string;
4
+ export declare const getSimplifiedPlanTranslation: (plan: PlanType) => "60 Months" | "36 Months" | "24 Months" | "12 Months" | "Monthly" | "Weekly" | "Unknown Plan";
5
+ export declare const getMileagePackageTranslation: (mileagePackage?: MileagePackage) => "Lite" | "Standard" | "Plus" | "Unlimited" | "Unknown Mileage Package";
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/templates/QuotationPdf/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,eAAO,MAAM,aAAa,oBAAqB,OAAO,WAMrD,CAAA;AAED,eAAO,MAAM,4BAA4B,SAAU,QAAQ,kGAiB1D,CAAA;AAED,eAAO,MAAM,4BAA4B,oBAAqB,cAAc,2EAa3E,CAAA"}
@@ -0,0 +1,70 @@
1
+ function _object_without_properties(source, excluded) {
2
+ if (source == null) return {};
3
+ var target = _object_without_properties_loose(source, excluded);
4
+ var key, i;
5
+ if (Object.getOwnPropertySymbols) {
6
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
7
+ for(i = 0; i < sourceSymbolKeys.length; i++){
8
+ key = sourceSymbolKeys[i];
9
+ if (excluded.indexOf(key) >= 0) continue;
10
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
11
+ target[key] = source[key];
12
+ }
13
+ }
14
+ return target;
15
+ }
16
+ function _object_without_properties_loose(source, excluded) {
17
+ if (source == null) return {};
18
+ var target = {};
19
+ var sourceKeys = Object.keys(source);
20
+ var key, i;
21
+ for(i = 0; i < sourceKeys.length; i++){
22
+ key = sourceKeys[i];
23
+ if (excluded.indexOf(key) >= 0) continue;
24
+ target[key] = source[key];
25
+ }
26
+ return target;
27
+ }
28
+ export var formatAddress = function(originalAddress) {
29
+ var coordinates = originalAddress.coordinates, metadata = originalAddress.metadata, address = _object_without_properties(originalAddress, [
30
+ "coordinates",
31
+ "metadata"
32
+ ]);
33
+ return Object.keys(address).filter(function(key) {
34
+ return key !== 'name' && !!address[key];
35
+ }).map(function(a) {
36
+ return address[a];
37
+ }).join(', ');
38
+ };
39
+ export var getSimplifiedPlanTranslation = function(plan) {
40
+ switch(plan){
41
+ case 'plan60':
42
+ return "60 Months";
43
+ case 'plan36':
44
+ return "36 Months";
45
+ case 'plan24':
46
+ return "24 Months";
47
+ case 'plan12':
48
+ return "12 Months";
49
+ case 'plan1':
50
+ return "Monthly";
51
+ case 'planWeekly':
52
+ return "Weekly";
53
+ default:
54
+ return "Unknown Plan";
55
+ }
56
+ };
57
+ export var getMileagePackageTranslation = function(mileagePackage) {
58
+ switch(mileagePackage){
59
+ case 'lite':
60
+ return "Lite";
61
+ case 'standard':
62
+ return "Standard";
63
+ case 'plus':
64
+ return "Plus";
65
+ case 'unlimited':
66
+ return "Unlimited";
67
+ default:
68
+ return "Unknown Mileage Package";
69
+ }
70
+ };
@@ -1,2 +1,3 @@
1
+ export * from './QuotationPdf/index.js';
1
2
  export * from './SubscriptionAgreement/index.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA"}
@@ -1 +1,2 @@
1
+ export * from './QuotationPdf/index.js';
1
2
  export * from './SubscriptionAgreement/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/pdf",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/index.js",
@@ -13,7 +13,7 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@driveflux/db": "1.0.36",
16
+ "@driveflux/db": "1.0.37",
17
17
  "@driveflux/env": "1.0.6",
18
18
  "@driveflux/time": "4.0.5",
19
19
  "@react-pdf/renderer": "^3.4.4",
@@ -0,0 +1,62 @@
1
+ import { Quotation } from '@driveflux/db'
2
+
3
+ export const quotation: Quotation = {
4
+ id: 'QUO_XZJLVSM8',
5
+ vehicleId: 'VBEXLQR',
6
+ plan: 'plan36',
7
+ mileagePackage: 'lite',
8
+ cycleFluxCoefficient: 'flux25',
9
+ customerName: 'Bubu Ahmad',
10
+ vehicleName: 'Volkswagen Polo 1.6 Sedan 2011',
11
+ createdById: 'U2R88JRVL',
12
+
13
+ createdAt: new Date('2024-05-27T02:26:36.070Z'),
14
+ updatedAt: new Date('2024-05-27T02:26:36.070Z'),
15
+ metadata: {},
16
+ customer: {
17
+ type: 'user',
18
+ name: 'Bubu Ahmad',
19
+ email: 'bubu@gmail.com',
20
+ address: {
21
+ street1: '15-2 Jalan Solaris',
22
+ city: 'Kuala Lumpur',
23
+ state: 'Johor',
24
+ postalCode: '12323',
25
+ country: 'MY'
26
+ }
27
+ },
28
+ fees: {
29
+ subscriptionFee: 800,
30
+ reservationFee: 0,
31
+ startFee: 498,
32
+ deposit: 1600,
33
+ depositMonths: 2,
34
+ extraCharges: [
35
+ {
36
+ type: 'upfront',
37
+ description: 'Spare Tyre',
38
+ amount: 2500.2
39
+ },
40
+ {
41
+ type: 'upfront',
42
+ description: 'Spare Tyre No 2',
43
+ amount: 3000.2
44
+ },
45
+ {
46
+ type: 'monthly',
47
+ description: 'Commitment ',
48
+ amount: 2
49
+ }
50
+ ],
51
+ amountBeforeTax: 8400.4,
52
+ taxAmount: 672.03,
53
+ amountAfterTax: 9072.43,
54
+ gfv: 0,
55
+ cycle: null,
56
+ couponCode: null,
57
+ discountAmount: null,
58
+ appliedDiscountId: null,
59
+ couponType: ''
60
+ },
61
+ quotationPdf: null
62
+ }
package/src/debug.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { loadAllEnv } from '@driveflux/env'
2
+ import { quotation } from './__mocks__/quotation.js'
2
3
  import { subscription } from './__mocks__/subscription.js'
3
4
  import { generateSubscriptionAgreementPdf } from './templates/SubscriptionAgreement/index.js'
5
+ import { generateQuotationPdf } from './templates/index.js'
4
6
 
5
7
  const debugSubscriptionAgreement = async () => {
6
8
  if (!subscription) {
@@ -11,10 +13,17 @@ const debugSubscriptionAgreement = async () => {
11
13
  await generateSubscriptionAgreementPdf({ subscription }, `${process.cwd()}/output/subscription-agreement.pdf`)
12
14
  }
13
15
 
16
+ const debugQuotation = async () => {
17
+ if (!quotation) {
18
+ console.error('no such quotation')
19
+ return
20
+ }
21
+
22
+ await generateQuotationPdf({ quotation }, `${process.cwd()}/output/quotation.pdf`)
23
+ }
24
+
14
25
  //! put all the debugging functions here
15
- const debugCases: Promise<any>[] = [
16
- debugSubscriptionAgreement()
17
- ]
26
+ const debugCases: Promise<any>[] = [debugSubscriptionAgreement(), debugQuotation()]
18
27
 
19
28
  const debug = async () => {
20
29
  loadAllEnv()
@@ -0,0 +1,65 @@
1
+ import { Quotation } from '@driveflux/db'
2
+ import { Address } from '@driveflux/db/types/index.js'
3
+ import { Text, View } from '@react-pdf/renderer'
4
+ import { FC } from 'react'
5
+ import { colors } from '../../theme/colors.js'
6
+ import SectionBoxNew from './SectionBoxNew.js'
7
+ import { QuotationPdfTranslation } from './translations.js'
8
+ import { formatAddress, getMileagePackageTranslation, getSimplifiedPlanTranslation } from './utils.js'
9
+
10
+ type Props = {
11
+ quotation: Quotation
12
+ t: QuotationPdfTranslation
13
+ }
14
+
15
+ const CustomerSubscriptionSection: FC<Props> = ({ quotation, t }) => {
16
+ const displayContent = (label: string, value: string, labelColor = colors.black, valueColor = colors.primary3) => (
17
+ <View style={{ gap: 4 }}>
18
+ <Text style={{ color: labelColor, letterSpacing: 1 }}>{label}</Text>
19
+ <Text style={{ color: valueColor, letterSpacing: 1 }}>{value}</Text>
20
+ </View>
21
+ )
22
+
23
+ return (
24
+ <View>
25
+ <SectionBoxNew
26
+ topContent={
27
+ <>
28
+ <Text style={{ textTransform: 'uppercase', fontSize: 12, fontWeight: 'bold' }}>{t.customer.title}</Text>
29
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
30
+ {displayContent(t.customer.name, quotation.customerName)}
31
+ {quotation.customer.email && displayContent(t.customer.email, quotation.customer.email)}
32
+ </View>
33
+ {quotation.customer.address &&
34
+ displayContent(t.customer.address, formatAddress(quotation.customer.address as Address))}
35
+ </>
36
+ }
37
+ bottomContent={
38
+ <>
39
+ <Text style={{ textTransform: 'uppercase', fontSize: 12, fontWeight: 'bold' }}>{t.subscription.title}</Text>
40
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between', gap: 4 }}>
41
+ {displayContent(t.subscription.vehicleName, quotation.vehicleName)}
42
+ <View style={{ justifyContent: 'space-between', flexDirection: 'row', gap: 16 }}>
43
+ {displayContent(t.subscription.plan, getSimplifiedPlanTranslation(quotation.plan))}
44
+ {displayContent(t.subscription.mileagePackage, getMileagePackageTranslation(quotation.mileagePackage))}
45
+ </View>
46
+ </View>
47
+ <View style={{ rowGap: 8 }}>
48
+ <Text style={{ color: colors.primary3, fontWeight: 'bold', letterSpacing: 1 }}>
49
+ {t.subIncludes.title}
50
+ </Text>
51
+ {t.subIncludes.content.map((line, i) => (
52
+ <View key={i} style={{ flexDirection: 'row', alignItems: 'flex-start', rowGap: 8 }}>
53
+ <Text style={{ marginRight: 4 }}>•</Text>
54
+ <Text style={{ color: colors.primary3, letterSpacing: 1 }}>{line}</Text>
55
+ </View>
56
+ ))}
57
+ </View>
58
+ </>
59
+ }
60
+ />
61
+ </View>
62
+ )
63
+ }
64
+
65
+ export default CustomerSubscriptionSection
@@ -0,0 +1,29 @@
1
+ import { Quotation } from '@driveflux/db'
2
+ import { formatMoney } from '@driveflux/format-money'
3
+ import { Text, View } from '@react-pdf/renderer'
4
+ import { FC } from 'react'
5
+ import { colors } from '../../theme/colors.js'
6
+ import { QuotationPdfTranslation } from './translations'
7
+
8
+ type Props = {
9
+ quotation: Quotation
10
+ t?: QuotationPdfTranslation['pricing']
11
+ }
12
+
13
+ const GFV: FC<Props> = ({ quotation, t }) => {
14
+ if (!quotation.fees.gfv) return
15
+
16
+ return (
17
+ <View style={{ border: `1px solid ${colors.primary2}`, padding: 16, rowGap: 16 }}>
18
+ <Text style={{ color: colors.primary3, fontWeight: 'bold', letterSpacing: 1, textTransform: 'uppercase' }}>
19
+ {t?.fees.gfv.title}
20
+ </Text>
21
+ <Text style={{ color: colors.primary3, letterSpacing: 1 }}>
22
+ You have the option to purchase this vehicle with GFV amount of
23
+ <Text style={{ fontWeight: 'bold' }}> {formatMoney(quotation.fees.gfv)} </Text>at the end of your subscription.
24
+ </Text>
25
+ </View>
26
+ )
27
+ }
28
+
29
+ export default GFV