-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathPolicy.ts
2046 lines (1525 loc) · 60.8 KB
/
Policy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import type {CONST as COMMON_CONST} from 'expensify-common';
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type {Country} from '@src/CONST';
import type * as OnyxTypes from '.';
import type * as OnyxCommon from './OnyxCommon';
import type {WorkspaceTravelSettings} from './TravelSettings';
/** Distance units */
type Unit = 'mi' | 'km';
/** Tax rate attributes of the policy distance rate */
type TaxRateAttributes = {
/** Percentage of the tax that can be reclaimable */
taxClaimablePercentage?: number;
/** External ID associated to this tax rate */
taxRateExternalID?: string;
};
/** Model of policy subrate */
type Subrate = {
/** Generated ID to identify the subrate */
id: string;
/** Name of the subrate */
name: string;
/** Amount to be reimbursed per unit */
rate: number;
};
/** Model of policy rate */
type Rate = OnyxCommon.OnyxValueWithOfflineFeedback<
{
/** Name of the rate */
name?: string;
/** Amount to be reimbursed per unit */
rate?: number;
/** Currency used to pay the rate */
currency?: string;
/** Generated ID to identify the rate */
customUnitRateID: string;
/** Whether this rate is currently enabled */
enabled?: boolean;
/** Error messages to show in UI */
errors?: OnyxCommon.Errors;
/** Form fields that triggered the errors */
errorFields?: OnyxCommon.ErrorFields;
/** Tax rate attributes of the policy */
attributes?: TaxRateAttributes;
/** Subrates of the given rate */
subRates?: Subrate[];
},
keyof TaxRateAttributes
>;
/** Custom unit attributes */
type Attributes = {
/** Distance unit name */
unit: Unit;
/** Whether the tax tracking is enabled or not */
taxEnabled?: boolean;
};
/** Policy custom unit */
type CustomUnit = OnyxCommon.OnyxValueWithOfflineFeedback<
{
/** Custom unit name */
name: string;
/** ID that identifies this custom unit */
customUnitID: string;
/** Contains custom attributes like unit, for this custom unit */
attributes?: Attributes;
/** Distance rates using this custom unit */
rates: Record<string, Rate>;
/** The default category in which this custom unit is used */
defaultCategory?: string;
/** Whether this custom unit is enabled */
enabled?: boolean;
/** Error messages to show in UI */
errors?: OnyxCommon.Errors;
/** Form fields that triggered errors */
errorFields?: OnyxCommon.ErrorFields;
},
keyof Attributes
>;
/** Policy company address data */
type CompanyAddress = {
/** Street address */
addressStreet: string;
/** City */
city: string;
/** State */
state: string;
/** Zip post code */
zipCode: string;
/** Country code */
country: Country | '';
};
/** Policy disabled fields */
type DisabledFields = {
/** Whether the default billable field is disabled */
defaultBillable?: boolean;
/** Whether the reimbursable field is disabled */
reimbursable?: boolean;
};
/** Policy tax rate */
type TaxRate = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Name of the tax rate. */
name: string;
/** The value of the tax rate. */
value: string;
/** The code associated with the tax rate. If a tax is created in old dot, code field is undefined */
code?: string;
/** This contains the tax name and tax value as one name */
modifiedName?: string;
/** Indicates if the tax rate is disabled. */
isDisabled?: boolean;
/** Indicates if the tax rate is selected. */
isSelected?: boolean;
/** The old tax code of the tax rate when we edit the tax code */
previousTaxCode?: string;
/** An error message to display to the user */
errors?: OnyxCommon.Errors;
/** An error object keyed by field name containing errors keyed by microtime */
errorFields?: OnyxCommon.ErrorFields;
}>;
/** Record of policy tax rates, indexed by id_{taxRateName} where taxRateName is the name of the tax rate in UPPER_SNAKE_CASE */
type TaxRates = Record<string, TaxRate>;
/** Policy tax rates with default tax rate */
type TaxRatesWithDefault = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Name of the tax */
name: string;
/** Default policy tax code */
defaultExternalID: string;
/** Default value of taxes */
defaultValue: string;
/** Default foreign policy tax code */
foreignTaxDefault: string;
/** List of tax names and values */
taxes: TaxRates;
/** An error message to display to the user */
errors?: OnyxCommon.Errors;
/** Error objects keyed by field name containing errors keyed by microtime */
errorFields?: OnyxCommon.ErrorFields;
}>;
/** Connection sync source values */
type JobSourceValues = 'DIRECT' | 'EXPENSIFYWEB' | 'EXPENSIFYAPI' | 'NEWEXPENSIFY' | 'AUTOSYNC' | 'AUTOAPPROVE';
/** Connection last synchronization state */
type ConnectionLastSync = {
/** Date when the connection's last successful sync occurred */
successfulDate?: string;
/** Date when the connection's last failed sync occurred */
errorDate?: string;
/** Error message when the connection's last sync failed */
errorMessage?: string;
/** If the connection's last sync failed due to authentication error */
isAuthenticationError: boolean;
/** Whether the connection's last sync was successful */
isSuccessful: boolean;
/** Where did the connection's last sync job come from */
source: JobSourceValues;
/**
* Sometimes we'll have a connection that is not connected, but the connection object is still present, so we can
* show an error message
*/
isConnected?: boolean;
};
/**
* Model of QBO credentials data.
*/
type QBOCredentials = {
/**
* The company ID that's connected from QBO.
*/
companyID: string;
/**
* The company name that's connected from QBO.
*/
companyName: string;
/**
* The current scope of QBO connection.
*/
scope: string;
};
/** Financial account (bank account, debit card, etc) */
type Account = {
/** GL code assigned to the financial account */
glCode?: string;
/** Name of the financial account */
name: string;
/** Currency of the financial account */
currency: string;
/** ID assigned to the financial account */
id: string;
};
/**
* Model of QuickBooks Online employee data
*
* TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type Employee = {
/** ID assigned to the employee */
id: string;
/** Employee's first name */
firstName?: string;
/** Employee's last name */
lastName?: string;
/** Employee's display name */
name: string;
/** Employee's e-mail */
email: string;
};
/**
* Model of QuickBooks Online vendor data
*
* TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type Vendor = {
/** ID assigned to the vendor */
id: string;
/** Vendor's name */
name: string;
/** Vendor's currency */
currency: string;
/** Vendor's e-mail */
email: string;
};
/**
* Model of QuickBooks Online tax code data
*
* TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type TaxCode = {
/** TODO: Will be handled in another issue */
totalTaxRateVal: string;
/** TODO: Will be handled in another issue */
simpleName: string;
/** TODO: Will be handled in another issue */
taxCodeRef: string;
/** TODO: Will be handled in another issue */
taxRateRefs: Record<string, string>;
/** TODO: Will be handled in another issue */
/** Name of the tax code */
name: string;
};
/**
* Data imported from QuickBooks Online.
*
* TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type QBOConnectionData = {
/** Country code */
country: ValueOf<typeof CONST.COUNTRY>;
/** TODO: Will be handled in another issue */
edition: string;
/** TODO: Will be handled in another issue */
homeCurrency: string;
/** TODO: Will be handled in another issue */
isMultiCurrencyEnabled: boolean;
/** Collection of journal entry accounts */
journalEntryAccounts: Account[];
/** Collection of bank accounts */
bankAccounts: Account[];
/** Collection of credit cards */
creditCards: Account[];
/** Collection of export destination accounts */
accountsReceivable: Account[];
/** TODO: Will be handled in another issue */
accountPayable: Account[];
/** TODO: Will be handled in another issue */
otherCurrentAssetAccounts: Account[];
/** TODO: Will be handled in another issue */
taxCodes: TaxCode[];
/** TODO: Will be handled in another issue */
employees: Employee[];
/** Collections of vendors */
vendors: Vendor[];
};
/** Sync entity names */
type IntegrationEntityMap = ValueOf<typeof CONST.INTEGRATION_ENTITY_MAP_TYPES>;
/**
* Non reimbursable account types exported from QuickBooks Online
*
* TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type QBONonReimbursableExportAccountType = ValueOf<typeof CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE>;
/**
* Reimbursable account types exported from QuickBooks Online
*
* TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type QBOReimbursableExportAccountType = ValueOf<typeof CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE>;
/**
* User configuration for the QuickBooks Online accounting integration.
*
* TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** TODO: Will be handled in another issue */
realmId: string;
/** TODO: Will be handled in another issue */
companyName: string;
/** Configuration of automatic synchronization from QuickBooks Online to the app */
autoSync: {
/** TODO: Will be handled in another issue */
jobID: string;
/** Whether changes made in QuickBooks Online should be reflected into the app automatically */
enabled: boolean;
};
/** Whether employees can be invited */
syncPeople: boolean;
/** TODO: Will be handled in another issue */
syncItems: boolean;
/** TODO: Will be handled in another issue */
markChecksToBePrinted: boolean;
/** Defines how reimbursable expenses are exported */
reimbursableExpensesExportDestination: QBOReimbursableExportAccountType;
/** Defines how non reimbursable expenses are exported */
nonReimbursableExpensesExportDestination: QBONonReimbursableExportAccountType;
/** Default vendor of non reimbursable bill */
nonReimbursableBillDefaultVendor: string;
/** ID of the invoice collection account */
collectionAccountID?: string;
/** ID of the bill payment account */
reimbursementAccountID?: string;
/** Account that receives the reimbursable expenses */
reimbursableExpensesAccount?: Account;
/** Account that receives the non reimbursable expenses */
nonReimbursableExpensesAccount?: Account;
/** Account that receives the exported invoices */
receivableAccount?: Account;
/**
* Whether a default vendor will be created and applied to all credit card
* transactions upon import
*/
autoCreateVendor: boolean;
/** TODO: Will be handled in another issue */
hasChosenAutoSyncOption: boolean;
/** Whether Quickbooks Online classes should be imported */
syncClasses: IntegrationEntityMap;
/** Whether Quickbooks Online customers should be imported */
syncCustomers: IntegrationEntityMap;
/** Whether Quickbooks Online locations should be imported */
syncLocations: IntegrationEntityMap;
/** TODO: Will be handled in another issue */
lastConfigurationTime: number;
/** Whether the taxes should be synchronized */
syncTax: boolean;
/** Whether new categories are enabled in chart of accounts */
enableNewCategories: boolean;
/** TODO: Will be handled in another issue */
errors?: OnyxCommon.Errors;
/** TODO: Will be handled in another issue */
exportDate: ValueOf<typeof CONST.QUICKBOOKS_EXPORT_DATE>;
/** Configuration of the export */
export: {
/** E-mail of the exporter */
exporter: string;
};
/** Collections of form field errors */
errorFields?: OnyxCommon.ErrorFields;
/** Credentials of the current QBO connection */
credentials: QBOCredentials;
}>;
/**
* Reimbursable account types exported from QuickBooks Desktop
*/
type QBDReimbursableExportAccountType = ValueOf<typeof CONST.QUICKBOOKS_DESKTOP_REIMBURSABLE_ACCOUNT_TYPE>;
/**
* Non reimbursable account types exported from QuickBooks Desktop
*/
type QBDNonReimbursableExportAccountType = ValueOf<typeof CONST.QUICKBOOKS_DESKTOP_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE>;
/** Xero bill status values
*
* TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type BillStatusValues = 'DRAFT' | 'AWT_APPROVAL' | 'AWT_PAYMENT';
/** Xero expense status values
*
* TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type ExpenseTypesValues = 'BILL' | 'BANK_TRANSACTION' | 'SALES_INVOICE' | 'NOTHING';
/** Xero bill date values
*
* TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type BillDateValues = 'REPORT_SUBMITTED' | 'REPORT_EXPORTED' | 'LAST_EXPENSE';
/**
* Model of an organization in Xero
*
* TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type Tenant = {
/** ID of the organization */
id: string;
/** Name of the organization */
name: string;
/** TODO: Will be handled in another issue */
value: string;
};
/** TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */
type XeroTrackingCategory = {
/** TODO: Will be handled in another issue */
id: string;
/** TODO: Will be handled in another issue */
name: string;
};
/**
* Data imported from Xero
*
* TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type XeroConnectionData = {
/** Collection of bank accounts */
bankAccounts: Account[];
/** TODO: Will be handled in another issue */
countryCode: string;
/** TODO: Will be handled in another issue */
organisationID: string;
/** TODO: Will be handled in another issue */
revenueAccounts: Array<{
/** TODO: Will be handled in another issue */
id: string;
/** TODO: Will be handled in another issue */
name: string;
}>;
/** Collection of organizations */
tenants: Tenant[];
/** TODO: Will be handled in another issue */
trackingCategories: XeroTrackingCategory[];
};
/** TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */
type XeroMappingType = {
/** TODO: Will be handled in another issue */
customer: string;
} & {
[key in `trackingCategory_${string}`]: string;
};
/** Xero auto synchronization configs */
type XeroAutoSyncConfig = {
/** Whether data should be automatically synched between the app and Xero */
enabled: boolean;
/** TODO: Will be handled in another issue */
jobID: string;
};
/** Xero export configs */
type XeroExportConfig = {
/** Current bill status */
billDate: BillDateValues;
/** TODO: Will be handled in another issue */
billStatus: {
/** Current status of the purchase bill */
purchase: BillStatusValues;
/** Current status of the sales bill */
sales: BillStatusValues;
};
/** TODO: Will be handled in another issue */
billable: ExpenseTypesValues;
/** The e-mail of the exporter */
exporter: string;
/** TODO: Will be handled in another issue */
nonReimbursable: ExpenseTypesValues;
/** TODO: Will be handled in another issue */
nonReimbursableAccount: string;
/** TODO: Will be handled in another issue */
reimbursable: ExpenseTypesValues;
};
/** TODO: Will be handled in another issue */
type XeroSyncConfig = {
/** TODO: Will be handled in another issue */
hasChosenAutoSyncOption: boolean;
/** TODO: Will be handled in another issue */
hasChosenSyncReimbursedReportsOption: boolean;
/** ID of the bank account for Xero invoice collections */
invoiceCollectionsAccountID: string;
/** ID of the bank account for Xero bill payment account */
reimbursementAccountID: string;
/** Whether the reimbursed reports should be synched */
syncReimbursedReports: boolean;
};
/**
* User configuration for the Xero accounting integration.
*
* TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033)
*/
type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<
{
/** Xero auto synchronization configs */
autoSync: XeroAutoSyncConfig;
/** TODO: Will be handled in another issue */
enableNewCategories: boolean;
/** Xero export configs */
export: XeroExportConfig;
/** Whether customers should be imported from Xero */
importCustomers: boolean;
/** Whether tax rates should be imported from Xero */
importTaxRates: boolean;
/** Whether tracking categories should be imported from Xero */
importTrackingCategories: boolean;
/** TODO: Will be handled in another issue */
isConfigured: boolean;
/** TODO: Will be handled in another issue */
mappings: XeroMappingType;
/** TODO: Will be handled in another issue */
sync: XeroSyncConfig;
/** ID of Xero organization */
tenantID: string;
/** TODO: Will be handled in another issue */
errors?: OnyxCommon.Errors;
/** Collection of form field errors */
errorFields?: OnyxCommon.ErrorFields;
},
keyof XeroAutoSyncConfig | keyof XeroExportConfig | keyof XeroSyncConfig | keyof XeroMappingType
>;
/** Data stored about subsidiaries from NetSuite */
type NetSuiteSubsidiary = {
/** ID of the subsidiary */
internalID: string;
/** Country where subsidiary is present */
country: string;
/** Whether the subsidiary is an elimination subsidiary (a special type used to handle intercompany transaction) */
isElimination: boolean;
/** Name of the subsidiary */
name: string;
};
/** NetSuite bank account type values imported by Expensify */
type AccountTypeValues = '_accountsPayable' | '_otherCurrentLiability' | '_creditCard' | '_bank' | '_otherCurrentAsset' | '_longTermLiability' | '_accountsReceivable' | '_expense';
/** NetSuite Financial account (bank account, debit card, etc) */
type NetSuiteAccount = {
/** GL code assigned to the financial account */
// eslint-disable-next-line @typescript-eslint/naming-convention
'GL Code'?: string;
/** Name of the account */
name: string;
/** ID assigned to the financial account in NetSuite */
id: string;
/** Type of the financial account */
type: AccountTypeValues;
};
/** NetSuite Tax account */
type NetSuiteTaxAccount = {
/** Name of the tax account */
name: string;
/** ID assigned to the tax account in NetSuite */
externalID: string;
/** Country of the tax account */
country: string;
};
/** NetSuite Vendor Model */
type NetSuiteVendor = {
/** ID of the vendor in NetSuite */
id: string;
/** Name of the vendor */
name: string;
/** E-mail of the vendor */
email: string;
};
/** NetSuite Invoice Item Model */
type InvoiceItem = {
/** ID of the invoice item in NetSuite */
id: string;
/** Name of the invoice item */
name: string;
};
/**
* NetSuite Custom List data modal
*/
type NetSuiteCustomListSource = {
/** Internal ID of the custom list in NetSuite */
id: string;
/** Name of the custom list */
name: string;
};
/** Data from the NetSuite accounting integration. */
type NetSuiteConnectionData = {
/** Collection of the custom lists in the NetSuite account */
customLists: NetSuiteCustomListSource[];
/** Collection of the subsidiaries present in the NetSuite account */
subsidiaryList: NetSuiteSubsidiary[];
/** Collection of receivable accounts */
receivableList?: NetSuiteAccount[];
/** Collection of vendors */
vendors?: NetSuiteVendor[];
/** Collection of invoice items */
items?: InvoiceItem[];
/** Collection of the payable accounts */
payableList: NetSuiteAccount[];
/** Collection of tax accounts */
taxAccountsList?: NetSuiteTaxAccount[];
};
/** NetSuite mapping values */
type NetSuiteMappingValues = 'NETSUITE_DEFAULT' | 'REPORT_FIELD' | 'TAG';
/** NetSuite invoice item preference values */
type NetSuiteInvoiceItemPreferenceValues = 'create' | 'select';
/** NetSuite export destination values */
type NetSuiteExportDestinationValues = 'EXPENSE_REPORT' | 'VENDOR_BILL' | 'JOURNAL_ENTRY';
/** NetSuite expense report approval level values */
type NetSuiteExpenseReportApprovalLevels = 'REPORTS_APPROVED_NONE' | 'REPORTS_SUPERVISOR_APPROVED' | 'REPORTS_ACCOUNTING_APPROVED' | 'REPORTS_APPROVED_BOTH';
/** NetSuite vendor bills approval level values */
type NetSuiteVendorBillApprovalLevels = 'VENDOR_BILLS_APPROVED_NONE' | 'VENDOR_BILLS_APPROVAL_PENDING' | 'VENDOR_BILLS_APPROVED';
/** NetSuite journal approval level values */
type NetSuiteJournalApprovalLevels = 'JOURNALS_APPROVED_NONE' | 'JOURNALS_APPROVAL_PENDING' | 'JOURNALS_APPROVED';
/** NetSuite export date values */
type NetSuiteExportDateOptions = 'SUBMITTED' | 'EXPORTED' | 'LAST_EXPENSE';
/** NetSuite journal posting preference values */
type NetSuiteJournalPostingPreferences = 'JOURNALS_POSTING_TOTAL_LINE' | 'JOURNALS_POSTING_INDIVIDUAL_LINE';
/** NetSuite custom segment/records and custom lists mapping values */
type NetSuiteCustomFieldMapping = 'TAG' | 'REPORT_FIELD' | '';
/** The custom form selection options for transactions (any one will be used at most) */
type NetSuiteCustomFormIDOptions = {
/** If the option is expense report */
expenseReport?: string;
/** If the option is vendor bill */
vendorBill?: string;
/** If the option is journal entry */
journalEntry?: string;
};
/** NetSuite custom list */
type NetSuiteCustomList = {
/** The name of the custom list in NetSuite */
listName: string;
/** The internalID of the custom list in NetSuite */
internalID: string;
/** The ID of the transaction form field we'll code the list option onto during Export */
transactionFieldID: string;
/** Whether we import this list as a report field or tag */
mapping: NetSuiteCustomFieldMapping;
};
/** NetSuite custom segments/records */
type NetSuiteCustomSegment = {
/** The name of the custom segment */
segmentName: string;
/** The ID of the custom segment in NetSuite */
internalID: string;
/** The ID of the transaction form field we'll code this segment onto during Export */
scriptID: string;
/** Whether we import this segment as a report field or tag */
mapping: NetSuiteCustomFieldMapping;
};
/** The custom form ID object */
type NetSuiteCustomFormID = {
/** The custom form selections for reimbursable transactions */
reimbursable: NetSuiteCustomFormIDOptions;
/** The custom form selections for non-reimbursable transactions */
nonReimbursable: NetSuiteCustomFormIDOptions;
/** Whether we'll use the custom form selections upon export to NetSuite */
enabled: boolean;
};
/** Different NetSuite records that can be mapped to either Report Fields or Tags in Expensify */
type NetSuiteSyncOptionsMapping = {
/** A general type of classification category in NetSuite */
classes: NetSuiteMappingValues;
/** A type of classification category in NetSuite linked to projects */
jobs: NetSuiteMappingValues;
/** A type of classification category in NetSuite linked to locations */
locations: NetSuiteMappingValues;
/** A type of classification category in NetSuite linked to customers */
customers: NetSuiteMappingValues;
/** A type of classification category in NetSuite linked to departments within the company */
departments: NetSuiteMappingValues;
};
/** Configuration options pertaining to sync. This subset of configurations is a legacy object. New configurations should just go directly under the config */
type NetSuiteSyncOptions = {
/** Different NetSuite records that can be mapped to either Report Fields or Tags in Expensify */
mapping: NetSuiteSyncOptionsMapping;
/** Whether we want to import customers into NetSuite from across all subsidiaries */
crossSubsidiaryCustomers: boolean;
/** Whether we'll import employee supervisors and set them as managers in the Expensify approval workflow */
syncApprovalWorkflow: boolean;
/** Whether we import custom lists from NetSuite */
syncCustomLists?: boolean;
/** The approval level we set for an Expense Report record created in NetSuite */
exportReportsTo: NetSuiteExpenseReportApprovalLevels;
/** The approval level we set for a Vendor Bill record created in NetSuite */
exportVendorBillsTo: NetSuiteVendorBillApprovalLevels;
/** Whether or not we need to set the final approver in this policy via sync */
setFinalApprover: boolean;
/** Whether we sync report reimbursement status between Expensify and NetSuite */
syncReimbursedReports: boolean;
/** The relevant details of the custom segments we import into Expensify and code onto expenses */
customSegments?: NetSuiteCustomSegment[];
/** Whether to import Employees from NetSuite into Expensify */
syncPeople: boolean;
/** Whether to enable a new Expense Category into Expensify */
enableNewCategories?: boolean;
/** A now unused configuration saying whether a customer had toggled AutoSync yet. */
hasChosenAutoSyncOption: boolean;
/** The final approver to be set in the Expensify approval workflow */
finalApprover: string;
/** Whether to import tax groups from NetSuite */
syncTax?: boolean;
/** Whether to import custom segments from NetSuite */
syncCustomSegments?: boolean;
/** The relevant details of the custom lists we import into Expensify and code onto expenses */
customLists?: NetSuiteCustomList[];
/** Whether we'll import Expense Categories into Expensify as categories */
syncCategories: boolean;
/** A now unused configuration saying whether a customer had toggled syncing reimbursement yet. */
hasChosenSyncReimbursedReportsOption: boolean;
/** The approval level we set for a Journal Entry record created in NetSuite */
exportJournalsTo: NetSuiteJournalApprovalLevels;
};
/** User configuration for the NetSuite accounting integration. */
type NetSuiteConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<
{
/** Invoice Item Preference */
invoiceItemPreference?: NetSuiteInvoiceItemPreferenceValues;
/** ID of the bank account for NetSuite invoice collections */
receivableAccount?: string;
/** ID of the bank account for NetSuite tax posting */
taxPostingAccount?: string;
/** Whether we should export to the most recent open period if the current one is closed */
exportToNextOpenPeriod: boolean;
/** Whether we will include the original foreign amount of a transaction to NetSuite */
allowForeignCurrency?: boolean;
/** Where to export reimbursable expenses */
reimbursableExpensesExportDestination: NetSuiteExportDestinationValues;
/** The sub-entity within the NetSuite account for which this policy is connected */
subsidiary: string;
/** Configuration options pertaining to sync. This subset of configurations is a legacy object. New configurations should just go directly under the config */
syncOptions: NetSuiteSyncOptions;
/** Whether to automatically create employees and vendors upon export in NetSuite if they don't exist */
autoCreateEntities: boolean;
/** The account to run auto export */
exporter: string;
/** The transaction date to set upon export */
exportDate?: NetSuiteExportDateOptions;
/** The type of transaction in NetSuite we export non-reimbursable transactions to */
nonreimbursableExpensesExportDestination: NetSuiteExportDestinationValues;
/** Credit account for reimbursable transactions */
reimbursablePayableAccount: string;
/** Whether we post Journals as individual separate entries or a single unified entry */
journalPostingPreference?: NetSuiteJournalPostingPreferences;
/** The Item record to associate with lines on an invoice created via Expensify */
invoiceItem?: string;
/** The internaID of the selected subsidiary in NetSuite */
subsidiaryID?: string;
/** The default vendor to use for Transactions in NetSuite */
defaultVendor?: string;
/** The provincial tax account for tax line items in NetSuite (only for Canadian Subsidiaries) */
provincialTaxPostingAccount?: string;
/** The account used for reimbursement in NetSuite */
reimbursementAccountID?: string;
/** The account used for approvals in NetSuite */
approvalAccount: string;
/** Credit account for Non-reimbursables (not applicable to expense report entry) */