-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show Pending Transactions on Account Details Page
Part of work for #1
- Loading branch information
1 parent
8119896
commit 05ebcdd
Showing
13 changed files
with
240 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using DashAccountingSystem.Data.Models; | ||
|
||
namespace DashAccountingSystem.Models | ||
{ | ||
public class AccountDetailsViewModel | ||
{ | ||
public Account Account { get; set; } | ||
public IEnumerable<AccountTransactionViewModel> PendingTransactions { get; set; } | ||
public PagedResult<AccountTransactionViewModel> Transactions { get; set; } | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
src/DashAccountingSystem/Models/AccountTransactionViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using DashAccountingSystem.Data.Models; | ||
|
||
namespace DashAccountingSystem.Models | ||
{ | ||
public class AccountTransactionViewModel : INumberedJournalEntry | ||
{ | ||
// Journal Entry top-level | ||
public int Id { get; set; } | ||
public int EntryId { get; set; } | ||
public TransactionStatus Status { get; set; } | ||
public string Description { get; set; } | ||
public string Note { get; set; } | ||
public uint? CheckNumber { get; set; } | ||
public DateTime Created { get; set; } | ||
public DateTime? Updated { get; set; } | ||
public DateTime EntryDate { get; set; } | ||
public DateTime? PostDate { get; set; } | ||
public DateTime? CancelDate { get; set; } | ||
|
||
public DateTime Date | ||
{ | ||
get | ||
{ | ||
switch (Status) | ||
{ | ||
case TransactionStatus.Posted: | ||
return PostDate.Value; | ||
case TransactionStatus.Pending: | ||
default: | ||
return EntryDate; | ||
} | ||
} | ||
} | ||
|
||
public AccountingPeriodLiteViewModel Period { get; set; } | ||
|
||
// Account Level | ||
public string AssetType { get; set; } | ||
public decimal Amount { get; set; } | ||
|
||
public AmountType AmountType | ||
{ | ||
get | ||
{ | ||
if (Amount < 0.0m) | ||
return AmountType.Credit; | ||
else | ||
return AmountType.Debit; | ||
} | ||
} | ||
|
||
public decimal? Debit | ||
{ | ||
get | ||
{ | ||
if (AmountType == AmountType.Debit) | ||
return Amount; | ||
|
||
return null; | ||
} | ||
} | ||
|
||
public decimal? Credit | ||
{ | ||
get | ||
{ | ||
if (AmountType == AmountType.Credit) | ||
return -Amount; | ||
|
||
return null; | ||
} | ||
} | ||
|
||
public decimal? PreviousBalance { get; set; } | ||
public decimal? NewBalance { get; set; } | ||
|
||
public static AccountTransactionViewModel FromModel(JournalEntryAccount model) | ||
{ | ||
if (model == null) | ||
return null; | ||
|
||
return new AccountTransactionViewModel() | ||
{ | ||
Id = model.JournalEntry.Id, | ||
EntryId = model.JournalEntry.EntryId, | ||
EntryDate = model.JournalEntry.EntryDate, | ||
Description = model.JournalEntry.Description, | ||
Note = model.JournalEntry.Note, | ||
CheckNumber = model.JournalEntry.CheckNumber, | ||
Created = model.JournalEntry.Created, | ||
Updated = model.JournalEntry.Updated, | ||
PostDate = model.JournalEntry.PostDate, | ||
CancelDate = model.JournalEntry.CancelDate, | ||
Status = model.JournalEntry.Status, | ||
Period = AccountingPeriodLiteViewModel.FromModel(model.JournalEntry.AccountingPeriod), | ||
AssetType = model.AssetType.Name, | ||
Amount = model.Amount, | ||
PreviousBalance = model.PreviousBalance, | ||
NewBalance = model.NewBalance | ||
}; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/DashAccountingSystem/Models/AccountingPeriodLiteViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using DashAccountingSystem.Data.Models; | ||
|
||
namespace DashAccountingSystem.Models | ||
{ | ||
public class AccountingPeriodLiteViewModel | ||
{ | ||
public int Id { get; set; } | ||
public AccountingPeriodType PeriodType { get; set; } | ||
public int Year { get; set; } | ||
public byte Month { get; set; } | ||
public byte Quarter { get; set; } | ||
public string Name { get; set; } | ||
public bool Closed { get; set; } | ||
|
||
public static AccountingPeriodLiteViewModel FromModel(AccountingPeriod model) | ||
{ | ||
if (model == null) | ||
return null; | ||
|
||
return Fill(new AccountingPeriodViewModel(), model); | ||
} | ||
|
||
public static AccountingPeriodLiteViewModel Fill( | ||
AccountingPeriodLiteViewModel viewModel, | ||
AccountingPeriod model) | ||
{ | ||
viewModel.Id = model.Id; | ||
viewModel.PeriodType = model.PeriodType; | ||
viewModel.Year = model.Year; | ||
viewModel.Month = model.Month; | ||
viewModel.Quarter = model.Quarter; | ||
viewModel.Name = model.Name; | ||
viewModel.Closed = model.Closed; | ||
|
||
return viewModel; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace DashAccountingSystem.Models | ||
{ | ||
public interface INumberedJournalEntry | ||
{ | ||
int EntryId { get; } | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
src/DashAccountingSystem/Models/JournalEntryDetailedViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.