From b066622b4fbcb9de90c152e606ce7eaee06e3b16 Mon Sep 17 00:00:00 2001 From: Anders Yderborg Date: Mon, 5 Oct 2020 09:50:53 +0200 Subject: [PATCH 1/4] Moved ProjectData to own cs file --- Visma.net/lib/DAta/CashSaleData.cs | 8 -------- Visma.net/lib/DAta/ProjectData.cs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 Visma.net/lib/DAta/ProjectData.cs diff --git a/Visma.net/lib/DAta/CashSaleData.cs b/Visma.net/lib/DAta/CashSaleData.cs index 06ef2e4..a7f92f0 100644 --- a/Visma.net/lib/DAta/CashSaleData.cs +++ b/Visma.net/lib/DAta/CashSaleData.cs @@ -10,12 +10,4 @@ internal CashSaleData(VismaNetAuthorization auth) ApiControllerUri = VismaNetControllers.CashSale; } } - - public class ProjectData : BaseCrudDataClass - { - internal ProjectData(VismaNetAuthorization auth) : base(auth) - { - ApiControllerUri = VismaNetControllers.Project; - } - } } diff --git a/Visma.net/lib/DAta/ProjectData.cs b/Visma.net/lib/DAta/ProjectData.cs new file mode 100644 index 0000000..e13ab9a --- /dev/null +++ b/Visma.net/lib/DAta/ProjectData.cs @@ -0,0 +1,12 @@ +using ONIT.VismaNetApi.Models; + +namespace ONIT.VismaNetApi.Lib.Data +{ + public class ProjectData : BaseCrudDataClass + { + internal ProjectData(VismaNetAuthorization auth) : base(auth) + { + ApiControllerUri = VismaNetControllers.Project; + } + } +} From 41c386470ae308f55e767133a81bc560ab51045d Mon Sep 17 00:00:00 2001 From: Anders Yderborg Date: Wed, 21 Oct 2020 08:55:10 +0200 Subject: [PATCH 2/4] Added attibute endpoint and shipments to sales order --- Visma.net/Models/Attribute.cs | 76 +++++++++++++++++++ Visma.net/Models/AttributeDetails.cs | 48 ++++++++++++ Visma.net/Models/CustomDto/ContactInvoice.cs | 53 +++++++++++++ .../Models/CustomDto/SubaccountProject.cs | 56 ++++++++++++++ Visma.net/Models/CustomerInvoice.cs | 12 +++ Visma.net/Models/Project.cs | 20 ++++- Visma.net/Models/ProjectTask.cs | 2 + Visma.net/Models/SalesOrder.cs | 7 ++ Visma.net/Models/SalesOrderShipment.cs | 71 +++++++++++++++++ Visma.net/Visma.net.csproj | 6 +- Visma.net/VismaNet.cs | 2 + Visma.net/lib/DAta/AttributeData.cs | 17 +++++ Visma.net/lib/VismaNetControllers.cs | 2 + 13 files changed, 366 insertions(+), 6 deletions(-) create mode 100644 Visma.net/Models/Attribute.cs create mode 100644 Visma.net/Models/AttributeDetails.cs create mode 100644 Visma.net/Models/CustomDto/ContactInvoice.cs create mode 100644 Visma.net/Models/CustomDto/SubaccountProject.cs create mode 100644 Visma.net/Models/SalesOrderShipment.cs create mode 100644 Visma.net/lib/DAta/AttributeData.cs diff --git a/Visma.net/Models/Attribute.cs b/Visma.net/Models/Attribute.cs new file mode 100644 index 0000000..5687164 --- /dev/null +++ b/Visma.net/Models/Attribute.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using ONIT.VismaNetApi.Lib; +using ONIT.VismaNetApi.Models.CustomDto; +using ONIT.VismaNetApi.Models.Enums; + +namespace ONIT.VismaNetApi.Models +{ + public class Attribute : DtoPaginatedProviderBase, IProvideIdentificator + { + public Attribute(string attributeID) + { + this.attributeID = attributeID; + } + public string attributeID + { + get => Get(); + set => Set(value); + } + public string description + { + get => Get(); + set => Set(value); + } + public string controlType + { + get => Get(); + set => Set(value); + } + public bool Internal + { + get => Get(); + set => Set(value); + } + public string entryMask + { + get => Get(); + set => Set(value); + } + public string regExp + { + get => Get(); + set => Set(value); + } + + [JsonProperty] public DateTime createdDateTime { get; private set; } + [JsonProperty] public DateTime lastModifiedDateTime { get; private set; } + + [JsonProperty] public string errorInfo { get; private set; } + + [JsonProperty] + public List details + { + get => Get(defaultValue: new List()); + private set => Set(value); + } + + public string GetIdentificator() + { + return attributeID; + } + + internal override void PrepareForUpdate() + { + foreach (var detail in details) + { + detail.operation = ApiOperation.Update; + } + + IgnoreProperties.Add(nameof(attributeID)); + } + } +} \ No newline at end of file diff --git a/Visma.net/Models/AttributeDetails.cs b/Visma.net/Models/AttributeDetails.cs new file mode 100644 index 0000000..075aa95 --- /dev/null +++ b/Visma.net/Models/AttributeDetails.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using ONIT.VismaNetApi.Lib; +using ONIT.VismaNetApi.Models.CustomDto; +using ONIT.VismaNetApi.Models.Enums; + +namespace ONIT.VismaNetApi.Models +{ + public class AttributeDetails : DtoProviderBase + { + public AttributeDetails() + { + DtoFields.Add("operation", new NotDto(ApiOperation.Insert)); + } + [JsonIgnore] + public ApiOperation operation + { + get => Get(defaultValue: new NotDto(ApiOperation.Insert)).Value; + set => Set(new NotDto(value)); + } + + public string valueId + { + get => Get(); + set => Set(value); + } + public string description + { + get => Get(); + set => Set(value); + } + public int sortOrder + { + get => Get(); + set => Set(value); + } + public bool disabled + { + get => Get(); + set => Set(value); + } + + [JsonProperty] public string errorInfo { get; private set; } + } +} \ No newline at end of file diff --git a/Visma.net/Models/CustomDto/ContactInvoice.cs b/Visma.net/Models/CustomDto/ContactInvoice.cs new file mode 100644 index 0000000..397bdf3 --- /dev/null +++ b/Visma.net/Models/CustomDto/ContactInvoice.cs @@ -0,0 +1,53 @@ +using System.Text; +using Newtonsoft.Json; +using ONIT.VismaNetApi.Lib; + +namespace ONIT.VismaNetApi.Models.CustomDto +{ + public class ContactInvoice : DtoProviderBase + { + [JsonProperty] public int contactId { get; private set; } + + public string email + { + get => Get(); + set => Set(value?.Trim()); + } + + public string businessName + { + get => Get(); + set => Set(value?.Trim()); + } + public string attention + { + get => Get(); + set => Set(value?.Trim()); + } + + public string phone1 + { + get => Get(); + set => Set(value?.Trim()); + } + public bool overrideContact + { + get => Get(); + set => Set(value); + } + + + public override string ToString() + { + var builder = new StringBuilder(); + builder.AppendLine(businessName); + if (!string.IsNullOrWhiteSpace(attention)) + builder.AppendLine(attention); + if (!string.IsNullOrWhiteSpace(email)) + builder.AppendLine(email); + if (!string.IsNullOrWhiteSpace(phone1)) + builder.AppendLine(phone1); + return builder.ToString().Trim(); + } + } +} \ No newline at end of file diff --git a/Visma.net/Models/CustomDto/SubaccountProject.cs b/Visma.net/Models/CustomDto/SubaccountProject.cs new file mode 100644 index 0000000..26e71b8 --- /dev/null +++ b/Visma.net/Models/CustomDto/SubaccountProject.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace ONIT.VismaNetApi.Models.CustomDto +{ + public class SubaccountProject : IProvideCustomDto + { + private List _segments; + + [JsonProperty] + public string id { get; private set; } + [JsonProperty] + public List segments + { + get => _segments ?? (_segments = new List()); + private set => _segments = value; + } + /// + /// Sets a segment (department, project) for an invoice line. Remember that you have to set ALL segments for a line. + /// + /// + /// + public string this[int segmentId] + { + get + { + if (segments == null || segments.Count == 0 || segments.All(x => x.segmentId != segmentId)) + return string.Empty; + var firstOrDefault = segments.FirstOrDefault(x => x.segmentId == segmentId); + if (firstOrDefault != null) + return firstOrDefault.segmentValue; + return string.Empty; + } + set + { + var firstOrDefault = segments.FirstOrDefault(x => x.segmentId == segmentId); + if (firstOrDefault != null) + { + firstOrDefault.segmentValue = value; + } + else + { + segments.Add(new Segment {segmentId = segmentId, segmentValue = value}); + } + } + } + + public object ToDto() + { + return segments.Select(x => new {x.segmentId, x.segmentValue}); + } + } +} \ No newline at end of file diff --git a/Visma.net/Models/CustomerInvoice.cs b/Visma.net/Models/CustomerInvoice.cs index 639c420..a73cc3a 100644 --- a/Visma.net/Models/CustomerInvoice.cs +++ b/Visma.net/Models/CustomerInvoice.cs @@ -184,6 +184,18 @@ public CustomerDocumentType documentType private set; // { Set(value); } } + public SoAddress invoiceAddress + { + get => Get(defaultValue: new SoAddress()); + set => Set(value); + } + + public ContactInvoice invoiceContact + { + get => Get(defaultValue: new ContactInvoice()); + set => Set(value); + } + [JsonProperty] public DateTime dunningLetterDate { get; private set; } [JsonProperty] public int dunningLetterLevel { get; private set; } diff --git a/Visma.net/Models/Project.cs b/Visma.net/Models/Project.cs index 7adc06e..4406767 100644 --- a/Visma.net/Models/Project.cs +++ b/Visma.net/Models/Project.cs @@ -14,6 +14,12 @@ public Project() IgnoreProperties.Add(nameof(this.projectID)); IgnoreProperties.Add(nameof(this.internalID)); } + + public Project(string projectNumber) + { + projectID = projectNumber; + IgnoreProperties.Add(nameof(this.internalID)); + } [JsonProperty] public double assets { get; private set; } [JsonProperty] @@ -31,12 +37,20 @@ public Project() public string description { get { return Get(); } set { Set(value); } } public DateTime startDate { get { return Get(); } set { Set(value); } } public DateTime endDate { get { return Get(); } set { Set(value); } } - [JsonProperty] - public ProjectManager projectManager { get { return Get(); } private set { Set(value); } } + + public ProjectManager projectManager { + get => Get("projectManger", new ProjectManager()); // Misspelled in Visma API projectManger not projectManager + set => Set(value, "employeeNumber"); + } + public bool restrictEmployees { get { return Get(); } set { Set(value); } } public bool restrictEquipment { get { return Get(); } set { Set(value); } } public Visibility visibility { get { return Get(defaultValue:new Visibility()); } set { Set(value); } } - public DescriptiveDto defSub { get { return Get(); } set { Set(value); } } + public CustomDto.SubaccountProject defSub + { + get => Get("defSub",defaultValue: new CustomDto.SubaccountProject()); + set => Set(value); + } public string billingPeriod { get { return Get(); } set { Set(value); } } //public DescriptiveDto customerLocation { get { return Get(); } set { Set(value); } } public DescriptiveDto allocationRule { get { return Get(); } set { Set(value); } } diff --git a/Visma.net/Models/ProjectTask.cs b/Visma.net/Models/ProjectTask.cs index ec9c728..5927594 100644 --- a/Visma.net/Models/ProjectTask.cs +++ b/Visma.net/Models/ProjectTask.cs @@ -23,5 +23,7 @@ public ApiOperation operation public DateTime plannedEnd { get { return Get(); } set { Set(value); } } public DateTime startDate { get { return Get(); } set { Set(value); } } public DescriptiveDto rateTable { get { return Get(); } set { Set(value); } } + + public string status { get { return Get(); } set { Set(value); } } } } \ No newline at end of file diff --git a/Visma.net/Models/SalesOrder.cs b/Visma.net/Models/SalesOrder.cs index 489d038..e84d3de 100644 --- a/Visma.net/Models/SalesOrder.cs +++ b/Visma.net/Models/SalesOrder.cs @@ -159,6 +159,13 @@ public List lines private set => Set(value); } + [JsonProperty] + public List shipments + { + get => Get(defaultValue: new List()); + private set => Set(value); + } + public LocationSummary location { get => Get(defaultValue: new LocationSummary()); diff --git a/Visma.net/Models/SalesOrderShipment.cs b/Visma.net/Models/SalesOrderShipment.cs new file mode 100644 index 0000000..1e86294 --- /dev/null +++ b/Visma.net/Models/SalesOrderShipment.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using ONIT.VismaNetApi.Lib; +using ONIT.VismaNetApi.Models.Enums; + +namespace ONIT.VismaNetApi.Models +{ + public class SalesOrderShipment : DtoProviderBase + { + public string shipmentType + { + get { return Get(); } + set { Set(value); } + } + + public string shipmentNo + { + get { return Get(); } + set { Set(value); } + } + + public DateTime shipmentDate + { + get { return Get(); } + set { Set(value); } + } + + public decimal shippedQty + { + get { return Get(); } + set { Set(value); } + } + + public decimal shippedWeight + { + get { return Get(); } + set { Set(value); } + } + public decimal shippedVolume + { + get { return Get(); } + set { Set(value); } + } + + + public string invoiceType + { + get { return Get(); } + set { Set(value); } + } + + public string invoiceNo + { + get { return Get(); } + set { Set(value); } + } + + public string inventoryDocType + { + get { return Get(); } + set { Set(value); } + } + + public string inventoryRefNo + { + get { return Get(); } + set { Set(value); } + } + } +} \ No newline at end of file diff --git a/Visma.net/Visma.net.csproj b/Visma.net/Visma.net.csproj index c2ed288..c9b284f 100644 --- a/Visma.net/Visma.net.csproj +++ b/Visma.net/Visma.net.csproj @@ -3,7 +3,7 @@ netstandard2.0;net461;net45 Visma.net Copyright © ON IT AS 2014 - 2020 - 3.7.1.0 + 3.7.1.9 Get started with Visma.net Integrations. ON IT AS ON IT AS @@ -19,8 +19,8 @@ https://sync-it.no/Images/on-it_logo.png LICENSE.md - 3.7.1.0 - 3.7.1.0 + 3.7.1.9 + 3.7.1.9 diff --git a/Visma.net/VismaNet.cs b/Visma.net/VismaNet.cs index f1f3468..bc52ca6 100644 --- a/Visma.net/VismaNet.cs +++ b/Visma.net/VismaNet.cs @@ -19,6 +19,7 @@ public class VismaNet : VismaNetDynamicHandler public readonly CustomerDocumentData CustomerDocument; public readonly CustomerInvoiceData CustomerInvoice; public readonly CustomerSalesPriceData CustomerSalesPrice; + public readonly AttributeData Attribute; public readonly CustomerData Customer; public readonly DimensionData Dimension; public readonly SupplierInvoiceData SupplierInvoice; @@ -68,6 +69,7 @@ public VismaNet(int companyId, string token, int branchId = 0) CompanyId = companyId, BranchId = branchId }; + Attribute = new AttributeData(Auth); Customer = new CustomerData(Auth); CustomerInvoice = new CustomerInvoiceData(Auth); Supplier = new SupplierData(Auth); diff --git a/Visma.net/lib/DAta/AttributeData.cs b/Visma.net/lib/DAta/AttributeData.cs new file mode 100644 index 0000000..8a7c030 --- /dev/null +++ b/Visma.net/lib/DAta/AttributeData.cs @@ -0,0 +1,17 @@ +using ONIT.VismaNetApi.Models; +using ONIT.VismaNetApi.Models.Enums; +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Threading.Tasks; + +namespace ONIT.VismaNetApi.Lib.Data +{ + public class AttributeData : BasePaginatedCrudDataClass + { + public AttributeData(VismaNetAuthorization auth) : base(auth) + { + ApiControllerUri = VismaNetControllers.Attribute; + } + } +} \ No newline at end of file diff --git a/Visma.net/lib/VismaNetControllers.cs b/Visma.net/lib/VismaNetControllers.cs index 2466af6..5fb9926 100644 --- a/Visma.net/lib/VismaNetControllers.cs +++ b/Visma.net/lib/VismaNetControllers.cs @@ -6,6 +6,7 @@ internal static class VismaNetControllers public const string Token = "security/api/v2/token"; // Financials + public const string Attribute = "controller/api/v1/attribute"; public const string Attachment = "controller/api/v1/attachment"; public const string Branch = "controller/api/v1/branch"; public const string CashSale = "controller/api/v1/cashsale"; @@ -29,6 +30,7 @@ internal static class VismaNetControllers public const string Location = "controller/api/v1/location"; public const string Payment = "controller/api/v1/payment"; public const string Project = "controller/api/v1/project"; + public const string ProjectTask = "controller/api/v1/projecttask"; public const string SalesOrder = "controller/api/v1/salesorder"; public const string Subaccount = "controller/api/v1/subaccount"; public const string Suppliers = "controller/api/v1/supplier"; From 7def5fd54b76f7f3e2f2bb64ac65c46ff65bb800 Mon Sep 17 00:00:00 2001 From: Anders Yderborg Date: Thu, 22 Oct 2020 16:58:23 +0200 Subject: [PATCH 3/4] Changes to project --- Visma.net/Models/Project.cs | 2 +- Visma.net/Models/ProjectManager.cs | 2 +- Visma.net/Visma.net.csproj | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Visma.net/Models/Project.cs b/Visma.net/Models/Project.cs index 4406767..8f64eaa 100644 --- a/Visma.net/Models/Project.cs +++ b/Visma.net/Models/Project.cs @@ -40,7 +40,7 @@ public Project(string projectNumber) public ProjectManager projectManager { get => Get("projectManger", new ProjectManager()); // Misspelled in Visma API projectManger not projectManager - set => Set(value, "employeeNumber"); + set => Set(value); } public bool restrictEmployees { get { return Get(); } set { Set(value); } } diff --git a/Visma.net/Models/ProjectManager.cs b/Visma.net/Models/ProjectManager.cs index f8e2a84..d2c3f50 100644 --- a/Visma.net/Models/ProjectManager.cs +++ b/Visma.net/Models/ProjectManager.cs @@ -14,7 +14,7 @@ public class ProjectManager : Employee, IProvideCustomDto object IProvideCustomDto.ToDto() { - return new DtoValue(number); + return new DtoValue(employeeNumber); } } } \ No newline at end of file diff --git a/Visma.net/Visma.net.csproj b/Visma.net/Visma.net.csproj index c9b284f..2e13e98 100644 --- a/Visma.net/Visma.net.csproj +++ b/Visma.net/Visma.net.csproj @@ -3,7 +3,7 @@ netstandard2.0;net461;net45 Visma.net Copyright © ON IT AS 2014 - 2020 - 3.7.1.9 + 3.7.1.10 Get started with Visma.net Integrations. ON IT AS ON IT AS @@ -19,8 +19,8 @@ https://sync-it.no/Images/on-it_logo.png LICENSE.md - 3.7.1.9 - 3.7.1.9 + 3.7.1.10 + 3.7.1.10 From c06625def7465758313feb027555d8e4e46e9dfc Mon Sep 17 00:00:00 2001 From: Anders Yderborg Date: Mon, 2 Nov 2020 13:28:33 +0100 Subject: [PATCH 4/4] Added externalLink to SalesorderLine --- Visma.net/Models/SalesOrderLine.cs | 6 ++++++ Visma.net/Visma.net.csproj | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Visma.net/Models/SalesOrderLine.cs b/Visma.net/Models/SalesOrderLine.cs index d0ff5f6..992284d 100644 --- a/Visma.net/Models/SalesOrderLine.cs +++ b/Visma.net/Models/SalesOrderLine.cs @@ -261,5 +261,11 @@ public DescriptiveDto warehouse get => Get(); set => Set(value); } + + public string externalLink + { + get => Get(); + set => Set(value); + } } } \ No newline at end of file diff --git a/Visma.net/Visma.net.csproj b/Visma.net/Visma.net.csproj index 2e13e98..06935d0 100644 --- a/Visma.net/Visma.net.csproj +++ b/Visma.net/Visma.net.csproj @@ -3,7 +3,7 @@ netstandard2.0;net461;net45 Visma.net Copyright © ON IT AS 2014 - 2020 - 3.7.1.10 + 3.7.1.12 Get started with Visma.net Integrations. ON IT AS ON IT AS @@ -19,8 +19,8 @@ https://sync-it.no/Images/on-it_logo.png LICENSE.md - 3.7.1.10 - 3.7.1.10 + 3.7.1.12 + 3.7.1.12