Summary
Resolution
Sage 200 2022 R2
Whats New?
In this release of Sage 200, we have included the ability to add tracking information of couriers to your SOP Despatch Routine.
The main object used when adding tracking information as part of the despatch of an order is the Sage.Accounting.SOP.PendingSOPDespatchReceipt object. As part of the despatch a collection of PendingSOPDespatchReceipts Sage.Accounting.SOP.PendingSOPDespatchReceipts can be set to the PendingSOPDespatchReceipts property of the SOPDespatchReceiptAdjustment and for each item in the collection the PendingSOPDespatchReceipt properties be set for the specific tracking values:
Property | Type | Details |
SYSCourier | Sage.Accounting.SystemManager.SYSCourier | The courier used for the despatch |
ConsignmentNo | String | The consignment number (shipping reference) for the despatch |
SOPIncoterm | Sage.Accounting.SOP.SOPIncoterm | Incoterm (International Commercial Term) for the despatch |
SOPReasonForExport | Sage.Accounting.SOP.SOPReasonForExport | The reason for exporting the despatched items |
Weight | Decimal | The weight of the items despatched |
Pieces | Int | The number of items despatched |
Notes | String | Notes for the despatch |
The tracking information is created as part of the Post method on the SOPDespatchReceiptAdjustment.
Tracking information for an existing despatch can be amended by filtering the SOPDespatchReceipts collection for the despatch you want to update using a unqiue SOPDespatchReceipt property value. The relevant tracking properties (see table above) can then be set on the SOPDespatchReceipt object. The tracking information is then updated by calling the Update method on the SOPDespatchReceipt object.
Code Examples
Below are examples on how to add tracking to a SOP Despatch. Although this example only demonstrates the despatch of one order, the example assumes that if you wish to despatch multiple orders that the same tracking information is used for every order. Amending how you loop through the PendingSOPDespatchReceipts will allow you to set unique tracking information for multiple despatches.
Here we are dealing with order number 0000005000
public void AddTrackingSOPDespatch()
{
// Instantiate the SOPAmendDespatchAdjustment object
Sage.Accounting.SOP.SOPDespatchReceiptAdjustment sopDespatchReceiptAdjustment =
new Sage.Accounting.SOP.SOPDespatchReceiptAdjustment();
try
{
// Specify that the SOPDespatchReceiptAdjustment is dealing with despatches not returns
sopDespatchReceiptAdjustment.DoDespatches = true;
// Specify that the SOPDespatchReceiptAdjustment is dealing with lines that are not set
// to ConfirmationIntentType of Confirm. This means that any free text lines set to
// be confirmed by the despatch free text lines option will not be despatched.
sopDespatchReceiptAdjustment.DoConfirmationOnly = false;
// Set the criteria that we wish to filter the goods awaiting despatch
// You can filter by: SingleCustomer, SingleWarehouse, OrderReturnNoFrom,
// OrderReturnNoTo, DocumentDateFrom, DocumentDateTo
// Here we are filtering by a customer.
sopDespatchReceiptAdjustment.OrderReturnNoFrom = "0000005000";
sopDespatchReceiptAdjustment.OrderReturnNoTo = "0000005000";
// Populate the DespatchReceiptItems with the items to be despatched
sopDespatchReceiptAdjustment.PopulateDespatchReceipts();
if (!sopDespatchReceiptAdjustment.DespatchReceiptItems.IsEmpty)
{
// Amend quantity to despatch
foreach (Sage.Accounting.SOP.SOPDespatchReceiptItem sopDespatchReceiptItem in
sopDespatchReceiptAdjustment.DespatchReceiptItems)
{
sopDespatchReceiptItem.Quantity = 2;
}
// Set the tracking information on the pending items
Sage.Accounting.SOP.PendingSOPDespatchReceipts pendingSOPDespatchReceipts =
sopDespatchReceiptAdjustment.PendingSOPDespatchReceipts;
// This is setting the same tracking information for all orders in the despatch.
foreach (Sage.Accounting.SOP.PendingSOPDespatchReceipt pendingSOPDespatchReceipt in
pendingSOPDespatchReceipts)
{
// Find and set Courier
Sage.Accounting.SystemManager.SYSCouriers couriers =
new Sage.Accounting.SystemManager.SYSCouriers();
couriers.Query.Filters.Add(new Filter(
PersistentSYSCourier.FIELD_NAME, FilterOperator.Equal, "New Courier"));
pendingSOPDespatchReceipt.SYSCourier = couriers.First;
// Find and set SOP Incoterm
Sage.Accounting.SOP.SOPIncoterms sopIncoterms =
new Sage.Accounting.SOP.SOPIncoterms();
sopIncoterms.Query.Filters.Add(new Filter(
PersistentSOPIncoterm.FIELD_NAME, FilterOperator.Equal, "FAS - Free Alongside Ship [2020]"));
pendingSOPDespatchReceipt.SOPIncoterm = sopIncoterms.First;
// Find and set SOP Reason for Export
Sage.Accounting.SOP.SOPReasonForExports sopReasonForExports =
new Sage.Accounting.SOP.SOPReasonForExports();
sopReasonForExports.Query.Filters.Add(new Filter(
PersistentSOPReasonForExport.FIELD_NAME, FilterOperator.Equal, "Gift"));
pendingSOPDespatchReceipt.SOPReasonForExport = sopReasonForExports.First;
// Set additional tracking information
pendingSOPDespatchReceipt.Pieces = 2;
pendingSOPDespatchReceipt.ConsignmentNo = "123";
pendingSOPDespatchReceipt.Weight = 1;
pendingSOPDespatchReceipt.Notes = "Handle with care.";
}
if (!sopDespatchReceiptAdjustment.DespatchReceiptItems.IsEmpty)
{
sopDespatchReceiptAdjustment.Post();
}
else
{
System.Diagnostics.Debug.WriteLine("There are no items to despatch.");
}
}
}
catch (System.Exception Ex)
{
System.Diagnostics.Debug.WriteLine(Ex.Message);
}
finally
{
sopDespatchReceiptAdjustment.Dispose();
sopDespatchReceiptAdjustment = null;
}
}
Public Sub AddTrackingSOPDespatch()
' Instantiate the SOPAmendDespatchAdjustment object
Dim sopDespatchReceiptAdjustment As Sage.Accounting.SOP.SOPDespatchReceiptAdjustment =
New Sage.Accounting.SOP.SOPDespatchReceiptAdjustment()
Try
' Specify that the SOPDespatchReceiptAdjustment is dealing with despatches not returns
sopDespatchReceiptAdjustment.DoDespatches = True
' Specify that the SOPDespatchReceiptAdjustment is dealing with lines that are not set
' to ConfirmationIntentType of Confirm. This means that any free text lines set to
' be confirmed by the despatch free text lines option will not be despatched.
sopDespatchReceiptAdjustment.DoConfirmationOnly = False
' Set the criteria that we wish to filter the goods awaiting despatch
' You can filter by: SingleCustomer, SingleWarehouse, OrderReturnNoFrom,
' OrderReturnNoTo, DocumentDateFrom, DocumentDateTo
' Here we are filtering by a customer.
sopDespatchReceiptAdjustment.OrderReturnNoFrom = "0000005000"
sopDespatchReceiptAdjustment.OrderReturnNoTo = "0000005000"
' Populate the DespatchReceiptItems with the items to be despatched
sopDespatchReceiptAdjustment.PopulateDespatchReceipts()
If Not sopDespatchReceiptAdjustment.DespatchReceiptItems.IsEmpty Then
' Amend quantity to despatch
For Each sopDespatchReceiptItem As Sage.Accounting.SOP.SOPDespatchReceiptItem In
sopDespatchReceiptAdjustment.DespatchReceiptItems
sopDespatchReceiptItem.Quantity = 2
Next
' Set the tracking information on the pending items
Dim pendingSOPDespatchReceipts As Sage.Accounting.SOP.PendingSOPDespatchReceipts =
sopDespatchReceiptAdjustment.PendingSOPDespatchReceipts
For Each pendingSOPDespatchReceipt As Sage.Accounting.SOP.PendingSOPDespatchReceipt In
pendingSOPDespatchReceipts
' Find and set Courier
Dim couriers As Sage.Accounting.SystemManager.SYSCouriers =
New Sage.Accounting.SystemManager.SYSCouriers()
couriers.Query.Filters.Add(New Filter(
PersistentSYSCourier.FIELD_NAME, FilterOperator.Equal, "New Courier"))
pendingSOPDespatchReceipt.SYSCourier = couriers.First
' Find and set SOP Incoterm
Dim sopIncoterms As Sage.Accounting.SOP.SOPIncoterms =
New Sage.Accounting.SOP.SOPIncoterms()
sopIncoterms.Query.Filters.Add(New Filter(
PersistentSOPIncoterm.FIELD_NAME, FilterOperator.Equal, "FAS - Free Alongside Ship [2020]"))
pendingSOPDespatchReceipt.SOPIncoterm = sopIncoterms.First
' Find and set SOP Reason for Export
Dim sopReasonForExports As Sage.Accounting.SOP.SOPReasonForExports =
New Sage.Accounting.SOP.SOPReasonForExports()
sopReasonForExports.Query.Filters.Add(New Filter(
PersistentSOPReasonForExport.FIELD_NAME, FilterOperator.Equal, "Gift"))
pendingSOPDespatchReceipt.SOPReasonForExport = sopReasonForExports.First
' Set additional tracking information
pendingSOPDespatchReceipt.Pieces = 2
pendingSOPDespatchReceipt.ConsignmentNo = "123"
pendingSOPDespatchReceipt.Weight = 1
pendingSOPDespatchReceipt.Notes = "Handle with care."
Next
If Not sopDespatchReceiptAdjustment.DespatchReceiptItems.IsEmpty Then
sopDespatchReceiptAdjustment.Post()
Else
System.Diagnostics.Debug.WriteLine("There are no items to despatch.")
End If
End If
Catch Ex As System.Exception
System.Diagnostics.Debug.WriteLine(Ex.Message)
Finally
sopDespatchReceiptAdjustment.Dispose()
sopDespatchReceiptAdjustment = Nothing
End Try
End Sub
There may be occasions where the tracking information requires amendment. Below are code examples of how to amend tracking information for an existing SOP Despatch. Here we are dealing with the first despatch for order number 0000005505.
public void AmendTrackingSOPDespatch()
{
// Instantiate the SOPDespatchReceipts and SOPDespatchReceipt objects
Sage.Accounting.SOP.SOPDespatchReceipts sopDespatchReceipts =
new Sage.Accounting.SOP.SOPDespatchReceipts();
Sage.Accounting.SOP.SOPDespatchReceipt sopDespatchReceipt =
new Sage.Accounting.SOP.SOPDespatchReceipt();
try
{
// Fetch and set the first individual despatch from the collection using the document number.
sopDespatchReceipts.Query.Filters.Add(new Filter(
Sage.Accounting.SOP.SOPDespatchReceipt.FIELD_DOCUMENTNO, "0000005505"));
sopDespatchReceipt = sopDespatchReceipts.First;
// Find and set Courier
Sage.Accounting.SystemManager.SYSCouriers couriers =
new Sage.Accounting.SystemManager.SYSCouriers();
couriers.Query.Filters.Add(new Filter(
PersistentSYSCourier.FIELD_NAME, FilterOperator.Equal, "New Courier"));
sopDespatchReceipt.SYSCourier = couriers.First;
// Find and set SOP Incoterm
Sage.Accounting.SOP.SOPIncoterms sopIncoterms =
new Sage.Accounting.SOP.SOPIncoterms();
sopIncoterms.Query.Filters.Add(new Filter(
PersistentSOPIncoterm.FIELD_NAME, FilterOperator.Equal, "FAS - Free Alongside Ship [2020]"));
sopDespatchReceipt.SOPIncoterm = sopIncoterms.First;
// Find and set SOP Reason for Export
Sage.Accounting.SOP.SOPReasonForExports sopReasonForExports =
new Sage.Accounting.SOP.SOPReasonForExports();
sopReasonForExports.Query.Filters.Add(new Filter(
PersistentSOPReasonForExport.FIELD_NAME, FilterOperator.Equal, "Gift"));
sopDespatchReceipt.SOPReasonForExport = sopReasonForExports.First;
// Set additional tracking information
sopDespatchReceipt.Pieces = 2;
sopDespatchReceipt.ConsignmentNo = "123";
sopDespatchReceipt.Weight = 1;
sopDespatchReceipt.Notes = "Handle with care.";
sopDespatchReceipt.Update();
}
catch (System.Exception Ex)
{
System.Diagnostics.Debug.WriteLine(Ex.Message);
}
finally
{
sopDespatchReceipts.Dispose();
sopDespatchReceipt.Dispose();
}
}
Public Sub AmendTrackingSOPDespatch()
' Instantiate the SOPDespatchReceipts and SOPDespatchReceipt objects
Dim sopDespatchReceipts As Sage.Accounting.SOP.SOPDespatchReceipts =
New Sage.Accounting.SOP.SOPDespatchReceipts()
Dim sopDespatchReceipt As Sage.Accounting.SOP.SOPDespatchReceipt =
New Sage.Accounting.SOP.SOPDespatchReceipt()
Try
' Fetch and set the first individual despatch from the collection using the document number
sopDespatchReceipts.Query.Filters.Add(New Filter(
Sage.Accounting.SOP.SOPDespatchReceipt.FIELD_DOCUMENTNO, "0000005505"))
sopDespatchReceipt = sopDespatchReceipts.First
' Find and set Courier
Dim couriers As Sage.Accounting.SystemManager.SYSCouriers =
New Sage.Accounting.SystemManager.SYSCouriers()
couriers.Query.Filters.Add(New Filter(
PersistentSYSCourier.FIELD_NAME, FilterOperator.Equal, "New Courier"))
sopDespatchReceipt.SYSCourier = couriers.First
' Find and set SOP Incoterm
Dim sopIncoterms As Sage.Accounting.SOP.SOPIncoterms =
New Sage.Accounting.SOP.SOPIncoterms()
sopIncoterms.Query.Filters.Add(New Filter(
PersistentSOPIncoterm.FIELD_NAME, FilterOperator.Equal, "FAS - Free Alongside Ship [2020]"))
sopDespatchReceipt.SOPIncoterm = sopIncoterms.First
' Find and set SOP Reason for Export
Dim sopReasonForExports As Sage.Accounting.SOP.SOPReasonForExports =
New Sage.Accounting.SOP.SOPReasonForExports()
sopReasonForExports.Query.Filters.Add(New Filter(
PersistentSOPReasonForExport.FIELD_NAME, FilterOperator.Equal, "Gift"))
sopDespatchReceipt.SOPReasonForExport = sopReasonForExports.First
' Set additional tracking information
sopDespatchReceipt.Pieces = 2
sopDespatchReceipt.ConsignmentNo = "123"
sopDespatchReceipt.Weight = 1
sopDespatchReceipt.Notes = "Handle with care."
sopDespatchReceipt.Update()
Catch Ex As System.Exception
System.Diagnostics.Debug.WriteLine(Ex.Message)
Finally
sopDespatchReceipts.Dispose()
sopDespatchReceipt.Dispose()
End Try
End Sub
A collection of couriers stored in the system which can be added to the tracking information for a despatched order.
The main objects used when adding a new courier are the Sage.Accounting.SystemManager.SYSCouriers and Sage.Accounting.SystemManager.SYSCourier objects which can be instantiated using the new keyword. The SYSCourier object allows the setting of the indivdual courier properties. The new SYSCourier is then added to the SYSCouriers collection where the Update method is used to update the entire collection with the new SYSCourier. This allows additional validation, such as checking for duplicate name, to be carried out.
Below are code examples of how to create a new courier. This example demonstrates how to create a new Courier which can be added to the tracking information for a despatched order.
Here we assume that a Courier with the name "Test Courier" does not already exist in the database.
private void CreateNewSysCourier()
{
// Instantiate the SYSCouriers and SYSCourier objects
Sage.Accounting.SystemManager.SYSCouriers couriers =
new Sage.Accounting.SystemManager.SYSCouriers();
Sage.Accounting.SystemManager.SYSCourier courier =
new Sage.Accounting.SystemManager.SYSCourier();
// Mandatory
courier.Name = "Test Courier";
// Optional - isDefault defaults to false if omitted
courier.WebSite = "www.test_courier.com";
courier.TrackingURL = "www.test_courier_tracking.com";
courier.IsDefault = false;
// Add new Courier to collection and update collection
couriers.Add(courier);
couriers.Update();
couriers.Dispose();
courier.Dispose();
}
Private Sub CreateNewSysCourier()
' Instantiate the SYSCouriers and SYSCourier objects
Dim couriers As Sage.Accounting.SystemManager.SYSCouriers =
New Sage.Accounting.SystemManager.SYSCouriers()
Dim courier As Sage.Accounting.SystemManager.SYSCourier =
New Sage.Accounting.SystemManager.SYSCourier()
' Mandatory
courier.Name = "Test Courier"
' Optional - isDefault defaults to false if omitted
courier.WebSite = "www.test_courier.com"
courier.TrackingURL = "www.test_courier_tracking.com"
courier.IsDefault = False
' Add new Courier to collection and update collection
couriers.Add(courier)
couriers.Update()
couriers.Dispose()
courier.Dispose()
End Sub
A collection of Incoterms stored in the system which can be added to the the tracking information for a despatched order. These are used to define the payment and management responsibilities for various delivery activities of the seller and buyer.
The main objects used when adding an additional Incoterm to the system are the Sage.Accounting.SOP.SOPIncoterms and Sage.Accounting.SOP.SOPIncoterm objects which can be instantiated using the new keyword. The SOPIncoterm object allows the setting of indivdual Incoterm properties. The new SOPIncoterm is then added to the SOPIncoterms collection where the Update method is used to update the entire collection with the new SOPIncoterm. This allows additional validation, such as checking for duplicate name, to be carried out.
Code Examples
This example demonstrates how to create a new SOP Incoterm which can be added to the tracking information for a despatched order. Here we assume that a SOP Incoterm with the name "Test Incoterm [2020]" does not already exist in the database:
private void CreateIncoterm()
{
// Instantiate the SOPIncoterms and SOPIncoterm objects
Sage.Accounting.SOP.SOPIncoterms sopIncoterms =
new Sage.Accounting.SOP.SOPIncoterms();
Sage.Accounting.SOP.SOPIncoterm sopIncoterm =
new Sage.Accounting.SOP.SOPIncoterm();
//Mandatory
sopIncoterm.Name = "Test Incoterm [2020]";
//Optional - isDefault defaults to false if omitted
sopIncoterm.IsDefault = false;
// Add new SOP Incoterm to collection and update collection
sopIncoterms.Add(sopIncoterm);
sopIncoterms.Update();
sopIncoterms.Dispose();
sopIncoterm.Dispose();
}
Private Sub CreateIncoterm()
' Instantiate the SOPIncoterms and SOPIncoterm objects
Dim sopIncoterms As Sage.Accounting.SOP.SOPIncoterms =
New Sage.Accounting.SOP.SOPIncoterms()
Dim sopIncoterm As Sage.Accounting.SOP.SOPIncoterm =
New Sage.Accounting.SOP.SOPIncoterm()
' Mandatory
sopIncoterm.Name = "Test Incoterm [2020]"
' Optional - isDefault defaults to false if omitted
sopIncoterm.IsDefault = False
' Add new SOP Incoterm to collection and update collection
sopIncoterms.Add(sopIncoterm)
sopIncoterms.Update()
sopIncoterms.Dispose()
sopIncoterm.Dispose()
End Sub
A collection of export reasons stored in the system which can be added to the the tracking information for a despatched order.
The main objects used when adding an additional reason for export to the system are the Sage.Accounting.SOP.SOPReasonForExports and Sage.Accounting.SOP.SOPReasonForExport objects which can be instantiated using the new keyword. The SOPReasonForExport object allows the setting of indivdual reason for export properties. The new SOPReasonForExport is then added to the SOPReasonForExports collection where the Update method is used to update the entire collection with the new SOPReasonForExport. This allows additional validation, such as checking for duplicate name, to be carried out.
Code Examples
This example demonstrates how to create a new SOP Reason for Export which can be added to the tracking information for a despatched order. Here we assume that a SOP Reason for Export with the name "Test Reason for Export" does not already exist in the database:
private void CreateReasonForExport()
{
// Instantiate the SOPReasonForExports and SOPReasonForExport objects
Sage.Accounting.SOP.SOPReasonForExports sopReasonForExports =
new Sage.Accounting.SOP.SOPReasonForExports();
Sage.Accounting.SOP.SOPReasonForExport sopReasonForExport =
new Sage.Accounting.SOP.SOPReasonForExport();
//Mandatory
sopReasonForExport.Name = "Test Reason for Export";
//Optional - isDefault defaults to false if omitted
sopReasonForExport.IsDefault = false;
// Add new SOP Reason for Export to collection and update collection
sopReasonForExports.Add(sopReasonForExport);
sopReasonForExports.Update();
sopReasonForExports.Dispose();
sopReasonForExport.Dispose();
}
Private Sub CreateReasonForExport()
' Instantiate the SOPReasonForExports and SOPReasonForExport objects
Dim sopReasonForExports As Sage.Accounting.SOP.SOPReasonForExports =
New Sage.Accounting.SOP.SOPReasonForExports()
Dim sopReasonForExport As Sage.Accounting.SOP.SOPReasonForExport =
New Sage.Accounting.SOP.SOPReasonForExport()
' Mandatory
sopReasonForExport.Name = "Test Reason for Export"
' Optional - isDefault defaults to false if omitted
sopReasonForExport.IsDefault = False
' Add new SOP Reason for Export to collection and update collection
sopReasonForExports.Add(sopReasonForExport)
sopReasonForExports.Update()
sopReasonForExports.Dispose()
sopReasonForExport.Dispose()
End Sub
What has been updated?
- The VB.net example for "How to post a purchase batch invoice transaction" now uses Sage.Accounting.PurchaseLedger.PendingPurchaseBatchEntriesFactory.Factory.FetchAllBatches() to match the C# example, rather than Sage.Accounting.PurchaseLedger.PurchaseModuleFactory.Factory.Fetch().Batches:
' Local storage for the batch entry header
Private batchEntry As Sage.Accounting.PurchaseLedger.PendingPurchaseUnspecifiedBatchEntry = Nothing
' Local storage for the purchase invoice instrument
Private purchaseInvoiceInstrument As Sage.Accounting.PurchaseLedger.PurchaseInvoiceInstrument = Nothing
Private Sub Create_Batch()
Try
Create_Batch_Header()
' Update the batch header
Update_Batch_Header()
' Now the header has been updated we can get the specified entry
Dim specifiedEntry As Sage.Accounting.PurchaseLedger.PendingPurchaseInvoiceBatchEntry =
CType(Me.batchEntry.SpecifiedEntry,
Sage.Accounting.PurchaseLedger.PendingPurchaseInvoiceBatchEntry)
' From the specified entry we can create a new purchase invoice batch item
Dim invoiceBatchItem As Sage.Accounting.PurchaseLedger.PendingPurchaseInvoiceBatchItem =
CType(specifiedEntry.CreateBatchItem(),
Sage.Accounting.PurchaseLedger.PendingPurchaseInvoiceBatchItem)
' We can get the purchase invoice instrument from the invoice batch item
Me.purchaseInvoiceInstrument = invoiceBatchItem.Instrument
' Suppress warnings that we do not wish to show
Suppress_Warnings()
' Set the first invoice details
Set_Invoice_Details()
' Update the invoice item and specified entry
Update_InvoiceItem_and_SpecifiedEntry(invoiceBatchItem, specifiedEntry)
' From the specified entry we can create a second purchase invoice batch item
invoiceBatchItem =
CType(specifiedEntry.CreateBatchItem(),
Sage.Accounting.PurchaseLedger.PendingPurchaseInvoiceBatchItem)
' We can get the purchase invoice instrument from the invoice batch item
Me.purchaseInvoiceInstrument = invoiceBatchItem.Instrument
' Suppress warnings that we do not wish to show
Suppress_Warnings()
' Set the second invoice details
Set_Invoice2_Details()
' Update the invoice item and specified entry
Update_InvoiceItem_and_SpecifiedEntry(invoiceBatchItem, specifiedEntry)
' The actual batch count and value have changed on the header so we need
' to commit these changes to the database
Update_Batch_Header()
' Optional: At this point we can commit the batch which will
' update the entries to the database.
Commit_Batch()
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
End Try
End Sub
Private Sub Create_Batch_Header()
' Create a new batch entry
Dim batchEntries As Sage.Accounting.PurchaseLedger.PendingPurchaseUnspecifiedBatchEntries =
Sage.Accounting.PurchaseLedger.PendingPurchaseUnspecifiedBatchEntriesFactory.Factory.FetchAllBatches()
Me.batchEntry =
CType(batchEntries.AddNew(),
Sage.Accounting.PurchaseLedger.PendingPurchaseUnspecifiedBatchEntry)
' Set the batch title
Me.batchEntry.BatchTitle = "New Invoice Batch"
' Set the batch type
Me.batchEntry.BatchType =
Sage.Accounting.TradingAccountEntryTypeEnum.TradingAccountEntryTypeInvoice
' Set the total number of items we are expecting in the batch.
Me.batchEntry.ExpectedBatchItemCount = 2 ' maximum 999
' Set the expected batch total value.
Me.batchEntry.ExpectedBatchTotal = 234.57D
' Set additional information
Me.batchEntry.CreationDate = Sage.Common.Clock.Today
Me.batchEntry.BatchUserName = Sage.Accounting.Application.ActiveUserName
Me.batchEntry.UserNumber = Sage.Accounting.Application.ActiveUserNumber
End Sub
Private Sub Update_Batch_Header()
' Update the header
Me.batchEntry.Update()
End Sub
Private Sub Suppress_Warnings()
' Suppress the warnings that we do not want to show
' allow supplier to be over their credit limit
Me.purchaseInvoiceInstrument.SuppressExceedsCreditLimitException = True
' allow the batch to be posted with zero net and tax values
Me.purchaseInvoiceInstrument.SuppressZeroGoodsTaxException = True
End Sub
Private Sub Set_Invoice_Details()
' Get the supplier we wish to create an invoice for
Dim supplier As Sage.Accounting.PurchaseLedger.Supplier =
Sage.Accounting.PurchaseLedger.SupplierFactory.Factory.Fetch("ATL001")
' Set the supplier on the invoice instrument
Me.purchaseInvoiceInstrument.Supplier = supplier
' Set the transaction references
Me.purchaseInvoiceInstrument.InstrumentNo = "INV001"
Me.purchaseInvoiceInstrument.SecondReferenceNo = "SAGE1234"
' Set the transaction date
Me.purchaseInvoiceInstrument.InstrumentDate = Sage.Common.Clock.Today
' Set the net value on the invoice instrument
Me.purchaseInvoiceInstrument.NetValue = 100D
' Optional: This sets the authorisation flag to be not required
Me.purchaseInvoiceInstrument.Authorised =
Sage.Accounting.AuthorisationTypeEnum.AuthorisationTypeNotRequired
End Sub
Private Sub Set_Invoice2_Details()
' Get the supplier we wish to create an invoice for
Dim supplier As Sage.Accounting.PurchaseLedger.Supplier =
Sage.Accounting.PurchaseLedger.SupplierFactory.Factory.Fetch("BGT001")
' Set the supplier on the invoice instrument
Me.purchaseInvoiceInstrument.Supplier = supplier
' Set the transaction references
Me.purchaseInvoiceInstrument.InstrumentNo = "INV002"
Me.purchaseInvoiceInstrument.SecondReferenceNo = "SAGE1235"
' Set the transaction date
Me.purchaseInvoiceInstrument.InstrumentDate = Sage.Common.Clock.Today
' Set the net value on the invoice instrument
Me.purchaseInvoiceInstrument.NetValue = 100D
' Optional: This sets the authorisation flag to be not required
Me.purchaseInvoiceInstrument.Authorised =
Sage.Accounting.AuthorisationTypeEnum.AuthorisationTypeNotRequired
End Sub
Private Sub Update_InvoiceItem_and_SpecifiedEntry(
ByVal invoiceBatchItem As Sage.Accounting.PurchaseLedger.PendingPurchaseInvoiceBatchItem,
ByVal specifiedEntry As Sage.Accounting.PurchaseLedger.PendingPurchaseInvoiceBatchEntry)
' Save the item, this copies the data from the instrument into the
' items dataobject.
' This method also updates the actual batch count and value for the batch entry
invoiceBatchItem.SaveItem()
' Add the invoice batch item to the entry
specifiedEntry.PurchaseBatchItems.Add(invoiceBatchItem)
' Update the invoice batch item
invoiceBatchItem.Update()
' Update the specified entry
specifiedEntry.Update()
End Sub
Private Sub Commit_Batch()
' This method will post the batch entries to the database
Me.batchEntry.Commit()
End Sub
- The content of the "How to get a Sage account and scope" has now been amended to reflect requesting Cloud ID Credentials in line with technology changes and deprecation.