Payables/Receivables invoices
This section contains code samples related to payables and receivables invoices.
Example Code
Load all payable invoices in a given fiscalyear.
[TestMethod]
public void REST_Payables_invoices_all_GET()
{
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 payable invoices in a given fiscalyear, which have not yet been paid.
[TestMethod]
public void REST_Payables_invoices_open_GET()
{
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> 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 a payable invoice with a given free invoice number.
#Code reference - GET.party_by_number
#Code reference - Create.payables_invoice
#Code reference - POST.payables_invoice
#Code reference - DELETE.payables_invoice
[TestMethod]
public void REST_Payables_invoice_by_free_invoice_num_GET()
{
state = new ErrorState { passed = false };
decimal payment_amount = 1000m;
String name = "Tamedia AG";
Party party = GET.party_by_name(name, manager);
party = GET.party_by_number(party.partyNum, manager);
Invoice rand_invoice = REST_Helper.getRandomPayablesOpenInvoiceWithFreeInvoiceNum(manager);
Invoice invoice = GET.payables_invoice_by_freeinvoicenum(rand_invoice.freeInvoiceNum, manager);
if (invoice == null)
{
List postings = new List();
postings.Add(payment_amount);
Invoice_TO invoice_DTO = new Invoice_TO
{
party = party,
manager = manager,
date = DateTime.Today,
posting_amounts = postings,
payment_amount = payment_amount,
free_inv_num = "RI_2222",
vat_code = "",
hasDocument = 0,
isDebit = true,
text = ""
};
invoice = Create.payables_invoice(invoice_DTO);
state.passed = POST.payables_invoice(invoice, manager);
Assert.AreEqual(true, state.passed, state.message);
}
invoice = GET.payables_invoice_by_freeinvoicenum(invoice.freeInvoiceNum, manager);
state.passed = false;
if (invoice != null)
{
state.passed = true;
Assert.AreEqual(true, state.passed, state.message);
}
state.passed = DELETE.payables_invoice(invoice, manager);
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static Invoice payables_invoice_by_freeinvoicenum(string free_invoice_num, Manager manager)
{
Invoice invoice = null;
string request = "clients/{0}/fiscalYears/{1}/payables/invoices/byfreeinvoicenum/{2}";
var response = manager.httpClient.GetAsync(string.Format(request, manager.getCurrentClient().id, manager.getCurrentFiscalYear().id, free_invoice_num)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
invoice = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);
}
return invoice;
}
}
UNDER CONSTRUCTION
Load all receivable invoices in a given fiscalyear.
[TestMethod]
public void REST_Receivables_invoices_GET()
{
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_GET()
{
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
{
"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 a receivable invoice with a given free invoice number.
#Code reference - GET.party_by_number
#Code reference - Create.receivables_invoice
#Code reference - POST.receivables_invoice
#Code reference - DELETE.receivables_invoice
[TestMethod]
public void REST_Receivables_invoice_by_freeinvoicenum_GET()
{
state = new ErrorState { passed = false };
string free_invoice_num = "RI_3810";
List invoices = GET.receivables_invoices_by_freeinvoicenum_all(free_invoice_num, manager);
if (invoices == null)
{
Party party = GET.party_by_name("Bucherer AG", manager);
party = GET.party_by_id(party.id, manager);
decimal payment_amount = 4000.0m;
decimal payment_fc_amount = 4000.0m;
Invoice_TO invoice_to = new Invoice_TO
{
party = party,
manager = manager,
vat_code = "UStn",
free_inv_num = free_invoice_num,
text = "Recivables Invoice",
payment_amount = payment_amount,
payment_fc_amount = payment_fc_amount,
exchange_rate = 1.0m,
contra_account = "3200",
pay_method = "Method_1",
payslip_code = "",
invoiceType = Convert.ToBoolean(InvoiceType.INCLUSIVE)
};
Invoice oinvoice = Create.receivables_invoice(invoice_to);
state.passed = POST.receivables_invoice(oinvoice, manager);
Assert.AreEqual(true, state.passed, state.message);
}
Invoice invoice = GET.receivables_invoice_by_freeinvoicenum(free_invoice_num, manager);
state.passed = false;
if (invoice.freeInvoiceNum.Equals(free_invoice_num)) {
state.passed = true;
}
Assert.AreEqual(true, state.passed, state.message);
state.passed = false;
state.passed = DELETE.receivables_invoice(invoice, manager);
Assert.AreEqual(true, state.passed, state.message);
}
class GET
{
public static Invoice receivables_invoice_by_freeinvoicenum(string free_invoice_num, Manager manager)
{
Invoice invoice = null;
string request = "clients/{0}/fiscalYears/{1}/receivables/invoices/byfreeinvoicenum/{2}";
var response = manager.httpClient.GetAsync(string.Format(request, manager.getCurrentClient().id, manager.getCurrentFiscalYear().id, free_invoice_num)).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
invoice = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);
}
return invoice;
}
UNDER CONSTRUCTION
Not available
Load all available payterms.
[TestMethod]
public void REST_PayTerm_GET()
{
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
{
"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 { passed = false };
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.
[TestMethod]
public void REST_VAT_by_code_GET()
{
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
}