6.4 KiB
Requirement: Expense Account for Deductions
Summary
Payment deductions require the Expense Account field to be set.
This is a mandatory requirement enforced by validation.
Why This Requirement?
Technical Reason
When creating a payment with deductions, the journal entry structure is:
Expense Account (Debit) ← Must be specified
Tax Accounts (Credit) ← Deductions
Bank Account (Credit) ← Net payment
Without the Expense Account, the system cannot determine which account should receive the debit entry.
Accounting Reason
The Expense Account represents:
- The full cost/expense being incurred
- The account that should be debited for the total amount
- The proper classification of the expense
Example:
- Telepon & Internet expense: Rp 2,000,000
- Less: PPh 21 withheld: Rp 100,000
- Less: PPh 29 withheld: Rp 50,000
- Net payment to vendor: Rp 1,850,000
The Expense Account (Telepon & Internet) gets the full Rp 2,000,000 debit.
Validation
The module enforces this requirement with a validation constraint:
@api.constrains('amount', 'amount_substract', 'expense_account_id', 'deduction_line_ids')
def _check_amount_substract(self):
for payment in self:
# ... other validations ...
# Require expense account when using deductions
if payment.deduction_line_ids and not payment.expense_account_id:
raise ValidationError(_(
"Expense Account is required when using payment deductions.\n\n"
"Please set the Expense Account field before adding deductions."
))
When Validation Triggers
The validation error appears when:
- You add deduction lines
- But haven't set the Expense Account field
- And try to save or post the payment
Error Message
Expense Account is required when using payment deductions.
Please set the Expense Account field before adding deductions.
How to Use
Correct Workflow
1. Create Payment
↓
2. Set Expense Account ✅ (e.g., "Telepon & Internet")
↓
3. Add Deductions (e.g., PPh 21, PPh 29)
↓
4. Post Payment ✅
Incorrect Workflow (Will Fail)
1. Create Payment
↓
2. Add Deductions ❌
↓
3. Try to Post ❌
↓
Error: "Expense Account is required..."
Alternative: Without Deductions
If you don't need deductions, you can use the standard payment flow:
1. Create Payment
↓
2. Don't set Expense Account (optional)
↓
3. Don't add Deductions
↓
4. Post Payment ✅
In this case, the system uses the standard Accounts Payable account.
Comparison
With Expense Account + Deductions
Journal Entry:
Expense Account Debit: 2,000,000
PPh 21 Credit: 100,000
PPh 29 Credit: 50,000
Bank Credit: 1,850,000
Use Case: Direct expense recording with tax withholding
Without Expense Account (Standard)
Journal Entry:
Accounts Payable Debit: 2,000,000
Bank Credit: 2,000,000
Use Case: Standard vendor payment without deductions
Benefits of This Requirement
1. Clear Accounting
Forces users to specify exactly which expense account should be used, ensuring:
- Proper expense classification
- Accurate financial reporting
- Clear audit trail
2. Prevents Errors
Prevents common mistakes like:
- Missing expense account
- Unclear journal entries
- Unbalanced entries
3. Consistent Behavior
Ensures all payments with deductions follow the same pattern:
- Always have an expense account
- Always have proper journal entries
- Always have correct tax treatment
Configuration
Required Accounts
Before using deductions, set up:
1. Expense Accounts
Chart of Accounts > Create Account
- Name: Telepon & Internet
- Code: 611505
- Type: Expenses
2. Tax Payable Accounts
Chart of Accounts > Create Account
- Name: PPh 21
- Code: 217101
- Type: Current Liabilities
Account Selection
When creating a payment with deductions:
Expense Account: Choose from expense accounts
- ✅ Telepon & Internet
- ✅ Office Supplies
- ✅ Professional Fees
- ❌ Accounts Payable (not allowed)
Deduction Accounts: Choose from tax/liability accounts
- ✅ PPh 21 (Tax Payable)
- ✅ PPh 23 (Tax Payable)
- ✅ PPh 29 (Tax Payable)
- ❌ Accounts Payable (not allowed)
- ❌ Bank accounts (not allowed)
User Training
Key Points to Teach Users
- Always set Expense Account first when using deductions
- Choose the right expense account for the type of expense
- Use tax accounts for deductions, not payable accounts
- Verify amounts before posting
Common Questions
Q: Why can't I just use Accounts Payable?
A: When using deductions, you're recording the expense directly. Accounts Payable is for tracking vendor balances, not expenses.
Q: What if I forget to set Expense Account?
A: You'll get a validation error. Just set the Expense Account field and try again.
Q: Can I change the Expense Account after adding deductions?
A: Yes, as long as the payment hasn't been posted yet.
Technical Details
Module Integration
This requirement is part of the vendor_payment_diff_amount module v2.0.0.
It works with:
vendor_batch_payment_merge(provides expense_account_id field)- Standard Odoo accounting (account.payment)
Field Definition
The expense_account_id field is defined in vendor_batch_payment_merge:
expense_account_id = fields.Many2one(
'account.account',
string='Expense Account',
domain="[('account_type', 'not in', ('asset_receivable', 'liability_payable'))]",
help="Account used for expense instead of the default payable/receivable account"
)
Validation Logic
The validation is in vendor_payment_diff_amount:
if payment.deduction_line_ids and not payment.expense_account_id:
raise ValidationError("Expense Account is required...")
Summary
✅ DO: Set Expense Account before adding deductions ✅ DO: Use expense accounts for Expense Account field ✅ DO: Use tax accounts for deduction accounts ❌ DON'T: Try to add deductions without Expense Account ❌ DON'T: Use Accounts Payable for deductions
Remember: Expense Account is REQUIRED when using deductions!
For more information, see:
- USER_GUIDE.md - Step-by-step instructions
- README.md - Module overview
- FINAL_FIX.md - Technical details