Xena

A walk-through of the most common actions in Xena, done via our API.

For a complete overview of the Xena API, please go to https://xena.biz/api-doc/

How the create a partner

A partner in Xena can be used as a creditor, debtor and/or employee. The idea behind this is to avoid duplicate data and to give our customers a better overview of all of their business with a specific partner. If a partner is a creditor, it will have a customer context connected. If a partner is a debtor, it will have a supplier context connected. A partner can have more than one context. When you make a lookup on a specific partner, you will get info about the contexts associated.

GET https://my.xena.biz/Api/Fiscal/{fiscalId}/Partner/{partnerId}
{
	...
	"SupplierId": {Supplier context id},
	"CustomerId": {customer context id},
	"ResourceId": {resource context id},
	...
}

This is important to understand when you create a new partner. If you use the default endpoint, the partner will be created without any contexts.

There are two ways to creating a partner. The first method requires two API calls. The second method can only create a customer or supplier but only requires one API call.

Create a partner without any context

POST https://my.xena.biz/Api/Fiscal/{fiscalId}/Partner

Create a basic partner without any customer or supplier context. See the full dto here: https://github.com/EG-BRS/Xena.Contracts/blob/development/src/Xena.Contracts/Domain/PartnerDto.cs

Path Parameters

Request Body

{
	"Version": 1,
	"IsDeactivated": false,
	"FiscalSetupId": 97190,
	"CreatedAt": "2019-11-26T10:25:53.307Z",
	"AccountNumber": 10229,
	"Address": {
		"City": "Aarhus",
		"CountryName": null,
		"PlaceName": "string",
		"Street": "string",
		"Zip": "8000",
		"Name": "string",
		"Description": "string - string, 8000 Aarhus",
		"CountryDisplayName": null
	},
	"ReferenceFiscalSetupId": null,
	"ReferenceUserId": null,
	"Attention": "string",
	"PartnerType": "xena_partnertype_company",
	"PartnerTypeTranslated": "Company",
	"PhoneNumber": "string",
	"Note": "string",
	"URL": null,
	"GLNNumber": "string",
	"OrgNumber": "string",
	"SupplierId": null,
	"CustomerId": null,
	"ResourceId": null,
	"DefaultDeliveryAddressId": null,
	"ShortDescription": "10229",
	"LongDescription": "10229 - string",
	"Tags": [],
	"Id": 520618279
}

This will create a new partner in Xena. In Xena, the partner can be converted to a customer, supplier or/and employee. If you want to add a context you can use the following endpoint.

Create a partner context

POST https://my.xena.biz/Api/Fiscal/{fiscalId}/PartnerContext

Create a supplier or customer context for a given partner.

Request Body

{
	"Version": 1,
	"IsDeactivated": false,
	"FiscalSetupId": 97190,
	"CreatedAt": "2019-11-26T12:52:50.89Z",
	"ContextType": "ContextType_Supplier",
	"PartnerId": 365830428,
	"TermsOfPayment": {
		"Offset": 15,
		"DueType": "xena_running_month",
		"Description": "Running month + 15 days"
	},
	"CurrencyAbbreviation": "DKK",
	"InvoiceEmail": "",
	"OfferReportLayoutId": null,
	"DeliveryReportLayoutId": null,
	"InvoiceReportLayoutId": null,
	"ConfirmationReportLayoutId": null,
	"PriceGroupId": null,
	"Culture": "da-DK",
	"DefaultArticleGroupId": null,
	"DefaultLedgerTagId": null,
	"DefaultVatId": null,
	"DefaultLedgerAccount": null,
	"PaymentMeansType": null,
	"PaymentMeansTypeTranslated": "",
	"Account": null,
	"AccountIdentifier": null,
	"AccountLabelTranslated": "",
	"AccountIdentifierLabelTranslated": "",
	"GroupPayments": false,
	"DefaultPaymentMessage": null,
	"PartnerName": null,
	"DefaultVatAbbreviation": null,
	"PriceGroupDescription": null,
	"ArticleGroupDescription": null,
	"LedgerTagNumber": null,
	"LedgerTagDescription": null,
	"OfferReportLayoutName": null,
	"DeliveryReportLayoutName": null,
	"InvoiceReportLayoutName": null,
	"ConfirmationReportLayoutName": null,
	"CurrencyDescription": "Danish Krone",
	"ContextDescription": "Supplier",
	"CultureDisplayName": "Danish (Denmark)",
	"DefaultBookkeepingText": "",
	"Id": 520693898
}

Create a partner as a customer and/or supplier

POST https://my.xena.biz/Api/Fiscal/{fiscal}/Partner/Search

To avoid making two requests when creating a customer or supplier, this endpoint can be used.

Request Body

Teh fu

The full model can be found here: https://github.com/EG-BRS/Xena.Contracts/blob/development/src/Xena.Contracts/Helpers/PartnerSearchDto.cs

How to create an order and add articles

In this section we will show you how to create an order and add an article to that order. This can be done with the following steps:

  1. Create the order

  2. Find the order task or add an order task

  3. Add a line to the order task

  4. Update the order line with an article

In the following sections we will describe the needed endpoints.

Create an order

POST https://my.xena.biz/Api/Fiscal/{fiscalId}/Order

First step is to create a new order.

Request Body

{
    "Version": 1,
    "IsDeactivated": false,
    "FiscalSetupId": 98824,
    "CreatedAt": "2019-11-21T18:48:14.583Z",
    "PartnerId": null,
    "OurReference": "Niels Husted",
    "YourReference": "",
    "ContextType": "ContextType_Customer",
    "Address": {
        "City": "",
        "CountryName": "DK",
        "PlaceName": "",
        "Street": "",
        "Zip": "",
        "Name": "",
        "Description": " -  ",
        "CountryDisplayName": "Denmark"
    },
    "DeliveryAddress": null,
    "DeliveryNote": null,
    "OrderNumber": 200009,
    "DateDays": 18221,
    "DeliveryDateDays": null,
    "CurrencyAbbreviation": "DKK",
    "OfferReportLayoutId": null,
    "DeliveryReportLayoutId": null,
    "InvoiceReportLayoutId": null,
    "ConfirmationReportLayoutId": null,
    "OfferReportLayoutName": null,
    "DeliveryReportLayoutName": null,
    "InvoiceReportLayoutName": null,
    "ConfirmationReportLayoutName": null,
    "GLNNumber": null,
    "InternalNote": "",
    "TermsOfPayment": {
        "Offset": 8,
        "DueType": "xena_nett",
        "Description": "Net + 8 days"
    },
    "Culture": "da-DK",
    "ProjectId": null,
    "ResponsibleId": 194833467,
    "ResponsibleName": "Niels Husted",
    "InvoiceEmail": "",
    "PartnerAccountNumber": null,
    "PartnerName": null,
    "PartnerNote": null,
    "PartnerPhoneNumber": null,
    "PartnerType": null,
    "Summary": {
        "Totals": {
            "PriceNettTotal": 0.0,
            "CostTotal": 0.0,
            "DiscountTotalRatio": 0.0,
            "DiscountTotalPct": 0.0,
            "DiscountTotal": 0.0,
            "MarginTotal": 0.0,
            "MarginTotalRatio": 0.0,
            "MarginTotalPct": 0.0,
            "VatEstTotal": 0.0
        },
        "NotInvoicedTotals": {
            "PriceNettTotal": 0.0,
            "CostTotal": 0.0,
            "DiscountTotalRatio": 0.0,
            "DiscountTotalPct": 0.0,
            "DiscountTotal": 0.0,
            "MarginTotal": 0.0,
            "MarginTotalRatio": 0.0,
            "MarginTotalPct": 0.0,
            "VatEstTotal": 0.0
        },
        "IsFullyInvoiced": false,
        "IsFullyDelivered": false,
        "IsFullyConfirmed": false,
        "CanOffer": false,
        "CanDeliver": false,
        "CanInvoice": false,
        "CanPay": false,
        "CanConfirm": false
    },
    "OrderInvoiceNumbers": [],
    "DepartmentId": null,
    "DepartmentDescription": null,
    "BearerId": null,
    "BearerDescription": null,
    "PurposeId": null,
    "PurposeDescription": null,
    "IsHeaderReadOnly": false,
    "OrderStatusId": 196093425,
    "OrderStatusName": "Oprettet",
    "OrderStatusColor": "#eac100",
    "ProjectDescription": null,
    "ProjectNumber": null,
    "OrderDeliveryStatus": "SalesOrderDeliveryStatus_NotApplicable",
    "CultureDisplayName": "Danish (Denmark)",
    "LastInvoicedDateDays": null,
    "SupplierInvoiceDateDays": null,
    "SupplierInvoiceNumber": null,
    "SupplierPaymentId": null,
    "Id": 518338659
}

Save the Id - you will need it later.

You can find the full model here

Articles/lines are not added directly to the order but to an order task. One order can have several order tasks. The next step is to get the tasks and add articles to them.

Get order tasks

GET https://my.xena.biz/Api/Fiscal/{fiscalId}/Order/{orderId}/OrderTask?ForceNoPaging=true&Page=0&PageSize=100&ShowDeactivated=false

First you need to find the order task that you want to add the article to. If CreateTask was true when you created the order then the order will have one task already. To find the Id of that order task you need to get the list of order tasks. You will get a PagedResultSet with a list of OrderTaskDTO in Entities property from the endpoint.

Path Parameters

{
    "Count": 1,
    "Entities": [{
        "Version": 1,
        "IsDeactivated": false,
        "FiscalSetupId": 98824,
        "CreatedAt": "2019-11-25T18:37:10.673Z",
        "OrderId": 520562489,
        "OrderContextType": "ContextType_Customer",
        "PrintDetails": false,
        "Details": "",
        "Description": "",
        "OrderTaskStatusId": 196020703,
        "Totals": {
            "PriceNettTotal": 0.0,
            "CostTotal": 0.0,
            "DiscountTotalRatio": 0.0,
            "DiscountTotalPct": 0.0,
            "DiscountTotal": 0.0,
            "MarginTotal": 0.0,
            "MarginTotalRatio": 0.0,
            "MarginTotalPct": 0.0,
            "VatEstTotal": 0.0
        },
        "Address": {
            "City": "",
            "CountryName": "DK",
            "PlaceName": "",
            "Street": "",
            "Zip": "",
            "Name": "",
            "Description": " -  ",
            "CountryDisplayName": "Denmark"
        },
        "DeliveryAddress": null,
        "OrderTaskStatusName": "Igangværende",
        "OrderTaskStatusColor": "#9cce6f",
        "OrderNumber": 200015,
        "Index": 1,
        "SubscriptionId": null,
        "IsInvoiced": false,
        "IsDelivered": false,
        "IsConfirmed": false,
        "IsReadonly": false,
        "Abbreviation": "200015-1",
        "ProjectId": null,
        "ProjectClosedDateDays": null,
        "AppointmentCount": 0,
        "IsPlanned": false,
        "Id": 520556331
    }]
}

Find an order task

POST https://my.xena.biz/Api/Fiscal/{fiscalId}/OrderTask

If there are no ordertasks on the order or you want to create a new one, you can use this endpoint.

Path Parameters

You should save the Id.

Create an order task line

POST https://my.xena.biz/Api/Fiscal/{fiscalId}/OrderLine

Now you are ready to add an article to the order task. To do this, you will need the id of the article and to create an order line. Here, we assume you got an article id. Start by creating a new order task line.

Request Body

{
	"Version": 1,
	"IsDeactivated": false,
	"FiscalSetupId": 98824,
	"CreatedAt": "2019-11-25T19:05:54.163Z",
	"OrderId": 520562489,
	"OrderContextType": "ContextType_Customer",
	"PrintDetails": false,
	"Details": "",
	"Description": "",
	"OrderTaskStatusId": 196020703,
	"Totals": {
		"PriceNettTotal": 0.0,
		"CostTotal": 0.0,
		"DiscountTotalRatio": 0.0,
		"DiscountTotalPct": 0.0,
		"DiscountTotal": 0.0,
		"MarginTotal": 0.0,
		"MarginTotalRatio": 0.0,
		"MarginTotalPct": 0.0,
		"VatEstTotal": 0.0
	},
	"Address": {
		"City": "",
		"CountryName": "DK",
		"PlaceName": "",
		"Street": "",
		"Zip": "",
		"Name": "",
		"Description": " -  ",
		"CountryDisplayName": "Denmark"
	},
	"DeliveryAddress": null,
	"OrderTaskStatusName": "Igangværende",
	"OrderTaskStatusColor": "#9cce6f",
	"OrderNumber": 200015,
	"Index": 2,
	"SubscriptionId": null,
	"IsInvoiced": false,
	"IsDelivered": false,
	"IsConfirmed": false,
	"IsReadonly": false,
	"Abbreviation": "200015-2",
	"ProjectId": null,
	"ProjectClosedDateDays": null,
	"AppointmentCount": 0,
	"IsPlanned": false,
	"Id": 520556332
}

Update an order task line

PUT https://my.xena.biz/Api/Fiscal/{fiscalId}/OrderLine/{orderlineId}

To update the line, make the this request. The important fields are ArticleId, Quantity and Description.

Path Parameters

{
	"Version": 2,
	"IsDeactivated": false,
	"FiscalSetupId": 98824,
	"CreatedAt": "2019-11-25T19:18:42.527Z",
	"LocationId": null,
	"OrderInvoiceTaskId": null,
	"OrderTaskId": 520556332,
	"OrderId": 520562489,
	"ProjectId": null,
	"Index": 0,
	"ArticleId": 195803359,
	"InvoiceDateDays": null,
	"CostEach": 0.00000,
	"Description": "Ydelser sats 1",
	"PriceEach": 0.00000,
	"Quantity": 1.00000,
	"UnitId": 195796629,
	"PayerId": null,
	"PayerAccountNumber": null,
	"UnitAbbreviation": "timer",
	"ArticleNumber": "yde1",
	"Totals": {
		"PriceNettTotal": 0.00000,
		"CostTotal": 0.00000,
		"DiscountTotalRatio": 0.0,
		"DiscountTotalPct": 0.0,
		"DiscountTotal": 0.00000,
		"MarginTotal": 0.00000,
		"MarginTotalRatio": 0.0,
		"MarginTotalPct": 0.0,
		"VatEstTotal": 0.00000
	},
	"ArticleGroupId": 195796691,
	"ArticleVariantId": null,
	"ArticleGroupDescription": "Ydelser",
	"ArticleHasInventoryManagement": false,
	"ArticleHasVariants": false,
	"ArticleInternalNote": null,
	"ArticleIsBundle": false,
	"ArticleVariantAbbreviation": null,
	"ArticleWeight": null,
	"LocationAbbreviation": null,
	"ArticleStatus": null,
	"OrderDeliveryTransactionId": null,
	"ArticleMappingId": null,
	"ArticleMappingQuantity": null,
	"PartnerArticleNumber": null,
	"IsConfirmed": false,
	"ArticleAbbreviation": "yde1",
	"IsDelivered": false,
	"ArticleIsDeactivated": false,
	"AverageCostPrice": null,
	"EstimatedCostTotal": 0.00000,
	"OrderLineStatusColor": null,
	"OrderLineStatusName": null,
	"HasLinkedLines": false,
	"Id": 520557490
}

How to create an invoice

[Coming up]

Last updated