From 9a5a5495363f314963e4d837c8b1d37fd2d49777 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Tue, 5 Mar 2024 16:26:11 -0800 Subject: [PATCH 01/16] feat: define types for connections property of Policy --- src/types/onyx/Policy.ts | 91 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 3 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index b005a9d2756f..7ca73eb79ea2 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; @@ -71,9 +72,93 @@ type TaxRatesWithDefault = { // These types are for the Integration connections for a policy (eg. Quickbooks, Xero, etc). // This data is not yet used in the codebase which is why it is given a very generic type, but the data is being put into Onyx for future use. // Once the data is being used, these types should be defined appropriately. -type ConnectionLastSync = Record; -type ConnectionData = Record; -type ConnectionConfig = Record; +type ConnectionLastSync = { + successfulDate?: string; + errorDate?: string; + isSuccessful: boolean; + source: 'DIRECT' | 'EXPENSIFYWEB' | 'EXPENSIFYAPI' | 'AUTOSYNC' | 'AUTOAPPROVE'; +}; + +type Account = { + glCode?: string; + name: string; + currency: string; + id: number; +}; + +type Employee = { + id: number; + firstName: string; + lastName: string; + name: string; + email: string; +}; + +type Vendor = { + id: number; + name: string; + currency: string; + email: string; +}; + +type ConnectionData = { + country: string; + edition: string; + homeCurrency: string; + isMultiCurrencyEnabled: boolean; + + journalEntryAccounts: Account[]; + bankAccounts: Account[]; + creditCards: Account[]; + accountsReceivable: Account[]; + accountsPayable: Account[]; + otherCurrentAssetAccounts: Account[]; + + taxCodes: string[]; + employees: Employee[]; + vendors: Vendor[]; +}; + +type IntegrationEntity = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD'; + +type ConnectionConfig = { + realmId: number; + credentials: { + access_token: string; + refresh_token: string; + expires: number; + companyID: number; + readlmId: number; + scope: string; + companyName: string; + token_type: string; + }; + companyName: string; + autoSync: { + jobID: number; + enabled: boolean; + }; + syncPeople: boolean; + syncItems: boolean; + markChecksToBePrinted: boolean; + reimbursableExpensesExportDestination: IntegrationEntity; + nonReimbursableExpensesExportDestination: IntegrationEntity; + + reimbursableExpensesAccount?: string; + nonReimbursableExpensesAccount?: string; + autoCreateVendor: boolean; + hasChosenAutoSyncOption: boolean; + syncClasses: IntegrationEntity; + syncCustomers: IntegrationEntity; + syncLocations: IntegrationEntity; + exportDate: string; + lastConfigurationTime: number; + syncTax: boolean; + enableNewCategories: boolean; + export: { + exporter: string; + }; +}; type Connection = { lastSync?: ConnectionLastSync; data: ConnectionData; From a586fed61826cdeb69e1644d3dd5f5a59a88def7 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Tue, 5 Mar 2024 16:32:39 -0800 Subject: [PATCH 02/16] define union of accounting software --- src/types/onyx/Policy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 7ca73eb79ea2..5f19d3f44d38 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -165,6 +165,8 @@ type Connection = { config: ConnectionConfig; }; +type AccountingSoftware = 'quickbooksOnline' | 'xero'; + type AutoReportingOffset = number | ValueOf; type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< @@ -310,7 +312,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< chatReportIDAnnounce?: number; /** All the integration connections attached to the policy */ - connections?: Record; + connections?: Record; /** Whether the Categories feature is enabled */ areCategoriesEnabled?: boolean; From 8f16c4e6480325cb7bbfda0c8ac3d5f868229312 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Wed, 6 Mar 2024 10:42:00 -0800 Subject: [PATCH 03/16] chore: remove outdated comments --- src/types/onyx/Policy.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 5f19d3f44d38..4625339f3aac 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -69,9 +69,6 @@ type TaxRatesWithDefault = { taxes: TaxRates; }; -// These types are for the Integration connections for a policy (eg. Quickbooks, Xero, etc). -// This data is not yet used in the codebase which is why it is given a very generic type, but the data is being put into Onyx for future use. -// Once the data is being used, these types should be defined appropriately. type ConnectionLastSync = { successfulDate?: string; errorDate?: string; From a0c7d1141f7320306ec46b4f327420cfadf948d2 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 7 Mar 2024 10:07:37 -0800 Subject: [PATCH 04/16] chore: rename a type name --- src/types/onyx/Policy.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 4625339f3aac..0c3d84c36538 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -116,7 +116,7 @@ type ConnectionData = { vendors: Vendor[]; }; -type IntegrationEntity = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD'; +type IntegrationEntityMap = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD'; type ConnectionConfig = { realmId: number; @@ -138,16 +138,16 @@ type ConnectionConfig = { syncPeople: boolean; syncItems: boolean; markChecksToBePrinted: boolean; - reimbursableExpensesExportDestination: IntegrationEntity; - nonReimbursableExpensesExportDestination: IntegrationEntity; + reimbursableExpensesExportDestination: IntegrationEntityMap; + nonReimbursableExpensesExportDestination: IntegrationEntityMap; reimbursableExpensesAccount?: string; nonReimbursableExpensesAccount?: string; autoCreateVendor: boolean; hasChosenAutoSyncOption: boolean; - syncClasses: IntegrationEntity; - syncCustomers: IntegrationEntity; - syncLocations: IntegrationEntity; + syncClasses: IntegrationEntityMap; + syncCustomers: IntegrationEntityMap; + syncLocations: IntegrationEntityMap; exportDate: string; lastConfigurationTime: number; syncTax: boolean; From 8d45c9ed3fdd6054dbc300180e9f24185385f6e6 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 7 Mar 2024 10:10:00 -0800 Subject: [PATCH 05/16] fix: make names optional --- src/types/onyx/Policy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 0c3d84c36538..96c87f2ca14d 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -85,8 +85,8 @@ type Account = { type Employee = { id: number; - firstName: string; - lastName: string; + firstName?: string; + lastName?: string; name: string; email: string; }; From d9d5b0959e5ae0b8393b43d698a3a2fe9899bcd4 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 7 Mar 2024 10:16:52 -0800 Subject: [PATCH 06/16] chore: use accounting-software-specific connection data type --- src/types/onyx/Policy.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 96c87f2ca14d..93f03362a795 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -98,7 +98,7 @@ type Vendor = { email: string; }; -type ConnectionData = { +type QuickBooksOnlineConnectionData = { country: string; edition: string; homeCurrency: string; @@ -156,13 +156,19 @@ type ConnectionConfig = { exporter: string; }; }; -type Connection = { +type Connection = { lastSync?: ConnectionLastSync; data: ConnectionData; config: ConnectionConfig; }; -type AccountingSoftware = 'quickbooksOnline' | 'xero'; +type Connections = { + quickbooksOnline: { + lastSync?: ConnectionLastSync; + data: Connection; + config: ConnectionConfig; + }; +}; type AutoReportingOffset = number | ValueOf; @@ -309,7 +315,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< chatReportIDAnnounce?: number; /** All the integration connections attached to the policy */ - connections?: Record; + connections?: Connections; /** Whether the Categories feature is enabled */ areCategoriesEnabled?: boolean; From c051c16191d9512d9a145d1cdc7536e700f900e0 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 7 Mar 2024 10:19:47 -0800 Subject: [PATCH 07/16] chore: define tax code type --- src/types/onyx/Policy.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 93f03362a795..9942b7638748 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -98,6 +98,14 @@ type Vendor = { email: string; }; +type TaxCode = { + totalTaxRateVal: string; + simpleName: string; + taxCodeRef: string; + taxRateRefs: Record; + name: string; +}; + type QuickBooksOnlineConnectionData = { country: string; edition: string; @@ -111,7 +119,7 @@ type QuickBooksOnlineConnectionData = { accountsPayable: Account[]; otherCurrentAssetAccounts: Account[]; - taxCodes: string[]; + taxCodes: TaxCode[]; employees: Employee[]; vendors: Vendor[]; }; From eb1f41191b2e49298b509a7f0b70e215b1dab651 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 7 Mar 2024 10:25:18 -0800 Subject: [PATCH 08/16] fix: change type for ids from number to string --- src/types/onyx/Policy.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 9942b7638748..27bc396720e2 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -80,11 +80,11 @@ type Account = { glCode?: string; name: string; currency: string; - id: number; + id: string; }; type Employee = { - id: number; + id: string; firstName?: string; lastName?: string; name: string; @@ -92,7 +92,7 @@ type Employee = { }; type Vendor = { - id: number; + id: string; name: string; currency: string; email: string; @@ -127,20 +127,20 @@ type QuickBooksOnlineConnectionData = { type IntegrationEntityMap = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD'; type ConnectionConfig = { - realmId: number; + realmId: string; credentials: { access_token: string; refresh_token: string; expires: number; - companyID: number; - readlmId: number; + companyID: string; + readlmId: string; scope: string; companyName: string; token_type: string; }; companyName: string; autoSync: { - jobID: number; + jobID: string; enabled: boolean; }; syncPeople: boolean; From a1d559c6a6117c5bafc922ec795bb5c89fce4693 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 8 Mar 2024 09:04:40 -0800 Subject: [PATCH 09/16] Update src/types/onyx/Policy.ts Co-authored-by: Francois Laithier --- src/types/onyx/Policy.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 27bc396720e2..18bfe4d4a5c4 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -171,11 +171,7 @@ type Connection = { }; type Connections = { - quickbooksOnline: { - lastSync?: ConnectionLastSync; - data: Connection; - config: ConnectionConfig; - }; + quickbooksOnline: Connection; }; type AutoReportingOffset = number | ValueOf; From 3b73bf4ad9a16c5e43b9c05a481107e4a3bd0acc Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 8 Mar 2024 09:08:31 -0800 Subject: [PATCH 10/16] fix: type Co-authored-by: Francois Laithier --- src/types/onyx/Policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 18bfe4d4a5c4..7d6314966e0d 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -133,7 +133,7 @@ type ConnectionConfig = { refresh_token: string; expires: number; companyID: string; - readlmId: string; + realmId: string; scope: string; companyName: string; token_type: string; From 90435855eb246f657f682622cd8e186a69595f28 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 8 Mar 2024 09:09:33 -0800 Subject: [PATCH 11/16] chore: remove credential property --- src/types/onyx/Policy.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 7d6314966e0d..f4e5cd0290e4 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -128,16 +128,6 @@ type IntegrationEntityMap = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD'; type ConnectionConfig = { realmId: string; - credentials: { - access_token: string; - refresh_token: string; - expires: number; - companyID: string; - realmId: string; - scope: string; - companyName: string; - token_type: string; - }; companyName: string; autoSync: { jobID: string; From 7268798ef017acfbed4066534d7e3b1d4c09ab11 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 8 Mar 2024 09:11:27 -0800 Subject: [PATCH 12/16] chore: make config type specific to QBO --- src/types/onyx/Policy.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index f4e5cd0290e4..93c76f98ef86 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -126,7 +126,7 @@ type QuickBooksOnlineConnectionData = { type IntegrationEntityMap = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD'; -type ConnectionConfig = { +type QBOConnectionConfig = { realmId: string; companyName: string; autoSync: { @@ -154,14 +154,14 @@ type ConnectionConfig = { exporter: string; }; }; -type Connection = { +type Connection = { lastSync?: ConnectionLastSync; data: ConnectionData; config: ConnectionConfig; }; type Connections = { - quickbooksOnline: Connection; + quickbooksOnline: Connection; }; type AutoReportingOffset = number | ValueOf; From 08553acb6d6b53658db93832a83d6cdb0088a082 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 8 Mar 2024 09:12:02 -0800 Subject: [PATCH 13/16] chore: shorten the type name --- src/types/onyx/Policy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 93c76f98ef86..3c2ab1b76af6 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -106,7 +106,7 @@ type TaxCode = { name: string; }; -type QuickBooksOnlineConnectionData = { +type QBOConnectionData = { country: string; edition: string; homeCurrency: string; @@ -161,7 +161,7 @@ type Connection = { }; type Connections = { - quickbooksOnline: Connection; + quickbooksOnline: Connection; }; type AutoReportingOffset = number | ValueOf; From 198c692de3be3f3e263da96b138314b168657244 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 8 Mar 2024 12:45:20 -0800 Subject: [PATCH 14/16] add comment for acronym Co-authored-by: Francois Laithier --- src/types/onyx/Policy.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 3c2ab1b76af6..d00576467126 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -126,6 +126,9 @@ type QBOConnectionData = { type IntegrationEntityMap = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD'; +/** + * User configuration for the QuickBooks Online accounting integration. + */ type QBOConnectionConfig = { realmId: string; companyName: string; From e8adbd6f89af285b377567507db879685e7a4833 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Mon, 11 Mar 2024 11:11:17 -0700 Subject: [PATCH 15/16] chore: delete unused ts error suppression comment --- src/types/onyx/Policy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index d00576467126..e2ecaaa14bb8 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; From 4fefa480621cc155b2b3b3d2a22410fdc79bb857 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Mon, 11 Mar 2024 13:30:21 -0700 Subject: [PATCH 16/16] doc: add comment for the type Co-authored-by: Francois Laithier --- src/types/onyx/Policy.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index e2ecaaa14bb8..b97038af28cc 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -105,6 +105,9 @@ type TaxCode = { name: string; }; +/** + * Data imported from QuickBooks Online. + */ type QBOConnectionData = { country: string; edition: string;