@star-insure/sdk 0.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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +8 -0
  5. package/dist/lib/dates.d.ts +8 -0
  6. package/dist/lib/index.d.ts +2 -0
  7. package/dist/lib/money.d.ts +32 -0
  8. package/dist/sdk.cjs.development.js +104 -0
  9. package/dist/sdk.cjs.development.js.map +1 -0
  10. package/dist/sdk.cjs.production.min.js +2 -0
  11. package/dist/sdk.cjs.production.min.js.map +1 -0
  12. package/dist/sdk.esm.js +92 -0
  13. package/dist/sdk.esm.js.map +1 -0
  14. package/dist/types/api/auth.d.ts +8 -0
  15. package/dist/types/api/enums.d.ts +3 -0
  16. package/dist/types/api/index.d.ts +30 -0
  17. package/dist/types/index.d.ts +3 -0
  18. package/dist/types/misc/index.d.ts +8 -0
  19. package/dist/types/misc/inertia.d.ts +8 -0
  20. package/dist/types/models/auth/Group.d.ts +10 -0
  21. package/dist/types/models/auth/Permission.d.ts +4 -0
  22. package/dist/types/models/auth/Role.d.ts +6 -0
  23. package/dist/types/models/auth/User.d.ts +12 -0
  24. package/dist/types/models/auth/index.d.ts +4 -0
  25. package/dist/types/models/claims/ClaimRequest.d.ts +267 -0
  26. package/dist/types/models/claims/index.d.ts +1 -0
  27. package/dist/types/models/index.d.ts +3 -0
  28. package/dist/types/models/oracle/Risk.d.ts +7 -0
  29. package/dist/types/models/oracle/TableData.d.ts +8 -0
  30. package/dist/types/models/oracle/index.d.ts +2 -0
  31. package/dist/types/models/quotes/QuoteRequest.d.ts +130 -0
  32. package/dist/types/models/quotes/index.d.ts +1 -0
  33. package/package.json +65 -0
  34. package/src/index.ts +2 -0
  35. package/src/lib/dates.ts +15 -0
  36. package/src/lib/index.ts +2 -0
  37. package/src/lib/money.ts +72 -0
  38. package/src/types/api/auth.ts +10 -0
  39. package/src/types/api/enums.ts +5 -0
  40. package/src/types/api/index.ts +34 -0
  41. package/src/types/index.ts +3 -0
  42. package/src/types/misc/index.ts +10 -0
  43. package/src/types/misc/inertia.ts +9 -0
  44. package/src/types/models/auth/Group.ts +11 -0
  45. package/src/types/models/auth/Permission.ts +4 -0
  46. package/src/types/models/auth/Role.ts +7 -0
  47. package/src/types/models/auth/User.ts +13 -0
  48. package/src/types/models/auth/index.ts +4 -0
  49. package/src/types/models/claims/ClaimRequest.ts +278 -0
  50. package/src/types/models/claims/index.ts +1 -0
  51. package/src/types/models/index.ts +3 -0
  52. package/src/types/models/oracle/Risk.ts +7 -0
  53. package/src/types/models/oracle/TableData.ts +8 -0
  54. package/src/types/models/oracle/index.ts +2 -0
  55. package/src/types/models/quotes/QuoteRequest.ts +148 -0
  56. package/src/types/models/quotes/index.ts +1 -0
@@ -0,0 +1,267 @@
1
+ import { Condition, Frequency, VehicleType } from "../../api";
2
+ export declare type ClaimRequestStatus = 'new' | 'draft' | 'in-progress' | 'exported';
3
+ export interface ClaimRequest {
4
+ id: string;
5
+ reference: string;
6
+ 'status': ClaimRequestStatus;
7
+ 'submitted_at': string;
8
+ 'reminder_sent_at': string;
9
+ 'claim_number': string;
10
+ 'policyholder': string;
11
+ 'policy_number': string;
12
+ 'policy_cover_number': string;
13
+ 'policy_version_number': string;
14
+ 'policy_contact_name': string;
15
+ 'mobile': string;
16
+ 'email': string;
17
+ 'alternative_contact': string;
18
+ 'broker_firm': string;
19
+ 'broker_name': string;
20
+ 'address': string;
21
+ 'terms_accepted': boolean;
22
+ }
23
+ export interface DamageClaimRequest extends ClaimRequest {
24
+ 'vehicle_registration': string;
25
+ 'vehicle_vin': string;
26
+ 'vehicle_make': string;
27
+ 'vehicle_model': string;
28
+ 'vehicle_year': string | number;
29
+ 'vehicle_type': VehicleType;
30
+ 'finance_company': string;
31
+ 'finance_phone': string;
32
+ 'driver_name': string;
33
+ 'driver_dob': string;
34
+ 'driver_relationship': string;
35
+ 'driver_licence_number': string;
36
+ 'driver_licence_version': string;
37
+ 'driver_licence_issuer': string;
38
+ 'was_intoxicated': boolean;
39
+ 'intoxicated_details': string;
40
+ 'has_conviction': boolean;
41
+ 'conviction_details': string;
42
+ 'has_recent_claim': boolean;
43
+ 'incident_details': Incident[];
44
+ 'was_disqualified': boolean;
45
+ 'disqualified_details': string;
46
+ 'was_vehicle_used_without_consent': boolean;
47
+ 'vehicle_used_without_consent_details': string;
48
+ 'has_existing_vehicle_damage': boolean;
49
+ 'existing_vehicle_damage_details': string;
50
+ 'was_refused_insurance': boolean;
51
+ 'refused_insurance_details': string;
52
+ 'has_additional_information': boolean;
53
+ 'additional_information_details': string;
54
+ 'accident_location': string;
55
+ 'accident_suburb': string;
56
+ 'accident_happened_at': string;
57
+ 'accident_speed': string;
58
+ 'impact_speed': string;
59
+ 'road_surface': string;
60
+ 'weather_conditions': string;
61
+ 'had_passengers': boolean;
62
+ 'passenger_details': Passenger[];
63
+ 'has_witnesses': boolean;
64
+ 'witness_details': Witness[];
65
+ 'accident_description': string;
66
+ 'is_vehicle_drivable': boolean;
67
+ 'vehicle_drivable_details': string;
68
+ 'was_warning_given': boolean;
69
+ 'warning_given_details': string;
70
+ 'was_third_party_responsible': boolean;
71
+ 'third_party_responsible_details': string;
72
+ 'was_third_party_involved': boolean;
73
+ 'third_party_vehicle_registration': string;
74
+ 'third_party_vehicle_owner': string;
75
+ 'third_party_vehicle_make': string;
76
+ 'third_party_vehicle_model': string;
77
+ 'third_party_vehicle_driver_name': string;
78
+ 'third_party_vehicle_driver_mobile': string;
79
+ 'third_party_vehicle_driver_phone': string;
80
+ 'third_party_vehicle_driver_address': string;
81
+ 'third_party_vehicle_insurance_company': string;
82
+ 'third_party_vehicle_damage': string;
83
+ 'third_party_details_provided': string;
84
+ 'were_police_notified': boolean;
85
+ 'did_police_attend': boolean;
86
+ 'police_officer_name': string;
87
+ 'police_officer_email': string;
88
+ 'police_reference': string;
89
+ 'police_station_address': string;
90
+ 'police_did_test': boolean;
91
+ 'police_issued_notice': boolean;
92
+ 'repairer_name': string;
93
+ 'repairer_phone': string;
94
+ 'repairer_email': string;
95
+ 'is_claiming_protective_gear': boolean;
96
+ 'is_protective_gear_insured_elsewhere': boolean;
97
+ 'protective_gear_details': ClaimItem[];
98
+ 'is_claiming_contents': boolean;
99
+ 'is_contents_insured_elsewhere': boolean;
100
+ 'contents_details': ClaimItem[];
101
+ }
102
+ export interface Incident {
103
+ 'year': string;
104
+ 'month': string;
105
+ 'description': string;
106
+ }
107
+ export interface Passenger {
108
+ 'name': string;
109
+ 'phone'?: string;
110
+ 'email'?: string;
111
+ 'address'?: string;
112
+ }
113
+ export interface Witness {
114
+ 'name': string;
115
+ 'phone'?: string;
116
+ 'email'?: string;
117
+ 'address'?: string;
118
+ }
119
+ export interface ClaimItem {
120
+ 'description': string;
121
+ 'purchased_from'?: string;
122
+ 'age'?: string;
123
+ 'purchase_price'?: string;
124
+ 'replacement_cost'?: string;
125
+ }
126
+ export interface GlassClaimRequest extends ClaimRequest {
127
+ 'vehicle_registration': string;
128
+ 'vehicle_vin': string;
129
+ 'vehicle_make': string;
130
+ 'vehicle_model': string;
131
+ 'vehicle_year': string | number;
132
+ 'accident_location': string;
133
+ 'accident_happened_at': string;
134
+ 'accident_description': string;
135
+ 'repairer_name': string;
136
+ 'repairer_phone': string;
137
+ 'repairer_email': string;
138
+ }
139
+ export interface TheftClaimRequest extends ClaimRequest {
140
+ 'vehicle_registration': string;
141
+ 'vehicle_vin': string;
142
+ 'vehicle_make': string;
143
+ 'vehicle_model': string;
144
+ 'vehicle_year': string | number;
145
+ 'vehicle_type': VehicleType;
146
+ 'finance_company': string;
147
+ 'finance_phone': string;
148
+ 'is_leased': boolean;
149
+ 'lease_name': string;
150
+ 'lease_address': string;
151
+ 'lease_phone': string;
152
+ 'lease_number': string;
153
+ 'lease_payment_amount': string | number;
154
+ 'lease_payment_frequency': Frequency;
155
+ 'has_conviction': boolean;
156
+ 'conviction_details': string;
157
+ 'has_recent_claim': boolean;
158
+ 'incident_details': Incident[];
159
+ 'was_disqualified': boolean;
160
+ 'disqualified_details': string;
161
+ 'was_vehicle_used_without_consent': boolean;
162
+ 'vehicle_used_without_consent_details': string;
163
+ 'has_existing_vehicle_damage': boolean;
164
+ 'existing_vehicle_damage_details': string;
165
+ 'was_refused_insurance': boolean;
166
+ 'refused_insurance_details': string;
167
+ 'has_additional_information': boolean;
168
+ 'additional_information_details': string;
169
+ 'vehicle_purchased_on': string;
170
+ 'vehicle_purchased_from': string;
171
+ 'vehicle_purchased_price': string | number;
172
+ 'vehicle_value': number;
173
+ 'was_vehicle_for_sale': boolean;
174
+ 'vehicle_first_asking_price': string | number;
175
+ 'vehicle_last_asking_price': string | number;
176
+ 'vehicle_sale_duration': string;
177
+ 'vehicle_purchaser_name': string;
178
+ 'vehicle_purchaser_address': string;
179
+ 'vehicle_purchaser_phone': string;
180
+ 'vehicle_hp_cc_rating': string;
181
+ 'vehicle_transmission': string;
182
+ 'vehicle_engine_number': string;
183
+ 'vehicle_has_air_conditioning': boolean;
184
+ 'vehicle_has_cng': boolean;
185
+ 'vehicle_has_lpg': boolean;
186
+ 'vehicle_colour': string;
187
+ 'vehicle_colour_changes': string;
188
+ 'was_vehicle_repaired': boolean;
189
+ 'vehicle_repaired_damage_details': string;
190
+ 'vehicle_repairer': string;
191
+ 'vehicle_repaired_on': string;
192
+ 'was_vehicle_damaged': boolean;
193
+ 'vehicle_damage_details': string;
194
+ 'vehicle_tyre_condition_front_right': Condition;
195
+ 'vehicle_tyre_condition_front_left': Condition;
196
+ 'vehicle_tyre_condition_rear_right': Condition;
197
+ 'vehicle_tyre_condition_rear_left': Condition;
198
+ 'vehicle_tyre_condition_spare': string;
199
+ 'wheel_assembly_details': string;
200
+ 'is_vehicle_radio_original': boolean;
201
+ 'vehicle_radio_make': string;
202
+ 'vehicle_radio_location': string;
203
+ 'vehicle_radio_fixing': string;
204
+ 'vehicle_speaker_make': string;
205
+ 'accessory_details': Accessory[];
206
+ 'identifiable_contents_details': Contents[];
207
+ 'vehicle_serviced_by': string;
208
+ 'has_service_invoices': boolean;
209
+ 'vehicle_wof_issued_by': string;
210
+ 'vehicle_wof_issued_on': string;
211
+ 'vehicle_wof_expires_on': string;
212
+ 'vehicle_floor_type': string;
213
+ 'vehicle_interior_details': string;
214
+ 'vehicle_seatbelt_type': string;
215
+ 'vehicle_seatbelt_condition': Condition;
216
+ 'vehicle_engine_condition': Condition;
217
+ 'vehicle_gearbox_condition': Condition;
218
+ 'vehicle_transmission_condition': Condition;
219
+ 'vehicle_suspension_condition': Condition;
220
+ 'vehicle_steering_condition': Condition;
221
+ 'vehicle_seats_condition': Condition;
222
+ 'vehicle_trims_condition': Condition;
223
+ 'vehicle_body_condition': Condition;
224
+ 'vehicle_paint_condition': Condition;
225
+ 'vehicle_dashboard_condition': Condition;
226
+ 'vehicle_engine_oil_per_month': string;
227
+ 'vehicle_ran_well': boolean;
228
+ 'theft_details': string;
229
+ 'theft_happened_on': string;
230
+ 'theft_discovered_on': string;
231
+ 'vehicle_last_used_by': string;
232
+ 'were_windows_up': boolean;
233
+ 'windows_down_details': string;
234
+ 'were_doors_locked': boolean;
235
+ 'doors_unlocked_details': string;
236
+ 'has_theft_evidence': boolean;
237
+ 'theft_evidence_details': string;
238
+ 'has_steering_lock': boolean;
239
+ 'has_alarm': boolean;
240
+ 'was_alarm_active': boolean;
241
+ 'alarm_inactive_details': string;
242
+ 'was_boot_locked': boolean;
243
+ 'boot_unlocked_details': string;
244
+ 'keys_count': string;
245
+ 'key_holder_name': string;
246
+ 'key_holder_phone': string;
247
+ 'key_holder_address': string;
248
+ 'keys_location': string;
249
+ 'policyholder_whereabouts_details': string;
250
+ 'were_police_notified': boolean;
251
+ 'did_police_attend': boolean;
252
+ 'police_officer_name': string;
253
+ 'police_officer_email': string;
254
+ 'police_reference': string;
255
+ 'police_station_address': string;
256
+ 'is_claiming_contents': boolean;
257
+ 'is_contents_insured_elsewhere': boolean;
258
+ 'contents_details': ClaimItem[];
259
+ }
260
+ export interface Accessory {
261
+ 'description': string;
262
+ 'age': string;
263
+ 'condition': string;
264
+ }
265
+ export interface Contents {
266
+ 'description': string;
267
+ }
@@ -0,0 +1 @@
1
+ export * from './ClaimRequest';
@@ -0,0 +1,3 @@
1
+ export * from './auth';
2
+ export * from './claims';
3
+ export * from './oracle';
@@ -0,0 +1,7 @@
1
+ export interface RiskDisplayValue {
2
+ id: number;
3
+ created_at: string;
4
+ updated_at: string;
5
+ RI_CODE: string;
6
+ value: string;
7
+ }
@@ -0,0 +1,8 @@
1
+ export interface TableDataDisplayValue {
2
+ id: number;
3
+ created_at: string;
4
+ updated_at: string;
5
+ tbl_type: string;
6
+ tbl_code: string;
7
+ value: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Risk';
2
+ export * from './TableData';
@@ -0,0 +1,130 @@
1
+ export declare type QuoteRequestStatus = 'new' | 'draft' | 'in-progress' | 'with-customer' | 'sold' | 'bound' | 'customer-modified' | 'closed';
2
+ export declare type QuoteRequestSource = 'web' | 'phone' | 'show' | 'existing-customer' | 'mighway' | 'agent' | 'entry-form' | 'bularangi';
3
+ export declare type QuoteRequestAutomatch = 'QUOTE' | 'EMAIL' | 'REGISTRATION' | 'DUPLICATE' | null;
4
+ export interface QuoteRequestUser {
5
+ id: number;
6
+ name: string;
7
+ email: string;
8
+ }
9
+ export interface QuoteRequestUserGroup {
10
+ id: number;
11
+ name: string;
12
+ }
13
+ export interface QuoteRequest {
14
+ id: string;
15
+ reference: string;
16
+ client_number: string;
17
+ first_name: string;
18
+ last_name: string;
19
+ phone: string;
20
+ mobile: string;
21
+ email: string;
22
+ license: string;
23
+ license_other: string | null;
24
+ has_automatch: boolean;
25
+ automatch_by: QuoteRequestAutomatch;
26
+ automatch_client_id: string | null;
27
+ promo_code: string | null;
28
+ club_membership_number: string;
29
+ broker_fee: number;
30
+ length_of_insurance: string | null;
31
+ theme: string | null;
32
+ created_at: string;
33
+ updated_at: string;
34
+ dob: string;
35
+ sold_at: string | null;
36
+ sent_at: string | null;
37
+ pricing_expires_at: string | null;
38
+ follow_up_at: string | null;
39
+ status_id: QuoteRequestStatus;
40
+ source_id: QuoteRequestSource;
41
+ resubmit_id: QuoteRequest['id'] | null;
42
+ referrer_id: QuoteRequestReferrer['id'] | null;
43
+ referrer_category_id: QuoteRequestReferrerCategory['id'] | null;
44
+ staff_member_id: QuoteRequestUser['id'] | null;
45
+ agent_id: QuoteRequestUser['id'] | null;
46
+ agent_firm_id: QuoteRequestUserGroup['id'] | null;
47
+ broker_firm_id: QuoteRequestUserGroup['id'] | null;
48
+ broker_id: QuoteRequestUser['id'] | null;
49
+ club_id: Club['id'] | null;
50
+ lead_id: Lead['id'] | null;
51
+ status?: QuoteRequestStatus;
52
+ source?: QuoteRequestSource;
53
+ declaration?: QuoteRequestDeclaration;
54
+ street_address?: StreetAddress;
55
+ postal_address?: PostalAddress;
56
+ resubmit?: QuoteRequest;
57
+ referrer?: QuoteRequestReferrer;
58
+ referrer_category?: QuoteRequestReferrerCategory;
59
+ staff_member?: QuoteRequestUser;
60
+ agent?: QuoteRequestUser;
61
+ agent_firm?: QuoteRequestUserGroup;
62
+ broker?: QuoteRequestUser;
63
+ broker_firm?: QuoteRequestUserGroup;
64
+ club?: Club;
65
+ lead?: Lead;
66
+ }
67
+ export interface QuoteRequestReferrer {
68
+ id: number;
69
+ name: string;
70
+ category_id: QuoteRequestReferrerCategory['id'];
71
+ category?: QuoteRequestReferrerCategory;
72
+ }
73
+ export interface QuoteRequestReferrerCategory {
74
+ id: number;
75
+ name: string;
76
+ }
77
+ export interface Club {
78
+ id: number;
79
+ name: string;
80
+ }
81
+ export interface StreetAddress {
82
+ id: number;
83
+ address: string | null;
84
+ unit: string | null;
85
+ suburb: string | null;
86
+ city: string | null;
87
+ post_code: string | null;
88
+ }
89
+ export interface PostalAddress {
90
+ id: number;
91
+ postal_line_1: string | null;
92
+ postal_line_2: string | null;
93
+ postal_line_3: string | null;
94
+ postal_line_4: string | null;
95
+ }
96
+ export interface Lead {
97
+ id: number;
98
+ first_name: string;
99
+ last_name: string;
100
+ email: string;
101
+ mobile: string;
102
+ status: string;
103
+ source: string;
104
+ postal_address_id: PostalAddress['id'];
105
+ current_insurer: string | null;
106
+ current_insurance_expires_at: string | null;
107
+ current_insurance_is_monthly: boolean;
108
+ vehicle_details: string | null;
109
+ notes: string | null;
110
+ import_data: string | null;
111
+ }
112
+ export interface QuoteRequestDeclaration {
113
+ id: number;
114
+ quote_request_id: QuoteRequest['id'];
115
+ had_incident: boolean;
116
+ has_demerit_points: boolean;
117
+ demerit_points: string | null;
118
+ has_lost_license: boolean;
119
+ lost_license_details: string | null;
120
+ was_refused_insurance: boolean;
121
+ refused_insurance_details: string | null;
122
+ has_criminal_conviction: boolean;
123
+ criminal_conviction_details: string | null;
124
+ has_vehicle_modifications: boolean;
125
+ vehicle_modifications_details: string | null;
126
+ has_previous_insurer: boolean;
127
+ previous_insurer_details: string | null;
128
+ previous_insurer_expires_at: string | null;
129
+ additional_details: string | null;
130
+ }
@@ -0,0 +1 @@
1
+ export * from './QuoteRequest';
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@star-insure/sdk",
3
+ "description": "The SDK for Star Insure client apps with shared helper functions and TypeScript definitions.",
4
+ "author": "alexclark_nz",
5
+ "version": "0.1.0",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/star-insure/sdk"
10
+ },
11
+ "main": "dist/index.js",
12
+ "typings": "dist/index.d.ts",
13
+ "files": [
14
+ "dist",
15
+ "src"
16
+ ],
17
+ "engines": {
18
+ "node": ">=10"
19
+ },
20
+ "scripts": {
21
+ "dev": "tsdx watch",
22
+ "start": "tsdx watch",
23
+ "build": "tsdx build",
24
+ "test": "tsdx test",
25
+ "lint": "tsdx lint",
26
+ "prepare": "tsdx build",
27
+ "size": "size-limit",
28
+ "analyze": "size-limit --why"
29
+ },
30
+ "husky": {
31
+ "hooks": {
32
+ "pre-commit": "tsdx lint"
33
+ }
34
+ },
35
+ "prettier": {
36
+ "printWidth": 80,
37
+ "semi": true,
38
+ "singleQuote": true,
39
+ "trailingComma": "es5"
40
+ },
41
+ "module": "dist/starinsure-sdk.esm.js",
42
+ "size-limit": [
43
+ {
44
+ "path": "dist/starinsure-sdk.cjs.production.min.js",
45
+ "limit": "10 KB"
46
+ },
47
+ {
48
+ "path": "dist/starinsure-sdk.esm.js",
49
+ "limit": "10 KB"
50
+ }
51
+ ],
52
+ "devDependencies": {
53
+ "@size-limit/preset-small-lib": "^7.0.8",
54
+ "husky": "^8.0.1",
55
+ "np": "^7.6.1",
56
+ "size-limit": "^7.0.8",
57
+ "tsdx": "^0.14.1",
58
+ "tslib": "^2.4.0",
59
+ "typescript": "^3.9.10"
60
+ },
61
+ "dependencies": {
62
+ "@inertiajs/inertia": "^0.11.0",
63
+ "date-fns": "^2.28.0"
64
+ }
65
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './lib';
@@ -0,0 +1,15 @@
1
+ import { format } from "date-fns";
2
+
3
+ /**
4
+ * Formats a date like "Jan 1, 2022"
5
+ */
6
+ export function formatDateNice(date: string) {
7
+ return format(new Date(date), "MMM d, yyyy");
8
+ }
9
+
10
+ /**
11
+ * Formats a date like "01/01/2022 9:50AM"
12
+ */
13
+ export function formatDateForTable(date: string) {
14
+ return format(new Date(date), 'dd/MM/yyyy h:mma');
15
+ }
@@ -0,0 +1,2 @@
1
+ export * from './dates';
2
+ export * from './money';
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Safely rounds a number
3
+ */
4
+ export function round(value: number): number {
5
+ return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2)
6
+ }
7
+
8
+ /**
9
+ * Gets the GST value from a number
10
+ */
11
+ export function getGst(value: number): number {
12
+ return round(value * 3 / 23);
13
+ }
14
+
15
+ /**
16
+ * Adds GST to a number
17
+ */
18
+ export function addGst(value: number): number {
19
+ return round(value * 1.15);
20
+ }
21
+
22
+ /**
23
+ * Subtracts GST from a number
24
+ */
25
+ export function subtractGst(value: number): number {
26
+ return round(value - getGst(value));
27
+ }
28
+
29
+ /**
30
+ * Calculates the various GST values on a figure
31
+ */
32
+ export function gstCalc(input: number|string): {
33
+ gst: number,
34
+ amountInclusive: number,
35
+ amountExclusive: number
36
+ } {
37
+ let value = input;
38
+
39
+ if (typeof value === 'string') {
40
+ value = parseFloat(value.replace(/[^0-9.]/g, ''));
41
+ }
42
+
43
+ value = round(value);
44
+
45
+ return {
46
+ gst: getGst(value),
47
+ amountInclusive: addGst(value),
48
+ amountExclusive: subtractGst(value)
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Formats a value nicely
54
+ */
55
+ export function formatMoney(value: string|number, decimals: number = 2): string {
56
+ let toFormat = value;
57
+ if (typeof value === 'string') {
58
+ toFormat = value.replace(/[^\d.-]/g, '')
59
+ }
60
+
61
+ return Number(toFormat).toLocaleString('en', {
62
+ minimumFractionDigits: decimals,
63
+ maximumFractionDigits: decimals,
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Turns a formatted value in to a float
69
+ */
70
+ export function formatNumber(value: string): number {
71
+ return parseFloat(value.replace(/[^0-9.]/g, ''));
72
+ }
@@ -0,0 +1,10 @@
1
+ import { User, Group } from "../models";
2
+
3
+ export type Audience = 'administrator' | 'staff' | 'broker' | 'agent';
4
+
5
+ export interface AuthContext {
6
+ user?: User;
7
+ audience?: Audience;
8
+ group?: Group;
9
+ permissions: string[];
10
+ }
@@ -0,0 +1,5 @@
1
+ export type VehicleType = 'car' | 'motorcycle' | 'motorhome';
2
+
3
+ export type Frequency = 'daily' | 'weekly' | 'fortnightly' | 'monthly' | 'quarterly' | 'annually';
4
+
5
+ export type Condition = 'poor' | 'fair' | 'good';
@@ -0,0 +1,34 @@
1
+ export * from './auth';
2
+ export * from './enums';
3
+
4
+ export interface ApiResponse<T = any> {
5
+ data: T;
6
+ meta: Meta;
7
+ links: Links;
8
+ status: number;
9
+ ok: boolean;
10
+ }
11
+
12
+ export interface Meta {
13
+ current_page: number;
14
+ from: number;
15
+ last_page: number;
16
+ links: PaginationLink[];
17
+ path: string;
18
+ per_page: number;
19
+ to: number;
20
+ total: number;
21
+ }
22
+
23
+ export interface Links {
24
+ first: string;
25
+ last: string;
26
+ prev: string | null;
27
+ next: string | null;
28
+ }
29
+
30
+ export interface PaginationLink {
31
+ url: string | null;
32
+ label: string;
33
+ active: boolean;
34
+ }
@@ -0,0 +1,3 @@
1
+ export * from './models';
2
+ export * from './api';
3
+ export * from './misc';
@@ -0,0 +1,10 @@
1
+ export * from './inertia';
2
+
3
+ export type FormStatus = 'idle' | 'processing' | 'success' | 'error';
4
+
5
+ export interface Toast {
6
+ _id?: string;
7
+ message: string;
8
+ status?: 'success' | 'error' | 'default' | 'warning';
9
+ timeout?: number;
10
+ }
@@ -0,0 +1,9 @@
1
+ import type { ErrorBag, Errors, Page, PageProps as PagePropsInterface } from "@inertiajs/inertia";
2
+ import { AuthContext } from '../..';
3
+
4
+ export interface PageProps extends Page<PagePropsInterface> {
5
+ props: {
6
+ auth: AuthContext;
7
+ errors: Errors & ErrorBag;
8
+ }
9
+ }
@@ -0,0 +1,11 @@
1
+ import { Role, Permission, User } from ".";
2
+
3
+ export interface Group {
4
+ id: number;
5
+ name: string;
6
+ code: string;
7
+ 'x_code': string;
8
+ role?: Role;
9
+ permissions?: Permission[];
10
+ users?: User[];
11
+ }