-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD Expensify/issues/390731] Fix account menu item visibility + reset account values #41079
Changes from all commits
2c1cdf5
27e1fac
3378491
36bff79
eaf68b0
ecd9631
d23b303
2e22a9e
0b029a3
c32473b
7b073df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ function QuickbooksCompanyCardExpenseAccountSelectCardPage({policy}: WithPolicyC | |
const policyID = policy?.id ?? ''; | ||
const {exportCompanyCard, syncLocations} = policy?.connections?.quickbooksOnline?.config ?? {}; | ||
const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); | ||
const {creditCards, bankAccounts, accountPayable} = policy?.connections?.quickbooksOnline?.data ?? {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
const defaultCards = useMemo<Card[]>( | ||
() => [ | ||
|
@@ -67,11 +68,18 @@ function QuickbooksCompanyCardExpenseAccountSelectCardPage({policy}: WithPolicyC | |
(row: CardListItem) => { | ||
if (row.value !== exportCompanyCard) { | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD, row.value); | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD_ACCOUNT); | ||
if (row.value === CONST.QUICKBOOKS_EXPORT_COMPANY_CARD.VENDOR_BILL) { | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD_ACCOUNT); | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ACCOUNT_PAYABLE, accountPayable?.[0]?.name); | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR); | ||
Comment on lines
70
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New record! 4 API calls 😅 cc @hayata-suenaga same question ^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @s77rt is correct. This breaks the 1:1:1 API design and shouldn't be allowed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. were these values there before your PR? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes in the backend will be done in this GH issue to update several fields of the connections configuration object, but the issue description might need to be updated. cc: @aldo-expensify There are fields I don't recognized, so I'd wait for @narefyev91's confirmation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes these values were added in the PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these fields don't exist on the backend 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't be adding config fields that don't already exist. This is a sample working QBO config:
|
||
} else { | ||
const accountName = row.value === CONST.QUICKBOOKS_EXPORT_COMPANY_CARD.CREDIT_CARD ? creditCards?.[0]?.name : bankAccounts?.[0]?.name; | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD_ACCOUNT, accountName); | ||
Comment on lines
+76
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB. Shouldn't we clear There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it's not really needed - when user will switch to debit/credit card - EXPORT_ACCOUNT_PAYABLE will not be used anywhere |
||
} | ||
} | ||
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT.getRoute(policyID)); | ||
}, | ||
[exportCompanyCard, policyID], | ||
[accountPayable, bankAccounts, creditCards, exportCompanyCard, policyID], | ||
); | ||
|
||
return ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyConnec | |
const isTaxError = isTaxesEnabled && exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; | ||
const isLocationError = isLocationsEnabled && exportEntity !== CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; | ||
const policyID = policy?.id ?? ''; | ||
const {bankAccounts, journalEntryAccounts, accountPayable} = policy?.connections?.quickbooksOnline?.data ?? {}; | ||
|
||
useEffect(() => { | ||
if (!isTaxError && !isLocationError) { | ||
|
@@ -73,11 +74,26 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyConnec | |
const selectExportEntity = useCallback( | ||
(row: CardListItem) => { | ||
if (row.value !== exportEntity) { | ||
let accountName; | ||
switch (row.value) { | ||
case CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK: | ||
accountName = bankAccounts?.[0]?.name; | ||
break; | ||
case CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL: | ||
accountName = accountPayable?.[0]?.name; | ||
break; | ||
case CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY: | ||
accountName = journalEntryAccounts?.[0]?.name; | ||
break; | ||
default: | ||
accountName = undefined; | ||
} | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, row.value); | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ACCOUNT, accountName); | ||
Comment on lines
91
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two API calls. Should we add this to https://github.com/Expensify/Expensify/issues/390731 @hayata-suenaga |
||
} | ||
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); | ||
}, | ||
[exportEntity, policyID], | ||
[accountPayable, bankAccounts, exportEntity, journalEntryAccounts, policyID], | ||
); | ||
|
||
return ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a memo for myself. Checked this field name is correct