Skip to content

Commit ea8f320

Browse files
refactor(OUT-3523): rename manage*AccountRef to getOrCreate*AccountRef
Rename methods to better reflect their find-or-create semantics and add consistent logging across all three account ref methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 42ac77f commit ea8f320

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

src/app/api/quickbooks/token/token.service.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,16 @@ export class TokenService extends BaseService {
171171
)
172172
}
173173

174-
private async manageIncomeAccountRef(intuitApi: IntuitAPI): Promise<string> {
174+
private async getOrCreateIncomeAccountRef(
175+
intuitApi: IntuitAPI,
176+
): Promise<string> {
175177
const existingIncomeAccRef = await intuitApi.getSingleIncomeAccount()
176178
if (existingIncomeAccRef?.Id) {
177179
return existingIncomeAccRef.Id
178180
}
179181

180182
console.info(
181-
'TokenService#manageIncomeAccountRef | No existing income account found. Creating new one.',
183+
'TokenService#getOrCreateIncomeAccountRef | No existing income account found. Creating new one.',
182184
)
183185

184186
const payload = {
@@ -192,13 +194,19 @@ export class TokenService extends BaseService {
192194
return incomeAccRef.Id
193195
}
194196

195-
private async manageExpenseAccountRef(intuitApi: IntuitAPI): Promise<string> {
197+
private async getOrCreateExpenseAccountRef(
198+
intuitApi: IntuitAPI,
199+
): Promise<string> {
196200
const accName = 'Assembly Processing Fees'
197201
const existingAccount = await intuitApi.getAnAccount(accName)
198202
if (existingAccount?.Id) {
199203
return existingAccount.Id
200204
}
201205

206+
console.info(
207+
'TokenService#getOrCreateExpenseAccountRef | No existing expense account found. Creating new one.',
208+
)
209+
202210
const payload = {
203211
Name: accName,
204212
Classification: 'Expense',
@@ -210,13 +218,19 @@ export class TokenService extends BaseService {
210218
return expenseAccRef.Id
211219
}
212220

213-
private async manageAssetAccountRef(intuitApi: IntuitAPI): Promise<string> {
221+
private async getOrCreateAssetAccountRef(
222+
intuitApi: IntuitAPI,
223+
): Promise<string> {
214224
const accName = 'Assembly General Asset'
215225
const existingAccount = await intuitApi.getAnAccount(accName)
216226
if (existingAccount?.Id) {
217227
return existingAccount.Id
218228
}
219229

230+
console.info(
231+
'TokenService#getOrCreateAssetAccountRef | No existing asset account found. Creating new one.',
232+
)
233+
220234
// Need to create this account as the source of cash for the company. This account will be referenced while creating a purchase as Expense for absorbed fee.
221235
// Docs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account#the-account-object
222236
const payload = {
@@ -235,11 +249,11 @@ export class TokenService extends BaseService {
235249
): Promise<string> {
236250
switch (accountType) {
237251
case AccountTypeObj.Income:
238-
return this.manageIncomeAccountRef(intuitApi)
252+
return this.getOrCreateIncomeAccountRef(intuitApi)
239253
case AccountTypeObj.Expense:
240-
return this.manageExpenseAccountRef(intuitApi)
254+
return this.getOrCreateExpenseAccountRef(intuitApi)
241255
case AccountTypeObj.Asset:
242-
return this.manageAssetAccountRef(intuitApi)
256+
return this.getOrCreateAssetAccountRef(intuitApi)
243257
default:
244258
throw new APIError(
245259
httpStatus.BAD_REQUEST,

0 commit comments

Comments
 (0)