Skip to content

Commit

Permalink
Merge pull request #37806 from Expensify/hayata-define-connections-ob…
Browse files Browse the repository at this point in the history
…ject
  • Loading branch information
francoisl authored Mar 11, 2024
2 parents 1f6e9a5 + 4fefa48 commit a37ea3c
Showing 1 changed file with 97 additions and 8 deletions.
105 changes: 97 additions & 8 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,107 @@ 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 = Record<string, unknown>;
type ConnectionData = Record<string, unknown>;
type ConnectionConfig = Record<string, unknown>;
type Connection = {
type ConnectionLastSync = {
successfulDate?: string;
errorDate?: string;
isSuccessful: boolean;
source: 'DIRECT' | 'EXPENSIFYWEB' | 'EXPENSIFYAPI' | 'AUTOSYNC' | 'AUTOAPPROVE';
};

type Account = {
glCode?: string;
name: string;
currency: string;
id: string;
};

type Employee = {
id: string;
firstName?: string;
lastName?: string;
name: string;
email: string;
};

type Vendor = {
id: string;
name: string;
currency: string;
email: string;
};

type TaxCode = {
totalTaxRateVal: string;
simpleName: string;
taxCodeRef: string;
taxRateRefs: Record<string, string>;
name: string;
};

/**
* Data imported from QuickBooks Online.
*/
type QBOConnectionData = {
country: string;
edition: string;
homeCurrency: string;
isMultiCurrencyEnabled: boolean;

journalEntryAccounts: Account[];
bankAccounts: Account[];
creditCards: Account[];
accountsReceivable: Account[];
accountsPayable: Account[];
otherCurrentAssetAccounts: Account[];

taxCodes: TaxCode[];
employees: Employee[];
vendors: Vendor[];
};

type IntegrationEntityMap = 'NONE' | 'DEFAULT' | 'TAG' | 'REPORT_FIELD';

/**
* User configuration for the QuickBooks Online accounting integration.
*/
type QBOConnectionConfig = {
realmId: string;
companyName: string;
autoSync: {
jobID: string;
enabled: boolean;
};
syncPeople: boolean;
syncItems: boolean;
markChecksToBePrinted: boolean;
reimbursableExpensesExportDestination: IntegrationEntityMap;
nonReimbursableExpensesExportDestination: IntegrationEntityMap;

reimbursableExpensesAccount?: string;
nonReimbursableExpensesAccount?: string;
autoCreateVendor: boolean;
hasChosenAutoSyncOption: boolean;
syncClasses: IntegrationEntityMap;
syncCustomers: IntegrationEntityMap;
syncLocations: IntegrationEntityMap;
exportDate: string;
lastConfigurationTime: number;
syncTax: boolean;
enableNewCategories: boolean;
export: {
exporter: string;
};
};
type Connection<ConnectionData, ConnectionConfig> = {
lastSync?: ConnectionLastSync;
data: ConnectionData;
config: ConnectionConfig;
};

type Connections = {
quickbooksOnline: Connection<QBOConnectionData, QBOConnectionConfig>;
};

type AutoReportingOffset = number | ValueOf<typeof CONST.POLICY.AUTO_REPORTING_OFFSET>;

type PendingJoinRequestPolicy = {
Expand Down Expand Up @@ -239,7 +328,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
chatReportIDAnnounce?: number;

/** All the integration connections attached to the policy */
connections?: Record<string, Connection>;
connections?: Connections;

/** Whether the Categories feature is enabled */
areCategoriesEnabled?: boolean;
Expand Down

0 comments on commit a37ea3c

Please sign in to comment.