Online Help
Pricing
Customers & Investors
Contact Us
 
 
 
OMADATAOBJECTS : SAGE EDITION | Online Help
   Public Function CreateInvoiceFromSalesOrder(ByVal oSOPRecord As SageDataObject50.SopRecord)
        Dim InvPost As SageDataObject90.InvoicePost
        Dim InvItem As SageDataObject90.InvoiceItem
        InvPost = ws50.CreateObject("InvoicePost")
        InvPost.Type = SageDataObject90.LedgerType.sdoLedgerInvoice
        InvPost.Header.Fields("Invoice_Number").Value = oSOPRecord.Fields.Item("INVOICE_NUMBER").Value
        InvPost.Header.Fields("Account_Ref").Value = oSOPRecord.Fields.Item("ACCOUNT_REF").Value
        InvPost.Header.Fields("Invoice_Date").Value = oSOPRecord.Fields.Item("ORDER_DATE").Value
        InvPost.Header.Fields("Order_Number").Value = oSOPRecord.Fields.Item("INVOICE_NUMBER").Value
        InvPost.Header.Fields("ITEMS_NET").Value = oSOPRecord.Fields.Item("ITEMS_NET").Value
        Dim intFirstItem As Integer
        intFirstItem = oSOPRecord.Fields.Item("FIRST_ITEM").Value
        Dim oSOPItem As SageDataObject90.SopItem
        oSOPItem = CType(oSOPRecord.Link, SageDataObject90.SopItem)
        oSOPItem.MoveFirst()
        Do
            InvItem = InvPost.Items.Add()
            InvItem.Fields.Item("Stock_Code").Value = oSOPItem.Fields.Item("STOCK_CODE").Value
            InvItem.Fields.Item("Description").Value = oSOPItem.Fields.Item("DESCRIPTION").Value
            InvItem.Fields.Item("Qty_Order").Value = oSOPItem.Fields.Item("QTY_ORDER").Value
            InvItem.Fields.Item("Unit_Price").Value = oSOPItem.Fields.Item("UNIT_PRICE").Value
            InvItem.Fields.Item("Net_Amount").Value = oSOPItem.Fields.Item("NET_AMOUNT").Value
            InvItem.Fields.Item("FULL_NET_AMOUNT").Value = oSOPItem.Fields.Item("FULL_NET_AMOUNT").Value           
        Loop While oSOPItem.MoveNext()
        If Not InvPost.Update Then
            MessageBox.Show("Unable to create invoice")
        End If
    End Function
 
 
Copyright 2008 Open Merchant Account Ltd. Sage® is a registered trademark of Sage Plc. All Trademarks recognised.