point-of-sale: consuming customer credits  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

point-of-sale: consuming customer credits

Postby pricerc » Fri Oct 08, 2021 2:06 pm

Our (new) customer is getting the hang of his new environment.

He's a "cash only" business, in that he doesn't have 'on account' customers. If people want stuff from his shop, they have to pay for it first.

95% of the time the transactions are this simple, and the POS software is just fine. But occasionally, customers return stuff. And then want to buy different stuff. And it gets complicated.

Say the customer returns $200 worth of goods, which is credited back into stock; they get a $200 credit on their account (rather than a cash refund). We can handle this.

Then they want to buy $300 worth of goods, for which they want to use their $200 credit, and pay the balance in cash. This is where it gets tricky.

What I'd like, is to be able to pop up a "Hey, this customer has a $200 credit, would you like to use it?" And if they answer 'yes', then I'd like the till slip to reflect a $200 'payment' from store credit and a $100 payment in cash.

I figure finding the $200 credit will be easy enough by looking at the debtor's current balance. But:

1) I don't know how to 'allocate' that $200 credit to the $300 sale so that I can show it as a 'payment' on the sale.
2) consequently, I don't know how to (reliably) capture the fact that I still need to collect $100 in cash (or credit card). And then process the 'fully paid' order.

So there are few parts to this puzzle, and I'm not sure where to start.

Even if we drive this process in Jiwa itself, instead of from the POS, it's quite a few steps, and a bit messy.

for (1), some options considered include:
a) adding a 'discount' item to the order, hiding it from the UI, but making it look like a 'payment' record on the till receipt.
b) adding a payment type of 'consume store credit', and then figuring out how to journal it into the right place as part of processing the order.

Any suggestions?
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: point-of-sale: consuming customer credits

Postby Mike.Sheen » Fri Oct 08, 2021 2:24 pm

When you say POS are you referring to an external POS system, or Jiwa's POS plugin?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: point-of-sale: consuming customer credits

Postby pricerc » Fri Oct 08, 2021 6:02 pm

Mike.Sheen wrote:When you say POS are you referring to an external POS system, or Jiwa's POS plugin?


The POS I developed, which started out loosely based on the Jiwa plugin, but is a standalone WinForms app.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: point-of-sale: consuming customer credits

Postby pricerc » Fri Oct 15, 2021 9:59 am

Ok, we've been discussing this in the office. And we think we have a viable solution.

within the POS, I currently will only process an order if it has been fully paid; because it's primarily a cash business in a retail environment.

But for the odd 'on-account' customer who may have a credit balance, I can keep track of the customer's available credit, and then allow the order to be processed if there is sufficient customer credit, and the operator has chosen 'yes' to the question of 'would you like to use the credit?'.

But that still leaves me with a bit of 'untidyness'. Mostly, the customer's current balance is not normally updated at the time the invoice is processed, if there is cash involved.

The invoice also needs to be allocated the credit and cash payments.

I think I've got some existing code for dealing with the allocations, but how do I activate cash receipts as they happen (instead of adding them to a batch that needs activating) ?
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: point-of-sale: consuming customer credits

Postby pricerc » Fri Oct 15, 2021 9:59 am

Ok, we've been discussing this in the office. And we think we have a viable solution.

within the POS, I currently will only process an order if it has been fully paid; because it's primarily a cash business in a retail environment.

But for the odd 'on-account' customer who may have a credit balance, I can keep track of the customer's available credit, and then allow the order to be processed if there is sufficient customer credit, and the operator has chosen 'yes' to the question of 'would you like to use the credit?'.

But that still leaves me with a bit of 'untidyness'. Mostly, the customer's current balance is not normally updated at the time the invoice is processed, if there is cash involved.

The invoice also needs to be allocated the credit and cash payments.

I think I've got some existing code for dealing with the allocations, but how do I activate cash receipts as they happen (instead of adding them to a batch that needs activating) ?
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: point-of-sale: consuming customer credits

Postby Mike.Sheen » Fri Oct 15, 2021 5:06 pm

pricerc wrote:how do I activate cash receipts as they happen (instead of adding them to a batch that needs activating) ?


That's how Jiwa does receipts - The Cash Book Receipt batch. That's what you use.

There is nothing stopping you activating each batch as soon as it is saved - a little bit of plugin code is all that is needed - read the Cash Book Receipt batch and invoke the Activate() method.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: point-of-sale: consuming customer credits  Topic is solved

Postby pricerc » Mon Oct 18, 2021 10:51 am

Mike.Sheen wrote:
pricerc wrote:how do I activate cash receipts as they happen (instead of adding them to a batch that needs activating) ?


That's how Jiwa does receipts - The Cash Book Receipt batch. That's what you use.

There is nothing stopping you activating each batch as soon as it is saved - a little bit of plugin code is all that is needed - read the Cash Book Receipt batch and invoke the Activate() method.


Looked at this over the weekend (I don't have much of a life during lock downs anyway).

I started looking into handling this in a plugin (and may still do so), but couldn't quickly see how to get all the different pieces together. Not helped by the fact that the setup we're using for this customer has several things pointing to a clearing account that probably shouldn't be (I'll be changing that this week, but it's a different story).

But along the way, I noticed that the "ProcessPayments" method has a pair of optional lambda functions for parameters. So between ilSpy and a fair bit of experimentation, I got to this:
Code: Select all
...
                so.SalesOrderPayments.Add(payment);

                CashBook paymentBatch = so.Manager.BusinessLogicFactory.CreateBusinessLogic<CashBook>(null);
                paymentBatch.CashBookType = CashBook.CashBookTypes.Receipt;
                paymentBatch.CreateNew();
                paymentBatch.BankLedgerID = payment.PaymentType.LedgerAccount.RecID;
                paymentBatch.BatchDate = payment.PaymentDate;
                paymentBatch.ClientClassName = "JiwaFinancials.Jiwa.JiwaCashBookUI.frmCashBookReceipts"; // hack
                paymentBatch.Description = $"Cash received for {so.InvoiceNo}-D{so.CurrentHistoryNo:00}";

                // whether or not the invoices is fully paid, we want to process the payment directly,
                // and activate the cashbook batch.
                so.ProcessPayments(null, (pmt, acct) => { return paymentBatch; });

                // reload batch
                paymentBatch.Setup();
                paymentBatch.Read(paymentBatch.RecID);
                paymentBatch.Activate();
...



I have some more testing to do, but it seems to be working well so far.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: point-of-sale: consuming customer credits

Postby Mike.Sheen » Mon Nov 15, 2021 7:02 pm

Neat.

For those following at home, If you don't provide that function, then the default behaviour is to try and find an existing cash book receipt for the same date as the payment on the sales order, with the bank account associated with the payment type - and if the BatchGrouping system setting is set to Warehouse with a Description pattern matching "Sales Receipts / W:%PhyscialWarehouseName%", or if BatchGrouping set to "Branch", with a Description pattern matching "Sales Receipts / B:%BranchName%".

For some reason I interpreted your last request as not wanting to use Cash book Receipts at all... and I completely forgot about the optional CashBookResolutionFunction parameter to the ProcessPayments() method of the sales order. From memory we added that to facilitate a Magento store creating orders which had captured payments and they had odd rules about cut-off times for grouping the cash book receipt batches for the different payment types.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: point-of-sale: consuming customer credits

Postby pricerc » Tue Nov 30, 2021 8:58 am

Mike.Sheen wrote:I completely forgot about the optional CashBookResolutionFunction parameter to the ProcessPayments() method of the sales order. From memory we added that to facilitate a Magento store creating orders which had captured payments and they had odd rules about cut-off times for grouping the cash book receipt batches for the different payment types.


To be fair, I still struggle to get my head around using functions and lambdas in this way. While it is quite powerful, it is not always intuitive and an easy way to make code unintentionally obscure.

I am still missing a bit where I'd like to reflect the allocated credit as a 'payment' on the sales order, so that if I print out an invoice the debtor's credit shows up under 'payments', with a nil balance at the bottom. For now, I'm adding a comment line to the sales order, but it is not very pretty on a cashdrawer receipt.

Next time I have a few days spare I might tackle it - I know from some other part of the puzzle that I can create a payment record and then *not* process it through to cashbook, so my current thinking is to overload that logic.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests