Cash Book Receipt. How to get the debtor?  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Cash Book Receipt. How to get the debtor?

Postby DannyC » Thu Aug 18, 2022 5:14 pm

I'm wanting to import a cash receipt batch sort of like the Bendigo Bank sample plugin but somewhat simpler.

I am adding a new line using this code from the above plugin
Code: Select all
CashBookForm.CashBook.AddNewTransaction(JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransactionCollection.TransactionTypes.Other, "", ref newTransactionKey);

but really, I want it to be a debtor transaction.
The only value I am supplied with is a debtor accountno. Aside from the value, a reference/InvRemitNo and date. But key to my question is the debtor accountno.

Just not sure of the correct syntax if I use
Code: Select all
CashBookForm.CashBook.AddNewTransaction(JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransactionCollection.TransactionTypes.Debtor, "", ref newTransactionKey);

(Note the difference is the transaction type).

Maybe I need to use
Code: Select all
cashBook.ReadDebtor(param, param, param and so on)

but all I can give ReadDebtor is the accountno. I know the last parameter is a bool UseDebtorAccountNoAsSeed which would be true.

I've fiddled about with a few various syntaxes but I'm stabbing in the dark and not getting anywhere.

When I go
Code: Select all
cashBook.ReadDebtor("1001", true)

I get a compile error No overload method for ReadDebtor takes 2 arguments.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Cash Book Receipt. How to get the debtor?  Topic is solved

Postby Mike.Sheen » Thu Aug 18, 2022 5:26 pm

The ReadDebtor method of CashBook wants a bunch of parameters passed in by reference and it sets those.

The method definition is:
Code: Select all
Public Sub ReadDebtor(ByRef DebtorID As String, ByRef DebtorAccountNo As String, ByRef DebtorAccountName As String, ByRef PeriodType As CashBookTransactionCollection.DebtorCreditorPeriodTypes, ByRef TermsType As CashBookTransactionCollection.TermsTypes, ByRef TermsDays As Integer, ByRef CurrentBalance As Decimal, ByRef Period1Balance As Decimal, ByRef Period2Balance As Decimal, ByRef Period3Balance As Decimal, ByRef Period4Balance As Decimal, Optional ByVal UseDebtorAccountNoAsSeed As Boolean = False)


So to use that, you need to declare some variables and pass those - and in C# you need to annotate those when you pass them as ref parameters.

The hint for it is shown in the editor:
ReadDebtorMethodHint.png


So you'd need code like this:
Code: Select all
string DebtorID = null;
string DebtorAccountNo = "1001";
string DebtorAccountName = null;
JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransactionCollection.DebtorCreditorPeriodTypes PeriodType = JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransactionCollection.DebtorCreditorPeriodTypes.Monthly;
JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransactionCollection.TermsTypes TermsType = JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransactionCollection.TermsTypes.Invoice;
int TermsDays = 0;
decimal CurrentBalance = 0;
decimal Period1Balance = 0;
decimal Period2Balance = 0;
decimal Period3Balance = 0;
decimal Period4Balance = 0;

cashBook.ReadDebtor(ref DebtorID, ref DebtorAccountNo, ref DebtorAccountName, ref PeriodType, ref TermsType, ref TermsDays, ref CurrentBalance, ref Period1Balance, ref Period2Balance, ref Period3Balance, ref Period4Balance,  true);


Personally, because that looks like an old crufty awful legacy Vb3 method, I'd instead create a debtor entity and use that to get what I want - it includes all the above fields, I believe - and you can read it using the debtor account no. or debtor id.
Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor debtor = cashBook.Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor>();
debtor.ReadRecordFromAccountNo("1001");
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Cash Book Receipt. How to get the debtor?

Postby Scott.Pearce » Thu Aug 18, 2022 5:47 pm

DannyC wrote:
Maybe I need to use
Code: Select all
cashBook.ReadDebtor(param, param, param and so on)

but all I can give ReadDebtor is the accountno. I know the last parameter is a bool UseDebtorAccountNoAsSeed which would be true.

I've fiddled about with a few various syntaxes but I'm stabbing in the dark and not getting anywhere.

When I go
Code: Select all
cashBook.ReadDebtor("1001", true)

I get a compile error No overload method for ReadDebtor takes 2 arguments.


You need to go and learn about parameter passing, i.e. what byval and byref means. And specifically, how parameters can be used as a way of *returning* values. Further, you cannot omit parameters unless they are prefixed with the *optional* keyword (in VB parlance).
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Cash Book Receipt. How to get the debtor?

Postby DannyC » Thu Aug 18, 2022 5:55 pm

You need to go and learn about parameter passing

Quite right!

And cheers Mike - armed with that info I reckon I can take it from here...until the next issue!

EDIT:
So it ended up being waaaay easier than using ReadDebtor.

Based on the hint to create a debtor entity, it's as simple as
Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor debtor = cashBook.Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor>();
debtor.ReadRecordFromAccountNo("1001");
CashBookForm.CashBook.AddNewTransaction(JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransactionCollection.TransactionTypes.Debtor, debtor.DebtorID, ref newTransactionKey);


I didn't know that the second parameter in AddNewTransaction would be the debtorID.
Anyway, all good & didn't have to use ReadDebtor.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 24 guests

cron