Skip to content

Business Validation Error when attempting to create a deposit from payments in undeposited funds #391

@LumaC0

Description

@LumaC0

When attempting to create a Deposit object to move payments from undeposited funds to a bank account, I keep getting "Business Validation Error: Select a bank account for this deposit" even though the DepositToAccountRef is correctly set to a valid bank account.

I tried mirroring this operation in the UI and got the same error when attempting to add funds manually to a bank deposit. When I selected the provided payments from the undeposited funds account (from the "Select the payments included in this deposit" section at the top), the payment was successful. This leads me to believe that the DepositLineDetail object may not be necessary when linking payments from undeposited funds.

Any guidance on the correct structure for creating deposits from undeposited funds payments would be greatly appreciated.

This is roughly the code I've been working with:

deposit = Deposit()
deposit.DepositToAccountRef = get_account_by_name(account_name).to_ref()
deposit.TxnDate = transaction_date

for payment in payments:
    line = DepositLine()
    detail = DepositLineDetail() # I've tried removing this all together
    line.DetailType = "DepositLineDetail" # I've tried with and without this
    detail.Entity = payment.CustomerRef
    detail.PaymentMethodRef = payment.PaymentMethodRef
    detail.AccountRef = get_account_by_name("Payments to deposit").to_ref() # the name of my undeposited funds account
    line.DepositLineDetail = detail  # type: ignore
    line.Amount = payment.TotalAmt  # type: ignore
    line.LinkedTxn = [payment.to_linked_txn()]
    deposit.Line.append(line)

deposit.save(qb=client)

python version: 3.12.11
python-quickbooks version: 0.9.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions