automating Payment Allocation to invoice

kamranshehzad
Member Posts: 165
Hi
I want to automate payment allocation to invoices. Eg, if i have 1 payment that needs to be applied to 1 invoice and it needs to be allocated. I want this process automated rather than going into customer ledger and set applies to id and then post.
I wrote a code unit that takes the parameters and set applies to id, amount and applying entry for payment and invoice but posting fails.
I can't see any other entry that needs to be done before posting during Nav set aplies to id process.
I can't see any entry in gen journal line either.
Am I missing something that needs to be done before i execute CU 226 with the payment record ?
regards,
I want to automate payment allocation to invoices. Eg, if i have 1 payment that needs to be applied to 1 invoice and it needs to be allocated. I want this process automated rather than going into customer ledger and set applies to id and then post.
I wrote a code unit that takes the parameters and set applies to id, amount and applying entry for payment and invoice but posting fails.
I can't see any other entry that needs to be done before posting during Nav set aplies to id process.
I can't see any entry in gen journal line either.
Am I missing something that needs to be done before i execute CU 226 with the payment record ?
regards,
KS
0
Answers
-
If you set the Application Method to "Apply To Oldest" in the customer card all payments will automatically be applied.
Is this what you're looking for?0 -
No. we need manual payment allocations. ](*,)KS0
-
shouldn't I just pass the desired record to CU101 and that will do the job????KS0
-
kamranshehzad wrote:I want to automate payment allocationkamranshehzad wrote:we need manual payment allocations.
:-k0 -
Savatage wrote:kamranshehzad wrote:I want to automate payment allocationkamranshehzad wrote:we need manual payment allocations.
Its a setting in customer card i believe.
:-k
](*,)KS0 -
Can any one guide me on this?
regards,KS0 -
What for an "Application Methode" do you use? It's behind the Register Payments.There are two options:
Manual and "Apply to Oldest".
Manual means that the program will apply payments only if you specify a document.
Apply to Oldest means that if you do not specify a document for the payment to be applied to, the program will apply the payment to the oldest of the customer's open entries.
RegardsDo you make it right, it works too!0 -
garak wrote:What for an "Application Methode" do you use? It's behind the Register Payments.There are two options:
Manual and "Apply to Oldest".
Manual means that the program will apply payments only if you specify a document.
Apply to Oldest means that if you do not specify a document for the payment to be applied to, the program will apply the payment to the oldest of the customer's open entries.
Regards
No Man.. you are not getting the point. I am getting orders and then payments from other system through our written interfaces in nav. in order to allocate those payments , i am getting the allocations ( they can't come at same time as mostly payments get allocated later on) through interfaces.
Now I need to write a routine that picks up the sales payment and related invoices (I can filter them ) and allocate them.
I am trying to replicate the allocation process but facing issues.
so all i want to know if there is any example that some one give me or advise me the best way to do so.
We dont want to use the above given process as some times allocated amount is not equal to payment or some times payment is allocated to multiple invoices etc.
hope its clear now.
please advise.
regards,KS0 -
kamranshehzad wrote:garak wrote:What for an "Application Methode" do you use? It's behind the Register Payments.There are two options:
Manual and "Apply to Oldest".
Manual means that the program will apply payments only if you specify a document.
Apply to Oldest means that if you do not specify a document for the payment to be applied to, the program will apply the payment to the oldest of the customer's open entries.
Regards
No Man.. you are not getting the point. I am getting orders and then payments from other system through our written interfaces in nav. in order to allocate those payments , i am getting the allocations ( they can't come at same time as mostly payments get allocated later on) through interfaces.
Now I need to write a routine that picks up the sales payment and related invoices (I can filter them ) and allocate them.
I am trying to replicate the allocation process but facing issues.
so all i want to know if there is any example that some one give me or advise me the best way to do so.
We dont want to use the above given process as some times allocated amount is not equal to payment or some times payment is allocated to multiple invoices etc.
hope its clear now.
please advise.
regards,
2. generate a random applies-to Id and set "Applies-to ID" field on both gen. journal and cust. ledger entry.
3. call cu 103 to update cust. ledger entry..
you can look into report 393 to see how NAV can handle this..no need to use "Applying Entry" etc.. just "amount to apply" and "Applies-To ID" can solve your problem.
If you are geting error, please explain your problem in detail.0 -
1. amount to apply must be set as remaining amount. (note that remaining amount is flow field)
2. generate a random applies-to Id and set "Applies-to ID" field on both gen. journal and cust. ledger entry.
3. call cu 103 to update cust. ledger entry..
you can look into report 393 to see how NAV can handle this..no need to use "Applying Entry" etc.. just "amount to apply" and "Applies-To ID" can solve your problem.
If you are geting error, please explain your problem in detail.
thanks this something i was looking for.
I did trying to set it cust ledger entry to amount to apply (validating it was setting the remaining amount i believe)
and was setting applied to id in cust ledger entry but not in gen. journal. and was calling cu 103 to update the entry and then was trying to post.
upon posting it finds that applying entry and applied to entry are same. i thinks this is due to missing applicatoin to g j entry.
I did look into GJ line table but i can't find any entry there.
Can you please advise me on this? am i looking at wrong table?
regards,KS0 -
I did the following to make it work
1- set the values of applying payment ledger entry (with out using code unit 103)
2- set the values of invoice ledger entry
3- passing the invoice entry to CustEntry-Apply Posted Entries
it does the job but I am not sure whether this will not cause any other issue. can some one please advise me on this.
here is the test code i wrote for this. Please feel free to comment on any thing in code. ill welcome it.Documentation() - THIS CODE UNIT IS DESIGNED TO - SELECT THE RELATED PAYMENT - APPLIES TO ID - POST THE ENTRY AS ALLOCATED ENTRY OnRun() ToDocNo := '471'; ToExtDocNo := '883'; ToERPDocType := 'Invoice'; AmountToApply := 10; ByDocNo := '552624'; ByExtDocNo := '1856'; ByERPDocType := 'Payment'; IF ByERPDocType = 'Payment' THEN BEGIN ApplyingCustLedgEntry.SETCURRENTKEY("Document Type" ,"Document No." , "External Document No."); ApplyingCustLedgEntry.SETRANGE("Document Type", ApplyingCustLedgEntry."Document Type"::Payment); ApplyingCustLedgEntry.SETRANGE("Document No.", ByDocNo); ApplyingCustLedgEntry.SETRANGE("External Document No.", ByExtDocNo); IF ApplyingCustLedgEntry.FIND('-') THEN IF ApplyingCustLedgEntry.Open THEN IF ToERPDocType = 'Invoice' THEN BEGIN CustLedgerEntry.SETCURRENTKEY("Document Type" ,"Document No." , "External Document No."); CustLedgerEntry.SETRANGE("Document Type", ApplyingCustLedgEntry."Document Type"::Invoice); CustLedgerEntry.SETRANGE("Document No.", ToDocNo); CustLedgerEntry.SETRANGE("External Document No.", ToExtDocNo); IF CustLedgerEntry.FIND('-') THEN BEGIN ApplyingCustLedgEntry.VALIDATE("Applies-to ID",USERID); ApplyingCustLedgEntry.VALIDATE("Amount to Apply", -AmountToApply); ApplyingCustLedgEntry.CALCFIELDS("Remaining Amount"); ApplyingCustLedgEntry.MODIFY; CustLedgerEntry.RESET; CustLedgerEntry.SETCURRENTKEY("Document Type" ,"Document No." , "External Document No."); CustLedgerEntry.SETRANGE("Document Type", ApplyingCustLedgEntry."Document Type"::Invoice); CustLedgerEntry.SETRANGE("Document No.", ToDocNo); CustLedgerEntry.SETRANGE("External Document No.", ToExtDocNo); CustLedgerEntry.VALIDATE("Applies-to ID",USERID); CustLedgerEntry.VALIDATE("Amount to Apply",AmountToApply); CustLedgerEntry.CALCFIELDS("Remaining Amount"); CustLedgerEntry.MODIFY; CustLedgerEntry.RESET; CustLedgerEntry.SETCURRENTKEY("Document Type" ,"Document No." , "External Document No."); CustLedgerEntry.SETRANGE("Document Type", ApplyingCustLedgEntry."Document Type"::Invoice); CustLedgerEntry.SETRANGE("Document No.", ToDocNo); CustLedgerEntry.SETRANGE("External Document No.", ToExtDocNo); IF CustLedgerEntry.FIND('-') THEN BEGIN CustEntryApplyPostedEntry.RUN(CustLedgerEntry); END; END; END; END; PostEntry(VAR CustEntryApplyPostedEntries : Record "Cust. Ledger Entry") CustEntryApplyPostedEntry.RUN(CustEntryApplyPostedEntries);
KS0 -
Hi Kamran,
Did you find the solution? I facing the same scenario can you shave code or any helping materiel to solve this problem.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions