Interestingly, there's already a field called ManualInvoiceID_W on the table CustInvoiceTable, but it's associated with countries LT,LV. However, you can use the code that makes that work as a good template for making this work yourself.
In our case, we added another field called ManualInvoiceID to the table.
In class CustPostInvoice, we added this method.
private container getNumAndVoucher(NumberSeq _numberSeq)
{
container ret;
if (custInvoiceTable.ManualInvoiceID != '')
{
_numberSeq.parmNumberSequenceCode('');
_numberSeq.parmNumberSequenceId(0);
ret = [custInvoiceTable.ManualInvoiceID, _numberSeq.voucher()];
}
else
{
ret = _numberSeq.numAndVoucher();
}
return ret;
}
And then modified part of the run() method as follows.
..
numberSeq = this.allocateNumAndVoucher();
// <GEEU>
if (countryRegion_LTLV)
{
[invoiceId, voucher] = this.getNumAndVoucher_W(numberSeq);
if (! CustInvoiceJour::checkDuplicateNum_W(invoiceId, '', custInvoiceTable.InvoiceDate))
{
throw error("@SYS25904");
}
}
else
{
// </GEEU>
[invoiceId, voucher] = this.getNumAndVoucher(numberSeq);
// <GEEU>
if (! custInvoiceJour::checkDuplicateNum_W(invoiceId, '', custInvoiceTable.InvoiceDate))
{
throw error("@SYS25904");
}
}
// </GEEU>
..
We originally considered using a Ledger journal because it allows the specification of the Invoice number, but during posting it collapses all of the offset lines into a single CustInvoiceTrans record, and for our purposes we needed each offset line to generate its own CustInvoiceTrans record with the description intact.
Hope this helps.