Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/Domain.LinnApps/Imports/ImportBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public ImportBook(

public string Comments { get; set; }

public string ClearanceComments { get; set; }

public string CustomsEntryCode { get; set; }

public DateTime? CustomsEntryCodeDate { get; set; }
Expand Down Expand Up @@ -198,6 +200,8 @@ public void Update(ImportUpdate update)
this.TransportBillNumber = update.TransportBillNumber;
this.DateReceived = update.DateReceived;
this.DateInstructionSent = update.DateInstructionSent;
this.Comments = update.Comments;
this.ClearanceComments = update.ClearanceComments;

if (update.Period != null && this.Period == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain.LinnApps/Imports/ImportReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private List<CalculationValueModel> SetImportReportModelRows(IEnumerable<ImportB
{
RowId = rowId,
ColumnId = "Sender Country",
TextDisplay = import.Supplier?.CountryCode
TextDisplay = import.Supplier?.Country.CountryCode
Comment thread
andrewfraser73 marked this conversation as resolved.
});
values.Add(
new CalculationValueModel
Expand Down
16 changes: 16 additions & 0 deletions src/Domain.LinnApps/Imports/Models/ImportClearanceInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public ImportClearanceInstruction(ImportMaster master, string toEmailAddress)

public string PVAText { get; set; }

public string[] Comments { get; set; }

public string[] Footer { get; set; }

public ImportMaster Master { get; set; }
Expand All @@ -60,6 +62,8 @@ public ImportClearanceInstruction(ImportMaster master, string toEmailAddress)
// Exists mainly for Linn Belgium instruction which may have EUR + SEK, DKK etc totals
public ICollection<ImportClearanceInstructionTotal> Totals { get; set; }

public bool HasComments => this.Comments != null && this.Comments.Any();

public bool HasIPRAndBRG => this.Sections.Any(s => s.CpcScheme == "IPR") && this.Sections.Any(s => s.CpcScheme == "BRG");

public ICollection<ImportClearanceInstructionTotal> IPRTotals => this.Totals.Where(t => t.CpcScheme == "IPR").ToList();
Expand Down Expand Up @@ -107,6 +111,18 @@ public void AddImportBook(ImportBook importBook, IEnumerable<ImportAuthNumber> i
this.InstructionDate = importBook.DateInstructionSent.Value;
}

if (!string.IsNullOrEmpty(importBook.ClearanceComments))
{
if (!this.HasComments)
{
this.Comments = importBook.ClearanceComments.Split("\n");
}
else
{
this.Comments = this.Comments.Concat(importBook.ClearanceComments.Split("/n")).ToArray();
Comment thread
andrewfraser73 marked this conversation as resolved.
}
}

foreach (var orderDetail in importBook.OrderDetails)
{
var invoice = orderDetail.RsnNumber != null
Expand Down
4 changes: 4 additions & 0 deletions src/Domain.LinnApps/Imports/Models/ImportUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class ImportUpdate

public string TransportBillNumber { get; set; }

public string Comments { get; set; }

public string ClearanceComments { get; set; }

public DateTime? DateReceived { get; set; }

public DateTime? DateInstructionSent { get; set; }
Expand Down
8 changes: 5 additions & 3 deletions src/Domain.LinnApps/Supplier.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Linn.Stores2.Domain.LinnApps
namespace Linn.Stores2.Domain.LinnApps
{
using System;

Expand All @@ -12,10 +12,12 @@ public class Supplier

public string ApprovedCarrier { get; set; }

public string CountryCode { get; set; }

public Country Country { get; set; }

public DateTime? DateClosed { get; set; }

public Address OrderAddress { get; set; }

public string NiceSupplierName => this.OrderAddress?.Addressee ?? this.Name;
Comment thread
andrewfraser73 marked this conversation as resolved.
}
}
41 changes: 17 additions & 24 deletions src/Facade/Extensions/ImportBookSearchResourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,52 +60,45 @@ public static Expression<Func<ImportBook, bool>> ToExpression(this ImportBookSea

if (!string.IsNullOrEmpty(searchResource.DateField))
{
DateTime? fromDate = string.IsNullOrEmpty(searchResource.FromDate) ? null : DateTime.Parse(searchResource.FromDate);
DateTime? toDate = string.IsNullOrEmpty(searchResource.ToDate) ? null : DateTime.Parse(searchResource.ToDate);
DateTime? fromDate = string.IsNullOrEmpty(searchResource.FromDate)
? null
: DateTime.Parse(searchResource.FromDate).Date;
DateTime? toDate = string.IsNullOrEmpty(searchResource.ToDate)
? null
: DateTime.Parse(searchResource.ToDate).Date.AddDays(1).AddTicks(-1);

if (searchResource.DateField == "Date Created")
{
if (fromDate != null && toDate != null)
{
filter = filter.And(ib => ib.DateCreated >= fromDate && ib.DateCreated <= toDate);
}
else if (fromDate != null)
if (fromDate != null)
{
filter = filter.And(ib => ib.DateCreated >= fromDate);
}
else if (toDate != null)

if (toDate != null)
{
filter = filter.And(ib => ib.DateCreated <= toDate);
}
}

if (searchResource.DateField == "Date Received")
else if (searchResource.DateField == "Date Received")
{
if (fromDate != null && toDate != null)
{
filter = filter.And(ib => ib.DateReceived >= fromDate && ib.DateReceived <= toDate);
}
else if (fromDate != null)
if (fromDate != null)
{
filter = filter.And(ib => ib.DateReceived >= fromDate);
}
else if (toDate != null)

if (toDate != null)
{
filter = filter.And(ib => ib.DateReceived <= toDate);
}
}

if (searchResource.DateField == "Customs Date")
else if (searchResource.DateField == "Customs Date")
{
if (fromDate != null && toDate != null)
{
filter = filter.And(ib => ib.CustomsEntryCodeDate >= fromDate && ib.CustomsEntryCodeDate <= toDate);
}
else if (fromDate != null)
if (fromDate != null)
{
filter = filter.And(ib => ib.CustomsEntryCodeDate >= fromDate);
}
else if (toDate != null)

if (toDate != null)
{
filter = filter.And(ib => ib.CustomsEntryCodeDate <= toDate);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Facade/ResourceBuilders/ImportBookResourceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ImportBookResource Build(ImportBook model, IEnumerable<string> claims)
SupplierCountry = model.Supplier != null ?
new CountryResource
{
CountryCode = model.Supplier.CountryCode,
CountryCode = model.Supplier.Country.CountryCode,
Name = model.Supplier.Country?.BestName
Comment thread
andrewfraser73 marked this conversation as resolved.
}
: null,
Expand All @@ -78,6 +78,7 @@ public ImportBookResource Build(ImportBook model, IEnumerable<string> claims)
NumCartons = model.NumCartons,
NumPallets = model.NumPallets,
Comments = model.Comments,
ClearanceComments = model.ClearanceComments,
CustomsEntryCodePrefix = model.CustomsEntryCodePrefix,
Pva = model.Pva,
ExchangeRate = model.ExchangeRate.GetValueOrDefault(),
Expand Down
2 changes: 2 additions & 0 deletions src/Facade/Services/ImportBookFacadeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ protected override async Task UpdateFromResourceAsync(
CustomsEntryCodeDate = string.IsNullOrEmpty(updateResource.CustomsEntryCodeDate) ? null : Convert.ToDateTime(updateResource.CustomsEntryCodeDate),
CustomsEntryCodePrefix = updateResource.CustomsEntryCodePrefix,
TransportBillNumber = updateResource.TransportBillNumber,
Comments = updateResource.Comments,
ClearanceComments = updateResource.ClearanceComments,
DateInstructionSent = string.IsNullOrEmpty(updateResource.DateInstructionSent) ? null : Convert.ToDateTime(updateResource.DateInstructionSent),
DateReceived = string.IsNullOrEmpty(updateResource.DateReceived) ? null : Convert.ToDateTime(updateResource.DateReceived),
Period = entity.Period,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override async Task<ImportBook> FindByIdAsync(int key)
.Include(r => r.OrderDetails).ThenInclude(o => o.Rsn).ThenInclude(r => r.AllegedReason)
.Include(i => i.InvoiceDetails)
.Include(i => i.PostEntries)
Comment thread
andrewfraser73 marked this conversation as resolved.
.Include(i => i.Supplier).ThenInclude(s => s.Country)
.Include(i => i.Supplier).ThenInclude(s => s.OrderAddress).ThenInclude(s => s.Country)
.Include(i => i.Carrier)
.Include(i => i.CreatedBy)
.Include(i => i.ContactEmployee)
Expand All @@ -47,6 +47,7 @@ public override IQueryable<ImportBook> FilterBy(
.Include(i => i.InvoiceDetails)
.Include(r => r.OrderDetails).ThenInclude(o => o.ImportBookCpcNumber)
.Include(i => i.Supplier).ThenInclude(s => s.Country)
.Include(i => i.Supplier).ThenInclude(s => s.OrderAddress).ThenInclude(a => a.Country)
.Include(i => i.Carrier)
.Include(i => i.CreatedBy);
}
Expand Down
23 changes: 12 additions & 11 deletions src/Persistence.LinnApps/ServiceDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,11 +1219,11 @@ private static void BuildSuppliers(ModelBuilder builder)
q.ToTable("SUPPLIERS");
q.Property(e => e.Id).HasColumnName("SUPPLIER_ID");
q.Property(e => e.Name).HasColumnName("SUPPLIER_NAME").HasMaxLength(50);
q.Property(e => e.CountryCode).HasColumnName("COUNTRY");
q.Property(e => e.DateClosed).HasColumnName("DATE_CLOSED");
q.Property(s => s.ApprovedCarrier).HasColumnName("APPROVED_CARRIER");
q.Property(s => s.AccountingCompany).HasColumnName("ACCOUNTING_COMPANY").HasMaxLength(10);
q.HasOne(s => s.Country).WithMany().HasForeignKey(s => s.CountryCode);
q.HasOne(s => s.Country).WithMany().HasForeignKey("COUNTRY");
q.HasOne(o => o.OrderAddress).WithMany().HasForeignKey("ORD_ADDRESS_ID");
}

private static void BuildImportBooks(ModelBuilder builder)
Expand Down Expand Up @@ -1257,6 +1257,7 @@ private static void BuildImportBooks(ModelBuilder builder)
q.Property(e => e.NumCartons).HasColumnName("NUM_CARTONS");
q.Property(e => e.NumPallets).HasColumnName("NUM_PALLETS");
q.Property(e => e.Comments).HasColumnName("COMMENTS").HasMaxLength(2000);
q.Property(e => e.ClearanceComments).HasColumnName("CLEARANCE_COMMENTS").HasMaxLength(2000);
q.Property(e => e.CreatedById).HasColumnName("CREATED_BY");
q.Property(e => e.CustomsEntryCodePrefix).HasColumnName("CUSTOMS_ENTRY_CODE_PREFIX").HasMaxLength(3);
q.Property(e => e.Pva).HasColumnName("PVA").HasMaxLength(1);
Expand All @@ -1269,14 +1270,14 @@ private static void BuildImportBooks(ModelBuilder builder)
.HasForeignKey(detail => detail.ImportBookId);
q.HasMany(t => t.PostEntries).WithOne()
.HasForeignKey(detail => detail.ImportBookId);
q.HasOne(d => d.Supplier).WithOne().HasForeignKey<ImportBook>(s => s.SupplierId);
q.HasOne(d => d.Carrier).WithOne().HasForeignKey<ImportBook>(s => s.CarrierId);
q.HasOne(d => d.CreatedBy).WithOne().HasForeignKey<ImportBook>(s => s.CreatedById);
q.HasOne(d => d.Currency).WithOne().HasForeignKey<ImportBook>(s => s.CurrencyCode);
q.HasOne(d => d.Period).WithOne().HasForeignKey<ImportBook>(s => s.PeriodNumber);
q.HasOne(d => d.BaseCurrency).WithOne().HasForeignKey<ImportBook>("BASE_CURRENCY");
q.HasOne(d => d.ExchangeCurrency).WithOne().HasForeignKey<ImportBook>("EXCHANGE_CURRENCY");
q.HasOne(d => d.ContactEmployee).WithOne().HasForeignKey<ImportBook>("CONTACT_EMPLOYEE");
q.HasOne(d => d.Supplier).WithMany().HasForeignKey(s => s.SupplierId);
q.HasOne(d => d.Carrier).WithMany().HasForeignKey(s => s.CarrierId);
q.HasOne(d => d.CreatedBy).WithMany().HasForeignKey(s => s.CreatedById);
q.HasOne(d => d.Currency).WithMany().HasForeignKey(s => s.CurrencyCode);
q.HasOne(d => d.Period).WithMany().HasForeignKey(s => s.PeriodNumber);
q.HasOne(d => d.BaseCurrency).WithMany().HasForeignKey("BASE_CURRENCY");
q.HasOne(d => d.ExchangeCurrency).WithMany().HasForeignKey("EXCHANGE_CURRENCY");
q.HasOne(d => d.ContactEmployee).WithMany().HasForeignKey("CONTACT_EMPLOYEE");
}

private static void BuildImportBookInvoiceDetails(ModelBuilder builder)
Expand Down Expand Up @@ -1384,7 +1385,7 @@ private static void BuildSalesArticles(ModelBuilder builder)
e.Property(a => a.Description).HasColumnName("INVOICE_DESCRIPTION");
e.Property(a => a.TariffId).HasColumnName("TARIFF_ID").HasMaxLength(3);
e.Property(a => a.Weight).HasColumnName("WEIGHT").HasMaxLength(10);
e.HasOne(a => a.Tariff).WithOne().HasForeignKey<SalesArticle>(x => x.TariffId);
e.HasOne(a => a.Tariff).WithMany().HasForeignKey(x => x.TariffId);
e.HasOne(a => a.CountryOfOrigin).WithMany().HasForeignKey("COUNTRY_CODE");
}

Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Imports/ImportBookResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class ImportBookResource : HypermediaResource

public string Comments { get; set; }

public string ClearanceComments { get; set; }

public string Currency { get; set; }

public string BaseCurrency { get; set; }
Expand Down
36 changes: 36 additions & 0 deletions src/Service.Host/client/src/components/imports/CommentsTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { InputField } from '@linn-it/linn-form-components-library';

function CommentsTab({ importBook, canChange, handleFieldChange }) {
return (
<>
<Grid container spacing={1}>
<Grid size={12}>
<InputField
value={importBook.comments}
fullWidth
rows={6}
label="Comments"
propertyName="comments"
onChange={handleFieldChange}
disabled={!canChange}
/>
</Grid>
<Grid size={12}>
<InputField
value={importBook.clearanceComments}
fullWidth
rows={6}
label="Clearance Comments"
propertyName="clearanceComments"
onChange={handleFieldChange}
disabled={!canChange}
/>
</Grid>
</Grid>
</>
);
}

export default CommentsTab;
24 changes: 13 additions & 11 deletions src/Service.Host/client/src/components/imports/CreateTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,19 @@ function CreateTab() {
)}
</Grid>
<Grid size={2}>
<Button
onClick={addClick}
variant="outlined"
style={{ marginTop: '29px' }}
disabled={
(importType === 'RSN' && (!rsnNumber || rsnLoading)) ||
(importType === 'PO' && (!purchaseOrderNumber || purchaseOrderLoading))
}
>
Add
</Button>
{(importType === 'RSN' || importType === 'PO') && (
<Button
onClick={addClick}
variant="outlined"
style={{ marginTop: '29px' }}
disabled={
(importType === 'RSN' && (!rsnNumber || rsnLoading)) ||
(importType === 'PO' && (!purchaseOrderNumber || purchaseOrderLoading))
}
>
Add
</Button>
)}
</Grid>
<Grid size={4}></Grid>
{(rsnLoading || purchaseOrderLoading) && (
Expand Down
Loading
Loading