Create Invoices using code...

thetallbloke
Member Posts: 66
Hi guys,
I need to create Sales Invoices (and eventually Purchase Invoices) for a customer but doing it automatically through C/Side code...
I have a dataport that imports a whole heap of data into our system and basically only want the user to enter a few details on the Dataport Options form and have the rest automated, to the point of posting to the GL, printing/email/faxing the invoice and finalising it all, as if they'd done it manually...
I know all the details for the Invoice, customer no., line items, etc.. my question is, do I just go and create the records in the Header/Line tables manually, or is there some pre-existing functions that I can call to do everything for me correctly...??
Any help would be very much appreciated..
Thanks
I need to create Sales Invoices (and eventually Purchase Invoices) for a customer but doing it automatically through C/Side code...
I have a dataport that imports a whole heap of data into our system and basically only want the user to enter a few details on the Dataport Options form and have the rest automated, to the point of posting to the GL, printing/email/faxing the invoice and finalising it all, as if they'd done it manually...
I know all the details for the Invoice, customer no., line items, etc.. my question is, do I just go and create the records in the Header/Line tables manually, or is there some pre-existing functions that I can call to do everything for me correctly...??
Any help would be very much appreciated..
Thanks
.
I'm not crazy !!! Just ask my toaster...
.
I'm not crazy !!! Just ask my toaster...
.
0
Answers
-
Do you mean posted Invoices or creating Sales Invoice, post it...?
I hope that the second case.
You need to create the header and lines in correct way and run the necessary codeunits to post it, print it etc.0 -
I already done the same thing as your scenario. The main thing you should consider is "validation of fields" and posting the transaction the right way (Just like Kine says).
Cheers!ma0 -
Kine,
Second case... I need to Create a Sales Invoice and then Post & Print the Sales Invoice..
I was just hoping someone could point to the right code unit(s) and functions to create the invoice lines, etc....
I'm not crazy !!! Just ask my toaster...
.0 -
There is no "generic" function for that, but you can look at codeunit 99008504 function "CreatePurchaseDocument" which is creating purchase doc. from some external data. You can use this example for the raw structure how to do that. After you insert all the data and you validate the created document manually (just import it first, check if all is correctly created etc.), you can call the posting codeunit to this document to post it...0
-
I'd probably design it in a commerce gateway type scenario. Import the data into staging tables, and process the information from there. That way you have a records of what was imported, and you can develop proper exception handling.0
-
Daniel,
The data is actually coming into a staging area, I just chose not to mention that to reduce some of the complexity of the problem...
Kine,
I'll have a look at that code unit...
Thanks.
I'm not crazy !!! Just ask my toaster...
.0 -
The way I usually approach these 'automated tasks' scenarios is to do the task manually, and debug the process as I go along. I try not to get caught up in the details, but to see if I can discover already existing functions in the application that I can use to automate the task.
The logical places to find order creation functions would be on requisition, planning, MRP type functionality, places like that. Maybe you can steal some logic from order creation routines from blanket orders.
Then when you have a good idea about how it's done in the standard app, you can use similar logic to create your own system.0 -
I'll second punossound's comment - field validiation and the order that fields are validated will probably be critical when you automate the tasks. I've automated this task several times in the past and I would recommend that you break the development down into 2 stages - order creation and everything else (posting, printing, etc.). This way you can create the Sales Headers & validate all of the fields and manually check order before it posts.
Auto posing and printing is fairly straight forward - you just call codeunit 80 or 90 dependong on whether it's sales or purchases and pass it the Sales/Purchase header record.
One word of caution here as you mentioned printing as well. Make sure that you commit or otherwise seperate things out so that your printing process DOES NOT keep locsk on those Sales & other ledger type tables. I've seen auto posting & printing scenarios where performance degrades significantly because the print part of the process is taking a while to complete and tying up other users from posting.0 -
Thanks guys..
You've been most helpful... I really appreciate the time you've taken to answer my question...
Hopefully not too much more ](*,) for me now... :-).
I'm not crazy !!! Just ask my toaster...
.0 -
You're very welcome mate
and please do come back with any question you have, we're all happy to help out.
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