I den här dokumentationen beskriver vi Annytab Dox Trade v1
, vår egna licensfria standard för ett affärsdokument som kan användas vid försäljning och inköp i ett företag. Försäljningsrutinen i ett företag innebär bland annat att ta emot offertförfrågningar från kunder, att skapa offerter, att ta emot ordrar från kunder och att skicka fakturor till kunder. Inköpsrutinen i ett företag innebär bland annat att skicka offertförfrågningar till leverantörer, att ta emot offerter, att skicka inköpsordrar till leverantörer och att ta emot fakturor från leverantörer.
Den här standarden för affärsdokument kan användas för offertförfrågning, offert, order, orderbekräftelse, faktura, kreditfaktura, kontantkvitto och betalningspåminnelse. Alla dessa dokument har samma utformning, beroende på vilken typ av dokument det rör sig om så kan man ignorera viss data i dokumentet. I den är standarden finns det en variabel som bestämmer vilken typ av dokument det rör sig om. En kreditfaktura (credit_invoice
) är en negativ faktura och skall ha negativa kvantiteter i produktraderna och negativa totalbelopp.
Den här standarden bygger på JSON, ett kompakt och textbaserat format som används för att utbyta data. Det är smidigt att serialisera objekt i program till JSON och det är smidigt att deserialisera JSON till objekt i program. Denna standard finns inkluderad i ett NuGet paket: a-dox-standards (NuGet Gallery).
AnnytabDoxTrade [Modell]
PartyInformation [Modell]
PaymentOption [Modell]
ProductRow [Modell]
VatSpecification [Modell]
JSON-Exempel
{
"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
}
Exempelkod
// 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);