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.
Copy 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
Id of the fiscal you want to create the partner in
Request Body
200
Copy {
"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
ContextType_Customer or ContextType_Supplier
The email that will be suggested when creating an invoice
200
Supplier context Customer context
Copy {
"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
}
Copy {
"Version": 1,
"IsDeactivated": false,
"FiscalSetupId": 97190,
"CreatedAt": "2019-11-26T12:54:12.233Z",
"ContextType": "ContextType_Customer",
"PartnerId": 516783821,
"TermsOfPayment": {
"Offset": 8,
"DueType": "xena_nett",
"Description": "Net + 8 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": "Customer",
"CultureDisplayName": "Danish (Denmark)",
"DefaultBookkeepingText": "",
"Id": 520619084
}
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
CustomerTermsOfPaymentOffset
Days or months the customer have to pay the invoice
CustomerTermsOfPaymentDueType
xena_cash, xena_nett, xena_running_month or xena_prepaid
SupplierTermsOfPaymentOffset
Days or months on supplier payment terms
SupplierTermsOfPaymentDueType
xena_cash, xena_nett, xena_running_month or xena_prepaid
xena_partnertype_person if the partner is a private customer.
xena_partnertype_company if the partner is a company.
Company registration number (CVR in DK)
Number used for electronic invoicing
ISO countrycode (DK, NO, SE etc.)
If this is True then a Customer context will be added to the partner
If this is True then a Supplier context will be added to the partner.
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:
Find the order task or add an order task
Add a line to the order task
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
If true an ordertask will be created.
This should be null. Only set this if you know what you are doing! This can be relevant if the order is born with a number in some other system (e.g. a webshop).
Id of the assosiated project. Only relevant for users of the project module.
Id of the Customer or Supplier on the order.
Whether it should be a Sales order (ContextType_Customer) or Purchase order (ContextType_Supplier)
200 302 Beskrivelse xxx
Copy {
"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
If you set this as True then you will deactivate pageing
200
Copy {
"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
Id for the order you want to create an ordertask on
200 Xena will return this model to you:
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
200 You should save the data since you will need it when updating the line with the article id.
Copy {
"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
Id of the line order you want to update
200
Copy {
"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]