EOM work 4
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Swarmops.Basic.Types.Financial;
|
||||
using Swarmops.Common;
|
||||
@@ -171,7 +172,13 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
public FinancialAccountDocument GetMostRecentDocument(FinancialAccountDocumentType documentType)
|
||||
{
|
||||
// TODO: Continue here
|
||||
FinancialAccountDocuments documents = FinancialAccountDocuments.ForAccount(this, documentType);
|
||||
|
||||
if (documents.Count() > 0)
|
||||
{
|
||||
return documents.Last();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,39 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Swarmops.Basic.Types.Financial;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
namespace Swarmops.Logic.Financial
|
||||
{
|
||||
public class FinancialAccountDocuments: PluralBase<FinancialAccountDocuments,FinancialAccountDocument,BasicFinancialAccountDocument>
|
||||
{
|
||||
public static FinancialAccountDocuments ForAccount(FinancialAccount account, FinancialAccountDocumentType typeRequested = FinancialAccountDocumentType.Unknown)
|
||||
{
|
||||
FinancialAccountDocuments result = FromArray(SwarmDb.GetDatabaseForReading().GetFinancialAccountDocuments(account));
|
||||
result.Sort(new FinancialAccountDocumentsSorterByTypeThenDate());
|
||||
|
||||
if (typeRequested != FinancialAccountDocumentType.Unknown)
|
||||
{
|
||||
return (FinancialAccountDocuments) result.Where(doc => doc.Type == typeRequested);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class FinancialAccountDocumentsSorterByTypeThenDate : IComparer<FinancialAccountDocument>
|
||||
{
|
||||
public int Compare(FinancialAccountDocument a, FinancialAccountDocument b)
|
||||
{
|
||||
if (a.Type != b.Type)
|
||||
{
|
||||
return a.Type.CompareTo(b.Type);
|
||||
}
|
||||
|
||||
return (a.ConcernsPeriodStart.CompareTo(b.ConcernsPeriodStart));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user