Integrations

QuickBooks Chart of Accounts Setup Guide

This guide explains how to set up accounts in QuickBooks Online for integration with the Hiana Loans accounting module. The system posts journal entries to QuickBooks using internal account type codes — each must be mapped to a QuickBooks account.

Important: The system only posts journal entries to QuickBooks. It does not create accounts, bills, invoices, or customers via the API. You must create the accounts manually in QuickBooks first, then map them in Hiana Loans.


Table of Contents

  1. How It Works
  2. Accounts Used by the System
  3. QuickBooks Setup Steps
  4. Recommended QuickBooks Account Types
  5. Account Mapping
  6. Journal Entry Reference
  7. Minimum Viable Setup
  8. Per-Product and Per-Jurisdiction Overrides
  9. Posting Configuration
  10. Troubleshooting
  11. Quick Setup Checklist

How It Works

The Hiana Loans accounting module uses a double-entry journal entry system. When loan events occur (disbursement, payment, interest accrual, fee assessment, etc.), the system:

  1. Generates a journal entry with debit and credit lines
  2. Resolves internal account codes to your QuickBooks account codes via the account mapping table
  3. Posts the entry to QuickBooks via the QuickBooks Online API (POST /v3/company/:id/journalentry)

Each internal account type (e.g., LOANS_RECEIVABLE, INTEREST_INCOME) must be mapped to a specific QuickBooks account. If a mapping is missing, the journal entry is rejected — the system will not post with unresolved account codes.

The integration uses three QuickBooks API operations only:

OperationPurpose
POST /journalentryCreate journal entries
GET /query (Account)Query account balances for reconciliation
GET /companyinfoTest connection / verify credentials

No other QuickBooks API operations are needed.


Accounts Used by the System

These are the internal account codes that the journal entry builder actually references. Each one must have a mapping to a QuickBooks account.

Core Accounts (Required — 7 accounts)

#Internal CodeAccount CategoryPurposeUsed By Events
1CASHAssetCash/bank for disbursements and repaymentsDisbursement, Payment, Collateral Liquidation
2LOANS_RECEIVABLEAssetOutstanding loan principalDisbursement, Payment, Write-off, Guarantee Claim, Collateral Liquidation
3INTEREST_RECEIVABLEAssetInterest accrued but not yet collectedInterest Accrual, Payment
4FEES_RECEIVABLEAssetFees assessed but not yet collectedFee Assessment, Payment
5INTEREST_INCOMEIncomeInterest revenue recognizedInterest Accrual
6FEE_INCOMEIncomeFee revenue (service fees)Fee Assessment
7PENALTIES_RECEIVABLEAssetPenalties assessed but not yet collectedPenalty Assessment, Payment

Extended Accounts (Required for full lifecycle — 4 accounts)

#Internal CodeAccount CategoryPurposeUsed By Events
8PENALTY_INCOMEIncomePenalty revenue recognizedPenalty Assessment
9LOAN_LOSS_PROVISIONContra-AssetAllowance for expected credit losses (IFRS 9)Loan Write-off
10GUARANTEE_RECEIVABLEAssetAmount recoverable from guarantor after claimGuarantee Claim
11DEFERRED_INTEGRAL_FEESContra-AssetLoan fees integral to EIR, amortised over loan lifeFee Assessment (optional, only if fee policy = integral EIR)

Collateral & Guarantee Accounts (Required for collateral liquidation — 4 accounts)

#Internal CodeAccount CategoryPurposeUsed By Events
12GUARANTEE_LIABILITYLiabilityCash collateral held as guarantee liabilityGuarantee Deposit
13REPOSSESSED_ASSETSAssetRepossessed assets under lender controlCollateral Repossession
14COLLATERAL_RECOVERYIncomeGain/loss on collateral sale vs. outstanding balanceCollateral Repossession
15SURPLUS_PROCEEDS_PAYABLELiabilityCollateral sale surplus owed to borrowerCollateral Repossession, Surplus Payment

Tax Accounts (Required for tax provisioning — 4 accounts)

#Internal CodeAccount CategoryPurposeUsed By Events
16INCOME_TAX_EXPENSEExpenseCurrent and deferred income tax expenseTax Provisioning
17TAX_PAYABLELiabilityCurrent tax owed to revenue authoritiesTax Provisioning
18DEFERRED_TAX_ASSETAssetDeferred tax asset (future deductible temporary differences)Tax Provisioning
19DEFERRED_TAX_LIABILITYLiabilityDeferred tax liability (future taxable temporary differences)Tax Provisioning

Reserved Accounts (Seeded but not yet used by the builder)

These accounts exist in the system's chart of accounts for future use. You do not need to create them in QuickBooks until the corresponding features are activated.

Internal CodeCategoryIntended Purpose
IMPAIRMENT_LOSS_EXPENSEExpenseECL provision expense when allowance is measured (future)
IMPAIRMENT_RECOVERYIncomeRecovery of previously written-off amounts (future)
DIRECT_LOAN_ORIGINATION_COSTSAssetOrigination costs included in EIR calculation (future)

QuickBooks Setup Steps

Step 1: Create Accounts in QuickBooks

  1. Log into QuickBooks Online
  2. Go to Settings (gear icon) → Chart of Accounts (or search "Chart of Accounts" in the search bar)
  3. Click New
  4. For each account in the tables above:
    • Select the Account Type (e.g., Bank, Other Current Asset, Income, Expense)
    • Select the Detail Type (optional but recommended for reporting)
    • Enter the Account Name (use a human-readable name, not the internal code)
    • Leave the opening balance blank (the system will populate via journal entries)
    • Click Save and Close
  5. Repeat for each account

Important: Do not use the internal code (e.g., FEES_RECEIVABLE) as the QuickBooks account name. Use a readable name like "Fees Receivable". The internal code is mapped separately in Hiana Loans.

Step 2: Note QuickBooks Account IDs

When you create an account in QuickBooks, it assigns a numeric Account ID (e.g., 93). You can find this by:

  • Querying the account via the QuickBooks API, or
  • Looking at the account in the Chart of Accounts

You will need the QuickBooks Account ID (not the name) when creating the mapping in Hiana Loans. The mapping links your stable internal code to the QuickBooks account ID, so if someone renames the account in QuickBooks, the mapping still works.

Step 3: Enable QuickBooks Provider in Hiana Loans

  1. Log into the Hiana Loans Admin Portal
  2. Go to Accounting → External Providers
  3. Find the QuickBooks provider
  4. Click Configure Credentials and enter:
    • Client ID
    • Client Secret
    • Refresh Token
    • Company ID
  5. Click Activate to enable the provider

Step 4: Create Account Mappings

  1. Go to Accounting → Account Mappings
  2. For each internal account type, map it to the corresponding QuickBooks account:
    • Select the Internal Account Type (e.g., LOANS_RECEIVABLE)
    • Enter the QuickBooks Account ID (the numeric ID from Step 2)
    • Enter the QuickBooks Account Name (for display/reference)
    • Click Save
  3. Repeat for all accounts

Recommended QuickBooks Account Types

When creating accounts in QuickBooks, use these account types and detail types:

#QB Account TypeSuggested Detail TypeAccount NameInternal Code
1BankBankOperating Bank AccountCASH
2Other Current AssetOther Current AssetsLoans ReceivableLOANS_RECEIVABLE
3Other Current AssetOther Current AssetsInterest ReceivableINTEREST_RECEIVABLE
4Other Current AssetOther Current AssetsFees ReceivableFEES_RECEIVABLE
5Other Current AssetOther Current AssetsPenalties ReceivablePENALTIES_RECEIVABLE
6IncomeService/Fee IncomeInterest IncomeINTEREST_INCOME
7IncomeService/Fee IncomeFee IncomeFEE_INCOME
8IncomeOther Primary IncomePenalty IncomePENALTY_INCOME
9Other Current AssetOther Current AssetsAllowance for Expected Credit LossesLOAN_LOSS_PROVISION
10Other Current AssetOther Current AssetsGuarantee ReceivableGUARANTEE_RECEIVABLE
11Other Current AssetOther Current AssetsDeferred Integral Loan FeesDEFERRED_INTEGRAL_FEES
12Other Current LiabilityOther Current LiabilitiesGuarantee LiabilityGUARANTEE_LIABILITY
13Other Current AssetOther Current AssetsRepossessed AssetsREPOSSESSED_ASSETS
14IncomeOther Primary IncomeCollateral RecoveryCOLLATERAL_RECOVERY
15Other Current LiabilityOther Current LiabilitiesSurplus Proceeds PayableSURPLUS_PROCEEDS_PAYABLE
16ExpenseOther Business ExpenseIncome Tax ExpenseINCOME_TAX_EXPENSE
17Other Current LiabilityOther Current LiabilitiesTax PayableTAX_PAYABLE
18Other Current AssetOther Current AssetsDeferred Tax AssetDEFERRED_TAX_ASSET
19Other Current LiabilityOther Current LiabilitiesDeferred Tax LiabilityDEFERRED_TAX_LIABILITY

Note on LOAN_LOSS_PROVISION: This is a contra-asset (allowance), not an expense. It reduces the net loans receivable on the balance sheet. The expense for measuring the allowance (IMPAIRMENT_LOSS_EXPENSE) is a separate account reserved for future use when ECL provisioning is automated.

Note on COLLATERAL_RECOVERY: This account captures both gains and losses on collateral disposal. When sale proceeds exceed the outstanding balance, the surplus is credited here (gain). When proceeds are less, the deficiency is debited here (loss).

Note on Detail Types: The exact detail type names depend on your QuickBooks region/company setup. The Account Type is what matters for financial statement classification; detail type is for additional categorization.


Account Mapping

The mapping table links internal account codes to QuickBooks accounts. The system resolves mappings with the following priority:

  1. Per-Product + Per-Jurisdiction (most specific)
  2. Per-Product only
  3. Per-Jurisdiction only
  4. Global (default for all products and jurisdictions)

Mapping Dimensions

Each mapping can be scoped by:

  • product_id — Optional, maps only for a specific product
  • fee_type — Optional, maps only for a specific fee type (e.g., ORIGINATION vs. INSURANCE)
  • jurisdiction_id — Optional, maps only for a specific jurisdiction

If a scoped mapping is not found, the system falls back to the global mapping.

Example: Fee-Specific Mapping

You may want different QuickBooks income accounts for different fee types:

Internal CodeFee TypeQuickBooks Account
FEE_INCOME(global)Fee Income
FEE_INCOMEORIGINATIONOrigination Fee Income
FEE_INCOMEINSURANCEInsurance Commission Income
FEE_INCOMEPROCESSINGProcessing Fee Income

This gives you granular income tracking per fee type in QuickBooks.


Journal Entry Reference

The system posts these journal entries to QuickBooks. Each entry is a balanced double-entry with at least one debit and one credit line.

1. Loan Disbursement

When a loan is disbursed to a borrower:

AccountDRCR
Loans ReceivablePrincipal
Cash / BankPrincipal

Description: "Loan disbursement - [loan number]" Posting: Immediate

2. Payment Received

When a borrower makes a repayment:

AccountDRCR
Cash / BankTotal payment
Loans ReceivablePrincipal portion
Interest ReceivableInterest portion
Fees ReceivableFee portion
Penalties ReceivablePenalty portion

Key point: Payments credit the receivable accounts, not income accounts. Income was already recognized when the fee/interest was assessed or accrued. This prevents double-counting revenue.

Description: "Payment received - [payment reference]" Posting: Immediate

3. Interest Accrued

When interest accrues on a loan (daily or monthly):

AccountDRCR
Interest ReceivableAccrual amount
Interest IncomeAccrual amount

Description: "Interest accrual - Loan [loan ID]" Posting: Batch (aggregated daily)

4. Fee Assessed

When a fee is charged to a loan:

Standard fee (service fee):

AccountDRCR
Fees ReceivableFee amount
Fee IncomeFee amount

Integral fee (part of effective interest rate):

AccountDRCR
Fees ReceivableFee amount
Deferred Integral Loan FeesFee amount

The system determines which treatment to use based on the fee accounting policy. Origination fees that are integral to the loan's EIR are deferred and amortised over the loan life, not recognized as immediate income.

Description: "Fee assessed - [fee type] - Loan [loan ID]" Posting: Batch (aggregated per fee type)

5. Penalty Assessed

When a penalty is charged:

AccountDRCR
Penalties ReceivablePenalty amount
Penalty IncomePenalty amount

Description: "Penalty assessed - [penalty type] - Loan [loan ID]" Posting: Batch (aggregated daily)

6. Loan Written Off

When a loan is written off as bad debt:

AccountDRCR
Allowance for Expected Credit LossesWrite-off amount
Loans ReceivableWrite-off amount

This removes the loan from the balance sheet using the contra-asset allowance. The expense for building the allowance (IMPAIRMENT_LOSS_EXPENSE) is recognized separately when the ECL is measured, not at write-off time.

Description: "Loan write-off - [loan number]" Posting: Immediate

7. Loan Closed

No journal entry is posted. Loan closure is an operational status change, not a financial event. The system explicitly skips journal entry creation for this event.

8. Guarantee Claimed

When a guarantee is invoked against a third-party guarantor:

AccountDRCR
Guarantee ReceivableClaim amount
Loans ReceivableClaim amount

This transfers the borrower's loan exposure to a receivable from the guarantor. The lender is now owed by the guarantor, not the borrower. This is not an expense — it's a substitution of debtor.

Description: "Guarantee claimed - [reference]" Posting: Immediate

9. Collateral Liquidated

When collateral is sold and proceeds are applied directly to the loan:

AccountDRCR
Cash / BankLiquidation amount
Loans ReceivableLiquidation amount

Pledged collateral remains off-balance-sheet until repossession. Sale proceeds are applied directly against the loan receivable.

Description: "Collateral proceeds applied - Loan [loan ID]" Posting: Immediate

10. Collateral Repossessed

When collateral is repossessed and transferred to lender control:

AccountDRCR
Repossessed AssetsOutstanding balance
Loans ReceivableOutstanding balance

If the repossessed asset is subsequently sold:

AccountDRCR
Cash / BankSale proceeds
Repossessed AssetsSale proceeds

If sale proceeds > outstanding balance (gain):

AccountDRCR
Collateral RecoverySurplus
Surplus Proceeds PayableSurplus

If sale proceeds < outstanding balance (loss):

AccountDRCR
Collateral RecoveryDeficiency
Repossessed AssetsDeficiency

Description: "Collateral repossession - Loan [loan ID]" Posting: Immediate

11. Surplus Proceeds Paid to Borrower

When surplus from collateral sale is paid to the borrower:

AccountDRCR
Surplus Proceeds PayableSurplus amount
Cash / BankSurplus amount

Description: "Surplus proceeds paid to borrower - Loan [loan ID]" Posting: Immediate

12. Guarantee Deposit Received

When cash collateral is received as a guarantee deposit:

AccountDRCR
Cash / BankDeposit amount
Guarantee LiabilityDeposit amount

The guarantee liability is recognised because the cash belongs to the guarantor and must be returned if the loan is repaid.

Description: "Cash collateral deposit - Guarantee [guarantee ID]" Posting: Immediate

13. Tax Provisioned

When income tax is provisioned for a reporting period:

Current tax:

AccountDRCR
Income Tax ExpenseCurrent tax
Tax PayableCurrent tax

Deferred tax (expense):

AccountDRCR
Income Tax ExpenseDeferred tax
Deferred Tax LiabilityDeferred tax

Deferred tax (benefit):

AccountDRCR
Deferred Tax AssetDeferred tax
Income Tax ExpenseDeferred tax

Description: "Tax provision - [reporting period]" Posting: Immediate


Minimum Viable Setup

If you want to start simple, create just these 7 accounts in QuickBooks:

QB Account TypeAccount NameInternal CodeCovers
BankOperating Bank AccountCASHDisbursements, payments, collateral proceeds
Other Current AssetLoans ReceivableLOANS_RECEIVABLEPrincipal tracking, write-offs, guarantee claims
Other Current AssetInterest ReceivableINTEREST_RECEIVABLEInterest accruals, interest collections
Other Current AssetFees ReceivableFEES_RECEIVABLEFee assessments, fee collections
IncomeInterest IncomeINTEREST_INCOMEInterest revenue
IncomeFee IncomeFEE_INCOMEFee revenue
Other Current AssetPenalties ReceivablePENALTIES_RECEIVABLEPenalty assessments, penalty collections

This covers the core loan lifecycle:

  • Loan disbursement
  • Payment receipt (principal + interest + fees + penalties)
  • Interest accrual
  • Fee assessment
  • Penalty assessment

Add the remaining accounts as you enable:

  • Penalty income tracking → Add Penalty Income
  • Write-offs (IFRS 9) → Add Allowance for Expected Credit Losses
  • Guarantee claims → Add Guarantee Receivable
  • Integral fee deferral → Add Deferred Integral Loan Fees
  • Guarantee deposits → Add Guarantee Liability
  • Collateral repossession → Add Repossessed Assets, Collateral Recovery, Surplus Proceeds Payable
  • Tax provisioning → Add Income Tax Expense, Tax Payable, Deferred Tax Asset, Deferred Tax Liability

Per-Product and Per-Jurisdiction Overrides

When to Use Overrides

ScenarioOverride TypeExample
Different loan products need separate receivable accountsPer-ProductNano loans → "Nano Loans Receivable", Traditional → "Traditional Loans Receivable"
Different jurisdictions require separate income accountsPer-JurisdictionKenya interest income → "KES Interest Income", Zambia → "ZMW Interest Income"
Different fee types need separate income accountsPer-Fee-TypeOrigination → "Origination Fee Income", Insurance → "Insurance Commission"
A specific product in a specific jurisdiction needs its own accountPer-Product + Per-JurisdictionNano loans in Kenya → "KE Nano Loans Receivable"

How to Create Overrides

  1. Go to Accounting → Account Mappings
  2. Click Add Mapping
  3. Select the Internal Account Type
  4. Optionally select a Product (leave blank for global)
  5. Optionally select a Jurisdiction (leave blank for all)
  6. Optionally enter a Fee Type (leave blank for all fee types)
  7. Enter the QuickBooks Account ID
  8. Click Save

The system will use the most specific mapping available. If no specific mapping is found, it falls back to the global mapping.


Posting Configuration

The system can post journal entries in two modes:

ModeEventsBehavior
ImmediateDisbursement, Payment, Write-off, Guarantee Claim, Collateral LiquidationPosts each event as it happens (real-time)
BatchInterest Accrual, Fee Assessment, Penalty AssessmentAggregates events and posts as a single entry (daily)

Batch Posting

For high-volume operations, batch posting reduces API calls to QuickBooks:

  • Interest accruals from 10,000 loans → 1 aggregated journal entry
  • Fee assessments across all loans → 1 aggregated entry per fee type
  • Penalty assessments across all loans → 1 aggregated entry

Configure batch posting in config/external_accounting.yaml:

external_accounting:
  enabled: false  # Set to true when ready
  provider: "quickbooks"
  posting_frequency: daily  # daily, weekly, monthly
  auto_post: true  # true = immediate, false = batch
  posting_time: "23:00"  # Batch posting time (HH:MM)

Troubleshooting

Common Issues

IssueCauseFix
Journal entry fails with "no resolved external account mapping"Missing account mapping for an internal codeCreate the mapping in Account Mappings for the missing internal code
Journal entry fails with "account not found" in QuickBooksWrong QuickBooks Account ID in mappingVerify the Account ID in QuickBooks and update the mapping
No entries posting to QuickBooksProvider not activated or integration disabledActivate the QuickBooks provider and set enabled: true in config
Entries posting to wrong accountOverride mapping is too broad or too narrowCheck if product/jurisdiction-specific mappings are correct
Batch events not postingNo active accounting provider configuredActivate the QuickBooks provider in Admin → Accounting → Providers
Warning: "no active accounting providers configured"Provider is inactiveThis is expected if external accounting is not yet enabled. Events remain pending and will post when the provider is activated.

Checking Posting Status

  1. Go to Accounting → Event Log to see all accounting events
  2. Check the Status column: PENDING, PROCESSING, POSTED, FAILED, RETRYING
  3. For failed events, check the Error column for details
  4. Failed events are automatically retried up to 3 times with 5-minute intervals

Quick Setup Checklist

  • Create core accounts in QuickBooks (7 minimum)
  • Create extended accounts in QuickBooks (4 more for full lifecycle)
  • Create collateral & guarantee accounts in QuickBooks (4 more for collateral liquidation)
  • Create tax accounts in QuickBooks (4 more for tax provisioning)
  • Note QuickBooks Account IDs from Chart of Accounts
  • Enable QuickBooks provider in Hiana Loans Admin
  • Configure credentials (Client ID, Secret, Refresh Token, Company ID)
  • Activate provider (set to active)
  • Create global account mappings (map each internal code to QB Account ID)
  • Create per-product overrides (if needed for different loan products)
  • Create per-jurisdiction overrides (if operating in multiple countries)
  • Create per-fee-type overrides (if tracking fee income separately)
  • Test connection (Admin → Accounting → Providers → Test Connection)
  • Test with a small loan disbursement and verify the entry appears in QuickBooks
  • Enable external accounting in config (enabled: true)