Greetings,
I am encoutering a big issue in our extension.
The flow:
- We create sales shipping lines/headers from a custom document by inserting them manually, and using item jnl-post code unit.
- We create a new invoice, and import the shipping lines
- We post the invoice
Everything seem to work, except, when we try to correct an invoice, the lines do not exist in "Item Ledger Entry", so it gives an error.
Also, a lot of report, dont seem to see the invoices, as they seem to be based on item ledger entry and entry values.
Any idea on why item ledger entries are not filled in by business central when posting an invoice? Where should I look on whats happening please?
Regards
HD
Lots of questions in a single post I can't speak to your solution and why it doesn't work, you will need to get someone involved (i.e. hire someone) to look at that in detail. In general though, the design approach that I would take is quite different from a solution point of view:
BC has its own process, where you have to create a sales order, and post the shipping from the order. By calling the Sales-Post routine with the sales order, the system will automatically take care of everything you need. It will post the proper item journals, which in turn will create the proper ILE's and Value Entries, and it will prepare the system to create the invoice.
I would never program a process to create posted documents directly. I have, in fact, declined to work on jobs where that was the "requirement", only to be pulled back in when we had to fix all the issues that were created as a result. The BC posting routines are robust enough to rely on, and they will make sure that everything is posted at least consistently.
Then, for the invoicing part, you have two choices: Either you post the invoice from the same sales order, or you create an unposted invoice and pull in the shipment lines to link to. There is a process in BC that does this for you, and you can extend that to customize the process.
The standard approach is: YOU write the code to create the unposted document, and you then utilize the standard posting to get the posted transactions into the system. I would stay away from creating posted documents directly altogether.
One more thing: the invoicing process does not create Item Ledger Entries, the shipping process does that. You could create an unposted invoice for items, and post that, but internally, the system will call the shipping process to take care of the proper item ledger entries. By default, you post the shipment first (which creates the ILEs) and then you post the invoice (which creates the Customer Ledger Entries). The standard posting routine will take care of the posted documents for you, no need to write any code for that.