Payables/Receivables invoices
This section contains code samples related to payables and receivables invoices.
Example Code
Load all payables invoices in a given fiscalyear.
[TestMethod]
public void REST_Payables_invoices_all_load()
{
state = new ErrorState { passed = false };
List invoices = GET.payables_invoices(manager);
if (invoices.Count > 0)
{
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static List<Invoice> payables_invoices(Manager manager)
{
var currentClient = manager.getCurrentClient();
var currentFiscalYear = manager.getCurrentFiscalYear();
List<Invoice> invoices = null;
string request = "clients/{0}/fiscalYears/{1}/payables/invoices";
var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, currentFiscalYear.id)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
invoices = JsonConvert.DeserializeObject<List<Invoice>>(response.Content.ReadAsStringAsync().Result);
}
return invoices;
}
}
class GET:
@staticmethod
def payablesInvoices(manager):
_currentClient = manager.getCurrentClient()
_currentFiscalyear = manager.getCurrentFiscalyear()
url = '{0}clients/{1}/fiscalYears/{2}/payables/Invoices'.format(manager.baseURL(),
_currentClient['id'],
_currentFiscalyear['id'])
url = url + '?onlyOpen=true'
response = requests.get(url, headers = manager.headers())
if response.status_code == 200:
return response.json()
else:
print(response.content())
return None
{
"id": "32e93480-5575-40c4-8093-54110312c082",
"authorizerFID": 21,
"partyFID": 1,
"payMethodFID": 373,
"payTermFID": 9,
"vatFID": -1,
"personRoleFID": 2,
"invoiceDate": "2019-06-12T00:00:00",
"dueDate": "2019-07-12T00:00:00",
"modifyDate": "2019-06-12T09:02:07.31",
"invoiceNum": 1109,
"reminderLevel": 0,
"freeInvoiceNum": "RI_3810",
"text": "Recivables Invoice",
"PayslipCode": "",
"totalAmount": 4000.0,
"totalAmountFC": 4000.0,
"exchangeRate": 1.0,
"IsAuthorized": true,
"noReminders": false,
"Remarks": "",
"partyNum": 1019,
"partyName": "Bucherer AG",
"partyShortName": "BucLuz",
"payTermCode": "30T",
"accountCode": "1100",
"currencyCode": "CHF",
"balance": 4000.0,
"balanceFC": 4000.0,
"barCode": "",
"currentReminderLevel": 0,
"hasDocument": 0,
"currentReminderDate": "1753-01-01T00:00:00",
"paymentPostings": [],
"transaction": {
"id": "32e93480-5575-40c4-8093-54110312c082",
"fiscalYearFID": 55,
"userFID": 21,
"transactionTypeFID": 3,
"docType": "",
"docNum": 582,
"docDate": "2019-06-12T00:00:00",
"modifyDate": "2019-06-12T09:02:06.903",
"isConfirmed": true,
"numRangeFID": 265,
"postings": [
{
"id": "a351a126-f6e9-45ba-b981-d85e003d54be",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 20,
"contraAccountFID": 71,
"vatFID": -1,
"vatAccountFID": -1,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 4000.0,
"fcAmount": 4000.0,
"exchangeRate": 1.0,
"vatAmount": 0.0,
"vatFcAmount": 0.0,
"vatPercent": 0.0,
"vatQuote": 0.0,
"text": "Recivables Invoice Posting #1",
"freeCode": "Posting Free",
"isDebit": true,
"isInclusive": false,
"isInvisible": false,
"postingIndex": 1,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
},
{
"id": "a3c9ad2a-c7df-4a50-98b5-5edb7d375031",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 71,
"contraAccountFID": 20,
"vatFID": 9,
"vatAccountFID": 51,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 3714.02,
"fcAmount": 3714.02,
"exchangeRate": 1.0,
"vatAmount": 285.98,
"vatFcAmount": 285.98,
"vatPercent": 7.7,
"vatQuote": 100.0,
"text": "Recivables Invoice Posting #2 (VAT posting)",
"freeCode": "",
"isDebit": false,
"isInclusive": true,
"isInvisible": false,
"postingIndex": 2,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
}
]
}
}
Load all payables invoices in a given fiscalyear, which have not yet been paid.
[TestMethod]
public void REST_Payables_invoices_open_load()
{
state = new ErrorState { passed = false };
List invoices = GET.payables_invoices_open(manager);
state.passed = false;
if (invoices.Count > 0)
{
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class Load
{
public static List<Invoice> payables_invoices_open(Manager manager)
{
var currentClient = manager.getCurrentClient();
var currentFiscalYear = manager.getCurrentFiscalYear();
List<Invoice> invoices = null;
string request = "clients/{0}/fiscalYears/{1}/payables/invoices/open";
var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, currentFiscalYear.id)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
invoices = JsonConvert.DeserializeObject<List<Invoice>>(response.Content.ReadAsStringAsync().Result);
}
return invoices;
}
}
class Load:
@staticmethod
def payablesInvoices(manager):
_currentClient = manager.getCurrentClient()
_currentFiscalyear = manager.getCurrentFiscalyear()
url = '{0}clients/{1}/fiscalYears/{2}/payables/Invoices'.format(manager.baseURL(),
_currentClient['id'],
_currentFiscalyear['id'])
url = url + '?onlyOpen=true'
response = requests.get(url, headers = manager.headers())
if response.status_code == 200:
return response.json()
else:
print(response.content())
return None
UNDER CONSTRUCTION
{
"id": "32e93480-5575-40c4-8093-54110312c082",
"authorizerFID": 21,
"partyFID": 1,
"payMethodFID": 373,
"payTermFID": 9,
"vatFID": -1,
"personRoleFID": 2,
"invoiceDate": "2019-06-12T00:00:00",
"dueDate": "2019-07-12T00:00:00",
"modifyDate": "2019-06-12T09:02:07.31",
"invoiceNum": 1109,
"reminderLevel": 0,
"freeInvoiceNum": "RI_3810",
"text": "Recivables Invoice",
"PayslipCode": "",
"totalAmount": 4000.0,
"totalAmountFC": 4000.0,
"exchangeRate": 1.0,
"IsAuthorized": true,
"noReminders": false,
"Remarks": "",
"partyNum": 1019,
"partyName": "Bucherer AG",
"partyShortName": "BucLuz",
"payTermCode": "30T",
"accountCode": "1100",
"currencyCode": "CHF",
"balance": 4000.0,
"balanceFC": 4000.0,
"barCode": "",
"currentReminderLevel": 0,
"hasDocument": 0,
"currentReminderDate": "1753-01-01T00:00:00",
"paymentPostings": [],
"transaction": {
"id": "32e93480-5575-40c4-8093-54110312c082",
"fiscalYearFID": 55,
"userFID": 21,
"transactionTypeFID": 3,
"docType": "",
"docNum": 582,
"docDate": "2019-06-12T00:00:00",
"modifyDate": "2019-06-12T09:02:06.903",
"isConfirmed": true,
"numRangeFID": 265,
"postings": [
{
"id": "a351a126-f6e9-45ba-b981-d85e003d54be",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 20,
"contraAccountFID": 71,
"vatFID": -1,
"vatAccountFID": -1,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 4000.0,
"fcAmount": 4000.0,
"exchangeRate": 1.0,
"vatAmount": 0.0,
"vatFcAmount": 0.0,
"vatPercent": 0.0,
"vatQuote": 0.0,
"text": "Recivables Invoice Posting #1",
"freeCode": "Posting Free",
"isDebit": true,
"isInclusive": false,
"isInvisible": false,
"postingIndex": 1,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
},
{
"id": "a3c9ad2a-c7df-4a50-98b5-5edb7d375031",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 71,
"contraAccountFID": 20,
"vatFID": 9,
"vatAccountFID": 51,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 3714.02,
"fcAmount": 3714.02,
"exchangeRate": 1.0,
"vatAmount": 285.98,
"vatFcAmount": 285.98,
"vatPercent": 7.7,
"vatQuote": 100.0,
"text": "Recivables Invoice Posting #2 (VAT posting)",
"freeCode": "",
"isDebit": false,
"isInclusive": true,
"isInvisible": false,
"postingIndex": 2,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
}
]
}
}
Load all receivable invoices in a given fiscalyear.
[TestMethod]
public void REST_Receivables_invoices_load()
{
state = new ErrorState { passed = false };
List invoices = GET.receivables_invoices(manager);
if (invoices.Count > 0)
{
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static List<Invoice> receivables_invoices(Manager manager)
{
var currentClient = manager.getCurrentClient();
var currentFiscalYear = manager.getCurrentFiscalYear();
List<Invoice> invoices = null;
string request = "clients/{0}/fiscalYears/{1}/receivables/invoices";
var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, currentFiscalYear.id)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
invoices = JsonConvert.DeserializeObject<List<Invoice>>(response.Content.ReadAsStringAsync().Result);
}
return invoices;
}
}
Under construction
{
"id": "32e93480-5575-40c4-8093-54110312c082",
"authorizerFID": 21,
"partyFID": 1,
"payMethodFID": 373,
"payTermFID": 9,
"vatFID": -1,
"personRoleFID": 2,
"invoiceDate": "2019-06-12T00:00:00",
"dueDate": "2019-07-12T00:00:00",
"modifyDate": "2019-06-12T09:02:07.31",
"invoiceNum": 1109,
"reminderLevel": 0,
"freeInvoiceNum": "RI_3810",
"text": "Recivables Invoice",
"PayslipCode": "",
"totalAmount": 4000.0,
"totalAmountFC": 4000.0,
"exchangeRate": 1.0,
"IsAuthorized": true,
"noReminders": false,
"Remarks": "",
"partyNum": 1019,
"partyName": "Bucherer AG",
"partyShortName": "BucLuz",
"payTermCode": "30T",
"accountCode": "1100",
"currencyCode": "CHF",
"balance": 4000.0,
"balanceFC": 4000.0,
"barCode": "",
"currentReminderLevel": 0,
"hasDocument": 0,
"currentReminderDate": "1753-01-01T00:00:00",
"paymentPostings": [],
"transaction": {
"id": "32e93480-5575-40c4-8093-54110312c082",
"fiscalYearFID": 55,
"userFID": 21,
"transactionTypeFID": 3,
"docType": "",
"docNum": 582,
"docDate": "2019-06-12T00:00:00",
"modifyDate": "2019-06-12T09:02:06.903",
"isConfirmed": true,
"numRangeFID": 265,
"postings": [
{
"id": "a351a126-f6e9-45ba-b981-d85e003d54be",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 20,
"contraAccountFID": 71,
"vatFID": -1,
"vatAccountFID": -1,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 4000.0,
"fcAmount": 4000.0,
"exchangeRate": 1.0,
"vatAmount": 0.0,
"vatFcAmount": 0.0,
"vatPercent": 0.0,
"vatQuote": 0.0,
"text": "Recivables Invoice Posting #1",
"freeCode": "Posting Free",
"isDebit": true,
"isInclusive": false,
"isInvisible": false,
"postingIndex": 1,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
},
{
"id": "a3c9ad2a-c7df-4a50-98b5-5edb7d375031",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 71,
"contraAccountFID": 20,
"vatFID": 9,
"vatAccountFID": 51,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 3714.02,
"fcAmount": 3714.02,
"exchangeRate": 1.0,
"vatAmount": 285.98,
"vatFcAmount": 285.98,
"vatPercent": 7.7,
"vatQuote": 100.0,
"text": "Recivables Invoice Posting #2 (VAT posting)",
"freeCode": "",
"isDebit": false,
"isInclusive": true,
"isInvisible": false,
"postingIndex": 2,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
}
]
}
}
Load all receivable invoices in a given fiscalyear, which have not yet been paid.
[TestMethod]
public void REST_Payables_invoices_open_load()
{
state = new ErrorState { passed = false };
List invoices = GET.payables_invoices_open(manager);
state.passed = false;
if (invoices.Count > 0)
{
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static List<Invoice> receivables_invoices_open(Manager manager)
{
var currentClient = manager.getCurrentClient();
var currentFiscalYear = manager.getCurrentFiscalYear();
List<Invoice> invoices = null;
string request = "clients/{0}/fiscalYears/{1}/receivable/invoices/open";
var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, currentFiscalYear.id)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
invoices = JsonConvert.DeserializeObject<List<Invoice>>(response.Content.ReadAsStringAsync().Result);
}
return invoices;
}
}
under construction
UNDER CONSTRUCTION
{
"id": "32e93480-5575-40c4-8093-54110312c082",
"authorizerFID": 21,
"partyFID": 1,
"payMethodFID": 373,
"payTermFID": 9,
"vatFID": -1,
"personRoleFID": 2,
"invoiceDate": "2019-06-12T00:00:00",
"dueDate": "2019-07-12T00:00:00",
"modifyDate": "2019-06-12T09:02:07.31",
"invoiceNum": 1109,
"reminderLevel": 0,
"freeInvoiceNum": "RI_3810",
"text": "Recivables Invoice",
"PayslipCode": "",
"totalAmount": 4000.0,
"totalAmountFC": 4000.0,
"exchangeRate": 1.0,
"IsAuthorized": true,
"noReminders": false,
"Remarks": "",
"partyNum": 1019,
"partyName": "Bucherer AG",
"partyShortName": "BucLuz",
"payTermCode": "30T",
"accountCode": "1100",
"currencyCode": "CHF",
"balance": 4000.0,
"balanceFC": 4000.0,
"barCode": "",
"currentReminderLevel": 0,
"hasDocument": 0,
"currentReminderDate": "1753-01-01T00:00:00",
"paymentPostings": [],
"transaction": {
"id": "32e93480-5575-40c4-8093-54110312c082",
"fiscalYearFID": 55,
"userFID": 21,
"transactionTypeFID": 3,
"docType": "",
"docNum": 582,
"docDate": "2019-06-12T00:00:00",
"modifyDate": "2019-06-12T09:02:06.903",
"isConfirmed": true,
"numRangeFID": 265,
"postings": [
{
"id": "a351a126-f6e9-45ba-b981-d85e003d54be",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 20,
"contraAccountFID": 71,
"vatFID": -1,
"vatAccountFID": -1,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 4000.0,
"fcAmount": 4000.0,
"exchangeRate": 1.0,
"vatAmount": 0.0,
"vatFcAmount": 0.0,
"vatPercent": 0.0,
"vatQuote": 0.0,
"text": "Recivables Invoice Posting #1",
"freeCode": "Posting Free",
"isDebit": true,
"isInclusive": false,
"isInvisible": false,
"postingIndex": 1,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
},
{
"id": "a3c9ad2a-c7df-4a50-98b5-5edb7d375031",
"transactionFID": "32e93480-5575-40c4-8093-54110312c082",
"invoiceFID": "32e93480-5575-40c4-8093-54110312c082",
"accountFID": 71,
"contraAccountFID": 20,
"vatFID": 9,
"vatAccountFID": 51,
"costCenterFID": -1,
"postingTypeFID": 2,
"amount": 3714.02,
"fcAmount": 3714.02,
"exchangeRate": 1.0,
"vatAmount": 285.98,
"vatFcAmount": 285.98,
"vatPercent": 7.7,
"vatQuote": 100.0,
"text": "Recivables Invoice Posting #2 (VAT posting)",
"freeCode": "",
"isDebit": false,
"isInclusive": true,
"isInvisible": false,
"postingIndex": 2,
"partyNum": 0,
"freepartyNum": null,
"partyName": null,
"invoiceNum": 0,
"freeInvoiceNum": null,
"invoiceDate": "0001-01-01T00:00:00"
}
]
}
}
Load all available payterms.
[TestMethod]
public void REST_PayTerm_load()
{
state = new ErrorState { passed = false };
var payterms = GET.payterms(manager);
if (payterms.Count > 0)
{
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static List<PayTerm> payterms(Manager manager)
{
var currentClient = manager.getCurrentClient();
var currentFiscalYear = manager.getCurrentFiscalYear();
List<PayTerm> payterms = null;
string request = "clients/{0}/payterms";
var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
payterms = JsonConvert.DeserializeObject<List<PayTerm>>(response.Content.ReadAsStringAsync().Result);
}
return payterms;
}
public static PayTerm payterm_by_code(string code, Manager manager)
{
var currentClient = manager.getCurrentClient();
var currentFiscalYear = manager.getCurrentFiscalYear();
PayTerm payterm = null;
string request = "clients/{0}/payterms/bycode/{1}";
var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, code)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
payterm = JsonConvert.DeserializeObject<PayTerm>(response.Content.ReadAsStringAsync().Result);
}
return payterm;
}
}
UNDER CONSTRUCTION
UNDER CONSTRUCTION
{
"id": 17,
"code": "BAR",
"description": "Barzahlung",
"dueDays": 0,
"details": [
{
"id": 18,
"payTermFID": 17,
"withinDays": 0,
"discount": 0.0
}
]
}
Load a payterm by code.
[TestMethod]
public void REST_PayTerm_load_by_code()
{
state = new ErrorState { passed = false };
string code = REST_Helper.getRandomPayTermCode(manager);
PayTerm payterm = GET.payterm_by_code(code, manager);
if (payterm.code.Equals(code)) {
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static PayTerm payterm_by_code(string code, Manager manager)
{
var currentClient = manager.getCurrentClient();
var currentFiscalYear = manager.getCurrentFiscalYear();
PayTerm payterm = null;
string request = "clients/{0}/payterms/bycode/{1}";
var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, code)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
payterm = JsonConvert.DeserializeObject<PayTerm>(response.Content.ReadAsStringAsync().Result);
}
return payterm;
}
}
UNDER CONSTRUCTION
{
"id": 17,
"code": "BAR",
"description": "Barzahlung",
"dueDays": 0,
"details": [
{
"id": 18,
"payTermFID": 17,
"withinDays": 0,
"discount": 0.0
}
]
}
Load all available VAT's.
[TestMethod]
public void REST_VAT_Load()
{
state = new ErrorState();
var vats = GET.vats(manager);
state.passed = false;
if (vats.Count > 0)
{
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static <List<VAT>> vats(Manager manager)
{
List<VAT> vats = null;
string request = "clients/{0}/fiscalYears/{1}/vats";
var response = manager.httpClient.GetAsync(string.Format(request, manager.getCurrentClient().id, manager.getCurrentFiscalYear().id)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
vats = JsonConvert.DeserializeObject<List<VAT>>(response.Content.ReadAsStringAsync().Result);
}
return vats;
}
}
UNDER CONSTRUCTION
{
"id": 11,
"accountFID": 51,
"code": "frei",
"description": "Von der Steuer ausgenommene Umsätze",
"isInclusive": true,
"isInputTax": false,
"quote": 100.0,
"rate": 0.0
}
Load a VAT by code.
vatPosting()
[TestMethod]
public void REST_VAT_by_code_load()
{
state = new ErrorState { passed = false };
string vat_code = "UStn";
var vat = GET.vat_by_code(vat_code, manager);
if (vat.code.Equals(vat_code)) {
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static VAT vat_by_code(string code, Manager manager)
{
VAT vat = null;
string request = "clients/{0}/fiscalYears/{1}/vats/bycode/{2}";
var response = manager.httpClient.GetAsync(string.Format(request, manager.getCurrentClient().id, manager.getCurrentFiscalYear().id, code)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
vat = JsonConvert.DeserializeObject<VAT>(response.Content.ReadAsStringAsync().Result);
}
return vat;
}
}
UNDER CONSTRUCTION
{
"id": 11,
"accountFID": 51,
"code": "frei",
"description": "Von der Steuer ausgenommene Umsätze",
"isInclusive": true,
"isInputTax": false,
"quote": 100.0,
"rate": 0.0
}