.NET wrapper for the Sage One Accounting API
A .Net client library for using the Sage One Accounting API. Read more about the API at: https://accounting.sageone.co.za/Marketing/DeveloperProgram.aspx
This project is under active development. If you wish to contribute, please follow the existing coding conventions and submit a pull request. For more information and usage examples visit http://www.mythicalmanmoth.com/2015/09/08/net-wrapper-sage-one-accounting-api/
Currently, the following objects/methods are available in the library:
GetAll | Get | Save | Delete | Get w/System Accounts | Get By Category | Get Current | Has Activity | Calculate | ||
---|---|---|---|---|---|---|---|---|---|---|
Account | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
||||
Account Category | ![]() |
![]() |
![]() |
![]() |
Account Note | ![]() |
![]() |
![]() |
![]() |
|
Account Receipt | ![]() |
![]() |
Additional Price List | ![]() |
![]() |
![]() |
![]() |
|||
Additional Item Price | ![]() |
![]() |
![]() |
![]() |
||||||
Asset | ![]() |
![]() |
![]() |
![]() |
||||||
Asset Category | ![]() |
![]() |
![]() |
![]() |
||||||
Asset Locations | ![]() |
![]() |
![]() |
![]() |
||||||
Asset Notes | ![]() |
![]() |
![]() |
![]() |
||||||
Bank Account | ![]() |
![]() |
![]() |
![]() |
||||||
Bank Account Category | ![]() |
![]() |
![]() |
![]() |
||||||
Customer | ![]() |
![]() |
![]() |
![]() |
||||||
Customer Category | ![]() |
![]() |
![]() |
![]() |
||||||
Customer Notes | ![]() |
![]() |
![]() |
![]() |
||||||
Company | ![]() |
![]() |
![]() |
|||||||
Item | ![]() |
![]() |
![]() |
![]() |
||||||
Item Movement | ![]() |
|||||||||
Item Notes | ![]() |
![]() |
![]() |
![]() |
||||||
Item Category | ![]() |
![]() |
![]() |
![]() |
||||||
Journal Entry | ![]() |
![]() |
![]() |
![]() |
![]() |
|||||
Purchase Order | ![]() |
![]() |
![]() |
![]() |
||||||
Sales Representative | ![]() |
![]() |
![]() |
![]() |
![]() |
|||||
Supplier | ![]() |
![]() |
![]() |
![]() |
||||||
Supplier Category | ![]() |
![]() |
![]() |
![]() |
||||||
Supplier Invoice | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
||||
Tax Invoice | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
||||
Tax Type | ![]() |
![]() |
![]() |
If you need to create test data for your developer account, take a look at the tests inside SampleDataCreate.cs
Code Examples
Get a list of Sage One Customers:
public void GetAllCustomers()
{
var api = new ApiRequest(Username, Password, Apikey, CompanyId);
var customers = api.CustomerRequest.Get();
}
Get a Sage One Customer with specific email address (OData query):
public void GetCustomerByEmail()
{
string filter = "Email eq 'info@contoso.com'";
var api = new ApiRequest(Username, Password, Apikey, CompanyId);
var customers = api.CustomerRequest.Get(filter);
}
Get a Sage One Customer by id:
public void GetCustomer()
{
int customerId = 12345;
var api = new ApiRequest(Username, Password, Apikey, CompanyId);
var customer = api.CustomerRequest.Get(customerId);
}
Create a new Sage One Customer:
public void SaveCustomer()
{
var api = new ApiRequest(Username, Password, Apikey, CompanyId);
var customer = new Customer
{
Name = "Mr. David R. Robinett”,
AcceptsElectronicInvoices = true,
Active = true,
AutoAllocateToOldestInvoice = true,
Balance = 0,
ContactName = "Mr. David R. Robinett”,
DeliveryAddress01 = "Pappelallee 6667”,
DeliveryAddress02 = "Solingen”,
DeliveryAddress03 = "Nordrhein-Westfalen”,
DeliveryAddress04 = "42651”,
DeliveryAddress05 = "Germany”,
CommunicationMethod = 1,
PostalAddress01 = "Pappelallee 6667”,
PostalAddress02 = "Solingen”,
PostalAddress03 = "Nordrhein-Westfalen”,
PostalAddress04 = "42651”,
PostalAddress05 = "Germany”,
Telephone = "238-555-0100”,
SalesRepresentativeId = null
};
api.CustomerRequest.Save(customer);
}
Delete a new Sage One Customer:
public void Delete()
{
int customerId = 12345;
var api = new ApiRequest(Username, Password, Apikey, CompanyId);
var result = api.CustomerRequest.Delete(customerId);
}
Create Sage One Tax Invoice:
public void CreateInvoice()
{
var api = new ApiRequest(Username, Password, Apikey, CompanyId);
var customerId = 0;
var salesRepId = 0;
var itemId = 0;
var taxTypeId = 0;
TaxInvoice invoice = new TaxInvoice();
var customer = api.CustomerRequest.Get(customerId);
var salesRep = api.SalesRepresentativeRequest.Get(salesRepId);
// Must set both CustomerId and Customer in order to work
invoice.CustomerId = customerId;
invoice.Customer = customer;
// Must set both SalesRepresentativeId and SalesRepresentative in order to work
invoice.SalesRepresentativeId = salesRepId;
invoice.SalesRepresentative = salesRep;
invoice.Date = DateTime.Now;
invoice.DueDate = new DateTime(2016, 01, 01);
invoice.Lines = new List<CommercialDocumentLine>();
var line1 = new CommercialDocumentLine
{
SelectionId = itemId, // This must be an item or account id
TaxTypeId = taxTypeId, // Use TaxTypeRequest to get list of Tax Types
LineType = 0, // 0=Item,1=Account
Quantity = 1,
UnitPriceExclusive = 390,
UnitPriceInclusive = 390,
DiscountPercentage = 0
};
invoice.Lines.Add(line1);
var newTaxInvoice = api.TaxInvoiceRequest.Save(invoice);
}
This project borrowed heavily from the concepts used by Scott Schluer and his .Net Wrapper for the Highrise Api