ProjInvoiceItem::initInvoice_SalesOrder Method
Creates a new invoice line and initializes it from an invoice proposal line using data from the associated sales order line.
Syntax
client server public static ProjInvoiceItem initInvoice_SalesOrder(ProjProposalItem _projProposalItem)
Run On
Called
Parameters
- _projProposalItem
Type: ProjProposalItem Table
The invoice proposal line from which to initialize the invoice line.
Return Value
Type: ProjInvoiceItem Table
The new invoice line.
Examples
The following example creates an item invoice line from an item invoice proposal line and saves it.
public void projInvoiceItemCreate(ProjProposalItem _projProposalItem)
{
ProjInvoiceItem projInvoiceItem;
// Initialize the invoice line fields from the invoice proposal.
projInvoiceItem = ProjInvoiceItem::initInvoice_SalesOrder(_projProposalItem);
// Set the invoice ID and date based on the invoice proposal's journal.
projInvoiceItem.ProjInvoiceId = _projProposalItem.projProposalJour().ProjInvoiceId;
projInvoiceItem.InvoiceDate = _projProposalItem.projProposalJour().InvoiceDate;
// Validate the invoice line before attempting to save.
if (!projInvoiceItem.validateWrite())
{
// Update has been aborted due to an error.
throw error("@SYS21628");
}
// Save the new invoice line to the database.
projInvoiceItem.insert();
}