I have a bill for vendor A The bill has one entry, transfer account Expenses:TRA and some VAT details such that on posting the following bill transaction is created in my AP: Liabilities:VAT 21,00 Expenses:TRA 100,00 Liabilities:AP 121,00 This transaction will appear in the new-owner aging report for vendor A. The bill ID is clickable and links back to the bill itself. The amount is clickable as well and will open the transaction in the Liabilities:VAT account. That makes no sense to me. I would expect the transaction to open in the Liabilities:AP account as the Liabilities:AP split is the one matching the amount I clicked on.
Forgot to mention this is with a build from current maint https://github.com/Gnucash/gnucash/commit/073e47801d5da1f9448e575fcae4dee071899a76
The offending code is --- ;; for splits, find the first peer that is not in an APAR ;; account. this is adequate to find the transfer split (ie ;; asset/liability/income/expense account split). lot-link txns are ;; not expected to have any non-APAR split therefore returns #f. (define (txn->transfer-split txn) (find (compose (negate xaccAccountIsAPARType) xaccAccountGetType xaccSplitGetAccount) (xaccTransGetSplitList txn))) --- Basically from the AP posting split->transaction->splits, how to we determine the correct anchor click target? I wanted to avoid the originating APAR split, to ideally find the Transfer split i.e. the Expenses:TRA split. Customer invoices in my view should point to Income account. Vendor bills belong on the Expense account. It can easily be changed as follows: =====patch===== modified gnucash/report/business-reports/new-owner-report.scm @@ -745,7 +745,7 @@ (and (< orig-value 0) orig-value) (and (>= orig-value 0) orig-value) (invoice->sale invoice) (invoice->tax invoice) - (txn->transfer-split txn) + split link-option (cond ((and (txn-is-invoice? txn) (eq? link-option 'simple)) =====patch=====
(In reply to Christopher Lam from comment #2) > The offending code is > > > --- > ;; for splits, find the first peer that is not in an APAR > ;; account. this is adequate to find the transfer split (ie > ;; asset/liability/income/expense account split). lot-link txns are > ;; not expected to have any non-APAR split therefore returns #f. > (define (txn->transfer-split txn) > (find > (compose (negate xaccAccountIsAPARType) xaccAccountGetType > xaccSplitGetAccount) > (xaccTransGetSplitList txn))) > --- > > Basically from the AP posting split->transaction->splits, how to we > determine the correct anchor click target? > > I wanted to avoid the originating APAR split, to ideally find the Transfer > split i.e. the Expenses:TRA split. Customer invoices in my view should point > to Income account. Vendor bills belong on the Expense account. > Unfortunately no. In a business context the AP or AR account is the most important one and you should link there. As I said before in another context as soon as you have more than one entry in a bill or invoice or the bill/invoice uses VAT tables there no longer is "a transfer split". There will be multiple and there's no way to programatically determine which one is the most relevant. Even if in my simple case you would open the Expenses:TRA split that would confuse me initially: I clicked on an amount of 121 and the split in the register it opens will show me only 100. Additionally the Expenses:TRA won't give me any context. For example, if it involves a bill with multiple payments, I may want to open the lot viewer on the bill to evaluate the payments in more detail (the register equivalent of what your report does in the details view, with the exception that the lot viewer currently does show the exact parts of a payment matching the bill, not the payment totals). The lot viewer is not accessible from an expense account. It's only accessible from AR and AP accounts. > It can easily be changed as follows: > > =====patch===== > modified gnucash/report/business-reports/new-owner-report.scm > @@ -745,7 +745,7 @@ > (and (< orig-value 0) orig-value) > (and (>= orig-value 0) orig-value) > (invoice->sale invoice) (invoice->tax invoice) > - (txn->transfer-split txn) > + split > link-option > (cond > ((and (txn-is-invoice? txn) (eq? link-option 'simple)) > =====patch===== Indeed that will fix it.
(In reply to Geert Janssens from comment #3) > (In reply to Christopher Lam from comment #2) > > > Unfortunately no. In a business context the AP or AR account is the most > important one and you should link there. As I said before in another context > as soon as you have more than one entry in a bill or invoice or the > bill/invoice uses VAT tables there no longer is "a transfer split". There > will be multiple and there's no way to programatically determine which one > is the most relevant. > > Even if in my simple case you would open the Expenses:TRA split that would > confuse me initially: I clicked on an amount of 121 and the split in the > register it opens will show me only 100. > > Additionally the Expenses:TRA won't give me any context. For example, if it > involves a bill with multiple payments, I may want to open the lot viewer on > the bill to evaluate the payments in more detail (the register equivalent of > what your report does in the details view, with the exception that the lot > viewer currently does show the exact parts of a payment matching the bill, > not the payment totals). The lot viewer is not accessible from an expense > account. It's only accessible from AR and AP accounts. Ok. When a payment comprises multiple invoices, it'll link to the first APAR payment split though. To me it's not as useful as the originating account full-amount split, but ok.
Merged. FWIW the txn->transfer-split is still used for the RHS whereby it'd make more sense to show the Income/Expense split. This means the code txn->transfer-split is still not 100% right -- for LHS payments paying off a RHS invoice whose posting transaction has A/R, Income and Liability (VAT) splits, it may target the VAT account instead of the Income account. So it should be something like: --- (define (txn->transfer-split txn) (find (lambda (s) (memv (xaccAccountGetType (xaccSplitGetAccount s)) (cond ((txn-is-invoice? txn) (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)) ((txn-is-payment? txn) (list ACCT-TYPE-ASSET ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CHECKING ACCT-TYPE-SAVINGS ACCT-TYPE-MONEYMRKT ;;ACCT-TYPE-RECEIVABLE- exclude! ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY))))) (xaccTransGetSplitList txn))) --- Not easy isn't it?
(In reply to Christopher Lam from comment #5) > Merged. FWIW the txn->transfer-split is still used for the RHS whereby it'd > make more sense to show the Income/Expense split. > Why ? Personally I think the choice of split vs transfer split is not so much LHS vs RHS but invoice vs payment. Invoices are very likely to have more than one non-APAR split and exactly one APAR split. For payments (unless manually manipulated) will have one non-APAR split and can have multiple APAR splits (if the payment spans more than one document). > This means the code txn->transfer-split is still not 100% right -- for LHS > payments paying off a RHS invoice whose posting transaction has A/R, Income > and Liability (VAT) splits, it may target the VAT account instead of the > Income account. So it should be something like: > > --- > (define (txn->transfer-split txn) > (find > (lambda (s) > (memv (xaccAccountGetType (xaccSplitGetAccount s)) > (cond > ((txn-is-invoice? txn) (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)) > ((txn-is-payment? txn) > (list ACCT-TYPE-ASSET ACCT-TYPE-BANK ACCT-TYPE-CASH > ACCT-TYPE-CHECKING ACCT-TYPE-SAVINGS > ACCT-TYPE-MONEYMRKT ;;ACCT-TYPE-RECEIVABLE- exclude! > ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL > ACCT-TYPE-CURRENCY))))) > (xaccTransGetSplitList txn))) > --- > > Not easy isn't it? As I hinted before I still don't think that would work for invoices in case they have more than one non-APAR split. If the invoice in the report is marked for $100 (the invoice total), it makes sense to show the split representing that $100 when clicked. None of the income splits would match that amount if there's more than one non-APAR split. Simple example example invoice: AR $ 100 Income:Salary $ 80 Income:Bonus $ 20 The report will show an invoice of $ 100, yet none of the non-APAR splits does. So with your scheme, clicking on the link in the report would randomly choose the $ 80 or the $ 20 one.
Created attachment 373544 [details] trial patch (In reply to Geert Janssens from comment #6) > Personally I think the choice of split vs transfer split is not so much LHS > vs RHS but invoice vs payment. > > Invoices are very likely to have more than one non-APAR split and exactly > one APAR split. For payments (unless manually manipulated) will have one > non-APAR split and can have multiple APAR splits (if the payment spans more > than one document). ^ This is a nice succinct rule to follow > As I hinted before I still don't think that would work for invoices in case > they have more than one non-APAR split. If the invoice in the report is > marked for $100 (the invoice total), it makes sense to show the split > representing that $100 when clicked. None of the income splits would match > that amount if there's more than one non-APAR split. > > Simple example example invoice: > AR $ 100 > Income:Salary $ 80 > Income:Bonus $ 20 > > The report will show an invoice of $ 100, yet none of the non-APAR splits > does. So with your scheme, clicking on the link in the report would randomly > choose the $ 80 or the $ 20 one. So will it a worth rendering as follows? LHS invoice -> RHS payments - show bank/liab split (can be another currency) LHS payment -> RHS invoices - show APAR posting-split See attached trial patch.
(In reply to Christopher Lam from comment #7) > So will it a worth rendering as follows? > > LHS invoice -> RHS payments - show bank/liab split (can be another currency) > LHS payment -> RHS invoices - show APAR posting-split > > See attached trial patch. Can you explain in a bit more detail what you mean by this ? There's 4 numbers in there: LHS invoice, LHS payment, RHS invoice and RHS payment, but you only provide two display models. For what it's worth, I applied your patch to current maint and all LHS amounts seem to link to the APAR account where RHS the it's linked to Asset/Liability for payments and APAR for bills.
(In reply to Geert Janssens from comment #8) > (In reply to Christopher Lam from comment #7) > > So will it a worth rendering as follows? > > > > LHS invoice -> RHS payments - show bank/liab split (can be another currency) > > LHS payment -> RHS invoices - show APAR posting-split > > > > See attached trial patch. > > Can you explain in a bit more detail what you mean by this ? > > There's 4 numbers in there: LHS invoice, LHS payment, RHS invoice and RHS > payment, but you only provide two display models. > > For what it's worth, I applied your patch to current maint and all LHS > amounts seem to link to the APAR account where RHS the it's linked to > Asset/Liability for payments and APAR for bills. The patch takes the rule 'invoice=1 APAR split, payment=usually 1 non-APAR split' further: LHS invoice -> RHS payments, whereby each payment links to the bank/liab split (can be another currency). LHS payment -> RHS invoices, whereby each invoice links to the APAR posting-split (I think it's time to write some tests)