Page 1 of 1

Posting S/O payments to cashbook

PostPosted: Wed Sep 30, 2020 8:53 am
by pricerc
If I'm capturing C/C payments for a sales order, and I want to keep the sales order open (i.e. not process the order), but also want the payment to make it to the cashbook immediately, can I just use SalesOrder.ProcessPayments()? And what are the caveats, if any?

Re: Posting S/O payments to cashbook  Topic is solved

PostPosted: Wed Sep 30, 2020 11:43 am
by Scott.Pearce
can I just use SalesOrder.ProcessPayments()?

Absolutely. That's exactly what it's for - process payments but not the sales order.

caveats

You will probably want to have some control over the changing of a sales order that has had payments processed against it? Otherwise, nothing else comes to mind.

Re: Posting S/O payments to cashbook

PostPosted: Wed Sep 30, 2020 4:50 pm
by pricerc
Ok,

related question. How do I calculate the outstanding balance on an part-paid, unprocessed order that has items on backorder that need to be paid for in advance ?

I actually have two very different customers for whom these apply, but for quite different reasons.

I have a part-payment recorded and posted (perhaps a deposit or a laybuy) on said unprocessed order. The payment can be cash or credit card.

If I'm on snapshot #1, I figure (with help from the POS plugin) that the amount outstanding can probably be calculated as:

Code: Select all
( Lines.Sum(l => l.LineValueIncTax) ) - ( Payments.Where(p => p.AuthorisationStatus == Authorised || p.AuthorisationStatus == NoAuthorisationNeeded ).Sum(p => p.AmountPaid) )


But what if I'm on a later snapshot?

Does this same logic still work and/or is there another method that I'm missing?

Re: Posting S/O payments to cashbook

PostPosted: Wed Sep 30, 2020 5:08 pm
by Mike.Sheen
The figure on the bottom right of the payments tab - "Balance" - is the total amount owing, minus already made payments, and includes backordered amounts

SalesOrder_BO_With_Payment.png


That is calculated as:

Code: Select all
FreightAmount = SalesOrder.SalesOrderHistorys((SalesOrder.SelectedHistoryNo)).CartageCharge1.IncGSTAmount + SalesOrder.SalesOrderHistorys((SalesOrder.SelectedHistoryNo)).CartageCharge2.IncGSTAmount + SalesOrder.SalesOrderHistorys((SalesOrder.SelectedHistoryNo)).CartageCharge3.IncGSTAmount

Balance = SalesOrder.SalesOrderLines.OrderedIncGSTTotal + FreightAmount) - SalesOrder.SalesOrderPayments.TotalPayments


I believe that this is what you want - but your way is virtually the same - it's just we've already got a property doing that summing for you.

Re: Posting S/O payments to cashbook

PostPosted: Wed Sep 30, 2020 6:09 pm
by pricerc
will
Code: Select all
SalesOrder.SalesOrderPayments.TotalPayments
cope with (i.e. ignore), e.g. declined CC payments?

Re: Posting S/O payments to cashbook

PostPosted: Wed Sep 30, 2020 6:16 pm
by Mike.Sheen
pricerc wrote:will
Code: Select all
SalesOrder.SalesOrderPayments.TotalPayments
cope with (i.e. ignore), e.g. declined CC payments?


Nope.

So, now after reading your linq more closely I see you omit those - our TotalPayments does not and is obviously flawed.

Would you like a job fixing bugs?

Your calculation works, and would work with all snapshots - whilst payments do have a snapshot property to associate them with one, all payments for all snapshots would be included in your query, and SalesOrderLines.OrderedIncGSTTotal is always going to be the same, across all snapshots - so those combined will give you the outstanding balance (you may need to add freight charges as well like in my example).

Re: Posting S/O payments to cashbook

PostPosted: Fri Feb 05, 2021 10:57 am
by pricerc
I like to avoid necro'ing threads, but this is related.

If I've got a payment posted to cashbook from an unprocessed sales order, the cashbook transaction is unallocated - fair enough, because there's no invoice.

If I process the sales order later, is there a (convenient) way to create an allocation for the pre-payment?