Remove Debtor Allocations

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

Remove Debtor Allocations

Postby SBarnes » Tue Dec 29, 2020 7:08 pm

How can I using an SQL statement remove all allocations back to a given date this will be the transaction date for a debtor that is the parent account and include all the allocations on the children as well?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Remove Debtor Allocations

Postby Mike.Sheen » Wed Dec 30, 2020 12:52 pm

SBarnes wrote:How can I using an SQL statement remove all allocations back to a given date this will be the transaction date for a debtor that is the parent account and include all the allocations on the children as well?


Code: Select all
DECLARE @DebtorID CHAR(20) = '00000000080000000002'
DECLARE @DateLimit DATETIME = '2012-10-15'

DELETE
FROM DB_TransAlloc
WHERE (DebtorID = @DebtorID OR DebtorID IN (SELECT DebtorID FROM DB_Main WHERE ParentDebtorID = @DebtorID))
AND DateAlloc >= @DateLimit


Doing this will likely result in the period balances in DB_Main being now wrong - so you can then just run a period rollover and check the 'Recalc balances only' checkbox to have it re-calculate those balances for you.
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: Remove Debtor Allocations

Postby SBarnes » Wed Dec 30, 2020 1:00 pm

Won't this also mean the allocated amount in DB_Trans will also now be wrong or will recalc balances fix that?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Remove Debtor Allocations

Postby Mike.Sheen » Thu Dec 31, 2020 11:31 am

SBarnes wrote:Won't this also mean the allocated amount in DB_Trans will also now be wrong or will recalc balances fix that?


Yes and Yes

:)
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: Remove Debtor Allocations

Postby SBarnes » Mon Jan 04, 2021 3:42 pm

Thanks Mike,

I have found a weird thing with the debtor allocation screen where it over allocates and doubles up see the screenshot, this appears to be when orders may have had products that have more than two decimal places in them, I can't seem to reproduce it in demo data or on debtors where this hasn't occurred.

Are you aware of any issues with the screen?
Attachments
overallocation.jpg
over allocation
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Remove Debtor Allocations

Postby Mike.Sheen » Tue Jan 05, 2021 10:57 am

SBarnes wrote:Are you aware of any issues with the screen?


No - but I'll take a look to see if I can see anything obvious in the code.

In the meantime, perhaps a temporary solution which will bring to your attention when it occurs, would be a trigger to RAISERROR if the DB_Trans allocated amount is being set to something greater than the amount?
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: Remove Debtor Allocations

Postby SBarnes » Tue Jan 05, 2021 12:40 pm

A trigger won't do any good as it's whilst the whole thing is still in memory, I haven't even tried to save it, also I should have mentioned that once it over allocates you can't undo it you have to delete the lines out of the screen.

This is actually to do with the customer who sells seeds who you were looking at some performance issues with during last year.

It happens whether or not you tell the screen to auto allocate credits or debits or not in other words if you load the transaction in and then type in values it happens as well.

One other thing I have just discovered which might explain part of the issue where this is related to parent and child debtors, 0001314972-D01 is on a child account where there are no unaged or not fully allocated credits so it may be related to where the allocation is crossing the boundaries between the children.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 0 guests