It seems that your explanation makes sense, thanks for the "translation" ;). Unfortutnately I have no knowledge about this part of the code and did not look yet into details
Could you please open a Jira and submit a patch with your comments in code (this will help much) Thanks Jacques Robert G. wrote: > I played a little around and found in PartyFinancialHistory.groovy the > calculation of "totalToBeReceived" / "totalToBePayed" > > I believe, that these are the amounts that the company owe to the customer > or the customer owe to the company... > > if so, I think there is a misscalculation (cause I do not get correct > amounts there) > > your code: > transferAmount = > totalInvSaApplied.add(totalInvSaNotApplied).subtract(totalInvPuApplied.add(totalInvPuNotApplied)).subtract(totalPayInApplied.add(totalPayInNotApplied).*add*(totalPayOutApplied.add(totalPayOutNotApplied))); > > my opinion: > transferAmount = > totalInvSaApplied.add(totalInvSaNotApplied).subtract(totalInvPuApplied.add(totalInvPuNotApplied)).subtract(totalPayInApplied.add(totalPayInNotApplied).*subtract*(totalPayOutApplied.add(totalPayOutNotApplied))); > > in easier looking: > your code: > Sales Invoices - purchase invoices - (incomming payments + outgoing > payments) > > my code: > Sales Invoices - purchase invoices - (incomming payments - outgoing > payments) > > So lets test the cases: > *1. customer payed and we refund items * > payment 1000$ > sales invoices (applied and unapplied) = 1000$ > purchase invoice (refund) = 100$ (item refund) > refund payment 100$ > > acutally: 1000 - 100-(1000+100) = -100 --> Wrong, because we allready payed > and invoiced back > my way: 1000 - 100 -(1000-100) = 0 --> OK > > 2. customer payed more than he should (1200 instead of 1000) but we have not > refunded it (same amounts) > 1000 - 0 - (1200 - 0) = -200 --> OK, we owe 200$ to the customer > > what do you think, am I wrong? otherwise I do not understand the meaning of > the field value.
