Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #144

Merged
merged 6 commits into from
Nov 4, 2020
Merged

Dev #144

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Visma.net/Models/Attribute.cs
Original file line number Diff line number Diff line change
@@ -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<string>();
set => Set(value);
}
public string description
{
get => Get<string>();
set => Set(value);
}
public string controlType
{
get => Get<string>();
set => Set(value);
}
public bool Internal
{
get => Get<bool>();
set => Set(value);
}
public string entryMask
{
get => Get<string>();
set => Set(value);
}
public string regExp
{
get => Get<string>();
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<AttributeDetails> details
{
get => Get(defaultValue: new List<AttributeDetails>());
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));
}
}
}
48 changes: 48 additions & 0 deletions Visma.net/Models/AttributeDetails.cs
Original file line number Diff line number Diff line change
@@ -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
omelhus marked this conversation as resolved.
Show resolved Hide resolved
{
public AttributeDetails()
{
DtoFields.Add("operation", new NotDto<ApiOperation>(ApiOperation.Insert));
}
[JsonIgnore]
public ApiOperation operation
{
get => Get(defaultValue: new NotDto<ApiOperation>(ApiOperation.Insert)).Value;
set => Set(new NotDto<ApiOperation>(value));
}

public string valueId
{
get => Get<string>();
set => Set(value);
}
public string description
{
get => Get<string>();
set => Set(value);
}
public int sortOrder
{
get => Get<int>();
set => Set(value);
}
public bool disabled
{
get => Get<bool>();
set => Set(value);
}

[JsonProperty] public string errorInfo { get; private set; }
}
}
53 changes: 53 additions & 0 deletions Visma.net/Models/CustomDto/ContactInvoice.cs
Original file line number Diff line number Diff line change
@@ -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<string>();
set => Set(value?.Trim());
}

public string businessName
{
get => Get<string>();
set => Set(value?.Trim());
}
public string attention
{
get => Get<string>();
set => Set(value?.Trim());
}

public string phone1
{
get => Get<string>();
set => Set(value?.Trim());
}
public bool overrideContact
{
get => Get<bool>();
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();
}
}
}
56 changes: 56 additions & 0 deletions Visma.net/Models/CustomDto/SubaccountProject.cs
Original file line number Diff line number Diff line change
@@ -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<Segment> _segments;

[JsonProperty]
public string id { get; private set; }
[JsonProperty]
public List<Segment> segments
{
get => _segments ?? (_segments = new List<Segment>());
private set => _segments = value;
}
/// <summary>
/// Sets a segment (department, project) for an invoice line. Remember that you have to set ALL segments for a line.
/// </summary>
/// <param name="segmentId"></param>
/// <returns></returns>
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});
}
}
}
12 changes: 12 additions & 0 deletions Visma.net/Models/CustomerInvoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
20 changes: 17 additions & 3 deletions Visma.net/Models/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -31,12 +37,20 @@ public Project()
public string description { get { return Get<string>(); } set { Set(value); } }
public DateTime startDate { get { return Get<DateTime>(); } set { Set(value); } }
public DateTime endDate { get { return Get<DateTime>(); } set { Set(value); } }
[JsonProperty]
public ProjectManager projectManager { get { return Get<ProjectManager>(); } private set { Set(value); } }

public ProjectManager projectManager {
angoyd marked this conversation as resolved.
Show resolved Hide resolved
get => Get("projectManger", new ProjectManager()); // Misspelled in Visma API projectManger not projectManager
set => Set(value);
}

public bool restrictEmployees { get { return Get<bool>(); } set { Set(value); } }
public bool restrictEquipment { get { return Get<bool>(); } set { Set(value); } }
public Visibility visibility { get { return Get(defaultValue:new Visibility()); } set { Set(value); } }
public DescriptiveDto defSub { get { return Get<DescriptiveDto>(); } set { Set(value); } }
public CustomDto.SubaccountProject defSub
{
get => Get("defSub",defaultValue: new CustomDto.SubaccountProject());
set => Set(value);
}
public string billingPeriod { get { return Get<string>(); } set { Set(value); } }
//public DescriptiveDto customerLocation { get { return Get<DescriptiveDto>(); } set { Set(value); } }
public DescriptiveDto allocationRule { get { return Get<DescriptiveDto>(); } set { Set(value); } }
Expand Down
2 changes: 1 addition & 1 deletion Visma.net/Models/ProjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ProjectManager : Employee, IProvideCustomDto

object IProvideCustomDto.ToDto()
{
return new DtoValue(number);
return new DtoValue(employeeNumber);
}
}
}
2 changes: 2 additions & 0 deletions Visma.net/Models/ProjectTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ public ApiOperation operation
public DateTime plannedEnd { get { return Get<DateTime>(); } set { Set(value); } }
public DateTime startDate { get { return Get<DateTime>(); } set { Set(value); } }
public DescriptiveDto rateTable { get { return Get<DescriptiveDto>(); } set { Set(value); } }

public string status { get { return Get<string>(); } set { Set(value); } }
}
}
7 changes: 7 additions & 0 deletions Visma.net/Models/SalesOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ public List<SalesOrderLine> lines
private set => Set(value);
}

[JsonProperty]
public List<SalesOrderShipment> shipments
{
get => Get(defaultValue: new List<SalesOrderShipment>());
private set => Set(value);
}

public LocationSummary location
{
get => Get(defaultValue: new LocationSummary());
Expand Down
6 changes: 6 additions & 0 deletions Visma.net/Models/SalesOrderLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,11 @@ public DescriptiveDto warehouse
get => Get<DescriptiveDto>();
set => Set(value);
}

public string externalLink
{
get => Get<string>();
set => Set(value);
}
}
}
Loading