Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/app/api/quickbooks/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,31 @@ export class AuthService extends BaseService {
}

async manageIncomeAccountRef(intuitApi: IntuitAPI): Promise<string> {
const incomeAccRef = await intuitApi.getSingleIncomeAccount()
const existingIncomeAccRef = await intuitApi.getSingleIncomeAccount()
if (existingIncomeAccRef) {
return existingIncomeAccRef?.Id
}

console.info(
`IntuitAPI#manageIncomeAccountRef | No existing income account found. Creating new one.`,
)

const payload = {
Name: 'Assembly SOP Income',
Classification: 'Revenue',
AccountType: 'Income',
AccountSubType: 'SalesOfProductIncome',
Active: true,
}
const incomeAccRef = await intuitApi.createAccount(payload)
return incomeAccRef.Id
}

async manageExpenseAccountRef(intuitApi: IntuitAPI): Promise<string> {
const accName = 'Assembly Processing Fees'
const existingAccount = await intuitApi.getAnAccount(accName)
if (existingAccount) {
return existingAccount.Id
return existingAccount?.Id
}

// Docs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account#the-account-object
Expand All @@ -79,7 +95,7 @@ export class AuthService extends BaseService {
const accName = 'Assembly General Asset'
const existingAccount = await intuitApi.getAnAccount(accName)
if (existingAccount) {
return existingAccount.Id
return existingAccount?.Id
}

/**
Expand Down
Loading