This is a documentation of Annytab Dox Trade v1
, our own royalty-free standard that represent a trade document (business document) that can be used for sales and purchases in a company. The sales routine of a company means, among other things, to receive requests for quotation from customers, to create quotations, to receive orders from customers and to send invoices/bills to customers. The purchase routine of a company means, among other things, to send quotation requests to suppliers, to receive quotes, to send purchase orders to suppliers and to receive invoices from suppliers.
This standard for business documents can be used for quotation request, quotation, order, order confirmation, invoice, credit invoice, cash receipt and payment reminder. All these documents have the same layout, depending on the type of document you can can ignore some data in the document. A variable determines the kind of document (document_type
). A credit invoice (credit_invoice
) is a negative invoice and should have negative quantities in product rows and negative totals.
This standard is based on JSON, a compact and text-based format that is used to exchange data. It’s easy to serialize objects to JSON and it’s easy to deserialize JSON to objects. This standard is available in a NuGet package: a-dox-standards (NuGet Gallery).
AnnytabDoxTrade [Model]
PartyInformation [Model]
PaymentOption [Model]
ProductRow [Model]
VatSpecification [Model]
JSON Example
{
"id": "d82f56c8-7f87-402d-bbce-3af3e8287e67",
"document_type": "invoice",
"payment_reference": "D-2000",
"issue_date": "2017-12-04",
"due_date": "2018-01-03",
"delivery_date": "2017-12-04",
"offer_expires_date": null,
"seller_references": {
"supplier_id": "test"
},
"buyer_references": {
"customer_id": "F557882"
},
"terms_of_delivery": "CIF",
"terms_of_payment": "30",
"mode_of_delivery": "UPS",
"total_weight_kg": 10,
"penalty_interest": 0.2,
"currency_code": "USD",
"vat_country_code": "SE",
"vat_state_code": null,
"comment": "Thank you for buying from us.",
"seller_information": {
"person_id": "778899-7447",
"person_name": "Supplier Inc",
"address_line_1": "Abroad way 55",
"address_line_2": null,
"address_line_3": null,
"postcode": "CA90009",
"city_name": "San Francisco",
"country_name": "USA",
"country_code": "US",
"state_code": "CA",
"contact_name": "Brenda Meatloaf",
"phone_number": "+8800004545",
"email": "olle@annytab.se",
"vat_number": "778899-7447"
},
"buyer_information": {
"person_id": "556864-2747",
"person_name": "A Name Not Yet Taken AB",
"address_line_1": "Skonertgatan 12",
"address_line_2": "Kronobränneriet",
"address_line_3": "",
"postcode": "30238",
"city_name": "Halmstad",
"country_name": "Sweden",
"country_code": "SE",
"state_code": "",
"contact_name": "Fredrik Stigsson",
"phone_number": "",
"email": "dox@annytab.se",
"vat_number": "SE556864274701"
},
"delivery_information": null,
"payment_options": [
{
"name": "IBAN",
"account_reference": "SE4680000816959239073274",
"bank_identifier_code": "SWEDSESS",
"bank_name": "Swedbank AB",
"bank_country_code": "SE"
},
{
"name": "BG",
"account_reference": "7893514",
"bank_identifier_code": "BGABSESS",
"bank_name": "Bankgirocentralen BGC AB",
"bank_country_code": "SE"
},
{
"name": "BANK",
"account_reference": "816959239073274",
"bank_identifier_code": "SWEDSESS",
"bank_name": "Swedbank AB",
"bank_country_code": "SE"
},
{
"name": "SWISH",
"account_reference": "1235370366",
"bank_identifier_code": "SWEDSESS",
"bank_name": "Swedbank AB",
"bank_country_code": "SE"
},
{
"name": "PAYPAL.ME",
"account_reference": "https://www.paypal.me/annytab",
"bank_identifier_code": "",
"bank_name": "PayPal",
"bank_country_code": "US"
}
],
"product_rows": [
{
"product_code": null,
"manufacturer_code": null,
"gtin": null,
"product_name": "Support",
"vat_rate": 0.25,
"quantity": 10.46,
"unit_code": "h",
"unit_price": 11.44,
"subrows": null
},
{
"product_code": "C-546",
"manufacturer_code": "TT99878",
"gtin": null,
"product_name": "Computer",
"vat_rate": 0.12,
"quantity": 1,
"unit_code": "pcs",
"unit_price": 499.99,
"subrows": null
},
{
"product_code": "D-4879",
"manufacturer_code": null,
"gtin": "0000001",
"product_name": "Desk",
"vat_rate": 0.06,
"quantity": 2,
"unit_code": "pcs",
"unit_price": 2,
"subrows": null
}
],
"vat_specification": [
{
"tax_rate": 0.25,
"taxable_amount": 119.6624,
"tax_amount": 29.9156
},
{
"tax_rate": 0.12,
"taxable_amount": 499.99,
"tax_amount": 59.9988
},
{
"tax_rate": 0.06,
"taxable_amount": 4,
"tax_amount": 0.24
}
],
"subtotal": 624,
"vat_total": 90.1544,
"rounding": -0.1544,
"total": 714,
"paid_amount": 0,
"balance_due": 714
}
Code Example
// Create an invoice
AnnytabDoxTrade post = new AnnytabDoxTrade();
post.id = invoice.id;
post.document_type = "invoice";
post.payment_reference = invoice.invoice_number;
post.issue_date = invoice.invoice_date.ToString("yyyy-MM-dd");
post.due_date = invoice.invoice_date.AddDays(30).ToString("yyyy-MM-dd");
post.delivery_date = invoice.invoice_date.ToString("yyyy-MM-dd");
post.seller_references = new Dictionary<string, string>();
post.seller_references.Add("supplier_id", "T2000");
post.seller_references.Add("quotation_id", "546");
post.seller_references.Add("order_id", "1890");
post.buyer_references = new Dictionary<string, string>();
post.buyer_references.Add("customer_id", invoice.member_id);
post.buyer_references.Add("request_for_quotation_id", "55");
post.buyer_references.Add("order_id", "504");
post.terms_of_delivery = "EXW";
post.terms_of_payment = "Net 30";
post.mode_of_delivery = "WEB";
post.total_weight_kg = 0M;
post.penalty_interest = 0.10M;
post.currency_code = invoice.currency_code;
post.vat_country_code = "SE";
post.vat_state_code = "";
post.comment = tt.Get("invoice_text");
post.seller_information = new PartyInformation()
{
person_id = "556864-2747",
person_name = "A Name Not Yet Taken AB",
address_line_1 = "Skonertgatan 12",
address_line_2 = "Kronobränneriet",
address_line_3 = "",
postcode = "30238",
city_name = "Halmstad",
country_name = "Sweden",
country_code = "SE",
state_code = "",
contact_name = "Fredrik Stigsson",
phone_number = "",
email = "info@annytab.se",
vat_number = "SE556864274701"
};
post.buyer_information = new PartyInformation
{
person_id = invoice.person_id,
person_name = invoice.invoice_name,
address_line_1 = invoice.invoice_address_1,
address_line_2 = invoice.invoice_address_2,
address_line_3 = "",
postcode = invoice.invoice_postcode,
city_name = invoice.invoice_city,
country_name = invoice.invoice_country,
country_code = invoice.invoice_country_code,
state_code = "",
contact_name = invoice.contact_name,
phone_number = invoice.phone_number,
email = invoice.invoice_email,
vat_number = invoice.vat_number
};
post.payment_options = new List<PaymentOption>
{
new PaymentOption
{
name = "IBAN",
account_reference = "SE4680000816959239073274",
bank_identifier_code = "SWEDSESS",
bank_name = "Swedbank AB",
bank_country_code = "SE"
},
new PaymentOption
{
name = "BG",
account_reference = "7893514",
bank_identifier_code = "BGABSESS",
bank_name = "Bankgirocentralen BGC AB",
bank_country_code = "SE"
},
new PaymentOption
{
name = "SWISH",
account_reference = "1235370366",
bank_identifier_code = "SWEDSESS",
bank_name = "Swedbank AB",
bank_country_code = "SE"
}
};
post.product_rows = new List<ProductRow>
{
new ProductRow
{
product_code = "GiB",
manufacturer_code = "GiB",
gtin = "",
product_name = tt.Get("gibibytes"),
vat_rate = invoice.vat_rate,
quantity = invoice.gib,
unit_code = "PIEC",
unit_price = invoice.unit_price,
subrows = new List<ProductRow>()
}
};
post.vat_specification = new List<VatSpecification>
{
new VatSpecification
{
tax_rate = invoice.vat_rate,
taxable_amount = invoice.net_amount,
tax_amount = invoice.vat_amount,
}
};
post.subtotal = invoice.net_amount;
post.vat_total = invoice.vat_amount;
post.rounding = 0M;
post.total = invoice.gross_amount;
post.paid_amount = invoice.paid == true ? invoice.gross_amount : 0;
post.balance_due = invoice.gross_amount - post.paid_amount;
// Convert the object to a byte array
byte[] array = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(post));
// Write to the stream
stream.Write(array, 0, array.Length);