diff --git a/SmartPower.Application/Entity/DbContext.cs b/SmartPower.Application/Entity/DbContext.cs new file mode 100644 index 0000000..77a9620 --- /dev/null +++ b/SmartPower.Application/Entity/DbContext.cs @@ -0,0 +1,249 @@ +using Microsoft.EntityFrameworkCore; +using SmartPower.Application.Entity.Model; + +namespace SmartPower.Application.Entity +{ + public partial class DbContext : Microsoft.EntityFrameworkCore.DbContext + { + public DbContext() { } + + public DbContext(DbContextOptions options) : base(options) { } + + public virtual DbSet TReversalsBulkLists { get; set; } + public virtual DbSet TInvoices { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + // TODO : remove + optionsBuilder.UseSqlServer("Server=.\\;Database=Master_DB_DEMO;Integrated Security=True"); + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.RevId); + + entity.ToTable("tReversals_Bulk_List"); + + entity.Property(e => e.RevId).HasColumnName("Rev_ID"); + + entity.Property(e => e.NewSpInvNumber).HasColumnName("New_SpInvNumber"); + + entity.Property(e => e.OrgSpinvNumber).HasColumnName("Org_SPInvNumber"); + + entity.Property(e => e.RevResults) + .HasMaxLength(100) + .HasColumnName("Rev_Results"); + + entity.Property(e => e.RevStatus) + .HasMaxLength(100) + .HasColumnName("Rev_Status"); + + entity.Property(e => e.UserName).HasMaxLength(100); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.SpinvNumber); + + entity.ToTable("tInvoices"); + + entity.Property(e => e.SpinvNumber).HasColumnName("SPInvNumber"); + + entity.Property(e => e.AcadjFactor) + .HasColumnName("ACAdjFactor") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.AccountNo).HasMaxLength(200); + + entity.Property(e => e.ApplySitePpd) + .HasColumnName("Apply_Site_PPD") + .HasDefaultValueSql("((1))"); + + entity.Property(e => e.ArchiveDate).HasColumnType("date"); + + entity.Property(e => e.ClientCode).HasMaxLength(10); + + entity.Property(e => e.CostsFees).HasDefaultValueSql("((0))"); + + entity.Property(e => e.CostsNetwork).HasDefaultValueSql("((0))"); + + entity.Property(e => e.CostsUsage).HasDefaultValueSql("((0))"); + + entity.Property(e => e.CreditInv).HasDefaultValueSql("((0))"); + + entity.Property(e => e.EdiId).HasColumnName("EDI_ID"); + + entity.Property(e => e.FixedKva) + .HasColumnName("FixedKVA") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.GstFreeCharges).HasColumnName("GST_Free_Charges"); + + entity.Property(e => e.InvAmount) + .HasColumnType("money") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvAmountExGst) + .HasColumnType("money") + .HasColumnName("InvAmountExGST"); + + entity.Property(e => e.InvAmountGst) + .HasColumnType("money") + .HasColumnName("InvAmountGST"); + + entity.Property(e => e.InvAmountSoa) + .HasColumnName("InvAmountSOA") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvAmountToPay) + .HasColumnType("money") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvAmountToPayExGst) + .HasColumnType("money") + .HasColumnName("InvAmountToPayExGST"); + + entity.Property(e => e.InvAmountToPayGst) + .HasColumnType("money") + .HasColumnName("InvAmountToPayGST"); + + entity.Property(e => e.InvArchived) + .HasColumnName("Inv_Archived") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvDate).HasColumnType("date"); + + entity.Property(e => e.InvDiscount) + .HasColumnType("money") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvDiscountExGst) + .HasColumnType("money") + .HasColumnName("InvDiscountExGST"); + + entity.Property(e => e.InvDiscountGst) + .HasColumnType("money") + .HasColumnName("InvDiscountGST"); + + entity.Property(e => e.InvDueDate).HasColumnType("date"); + + entity.Property(e => e.InvEndDate).HasColumnType("date"); + + entity.Property(e => e.InvEnteredDate) + .HasColumnType("date") + .HasDefaultValueSql("(getdate())"); + + entity.Property(e => e.InvGst) + .HasColumnType("money") + .HasColumnName("InvGST") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvLinesArchived).HasColumnName("Inv_Lines_Archived"); + + entity.Property(e => e.InvNoPayfile).HasColumnName("InvNo_Payfile"); + + entity.Property(e => e.InvNotes).HasMaxLength(255); + + entity.Property(e => e.InvNumber) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.InvOpenBalType).HasMaxLength(10); + + entity.Property(e => e.InvOpeningBalance) + .HasColumnType("money") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvStartDate).HasColumnType("date"); + + entity.Property(e => e.InvSubTotal) + .HasColumnType("money") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.InvTotal) + .HasColumnType("money") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.Losses).HasDefaultValueSql("((0))"); + + entity.Property(e => e.NtwkFixed).HasDefaultValueSql("((0))"); + + entity.Property(e => e.ObGst) + .HasColumnName("OB_GST") + .HasDefaultValueSql("((1))"); + + entity.Property(e => e.ObGstFree) + .HasColumnName("OB_GST_Free") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.Obnotes) + .HasMaxLength(255) + .HasColumnName("OBNotes"); + + entity.Property(e => e.OpeningBalanceExGst) + .HasColumnType("money") + .HasColumnName("OpeningBalanceExGST"); + + entity.Property(e => e.OpeningBalanceGst) + .HasColumnType("money") + .HasColumnName("OpeningBalanceGST"); + + entity.Property(e => e.OrgId).HasColumnName("Org_ID"); + + entity.Property(e => e.ParentAccNum) + .HasMaxLength(255) + .HasColumnName("Parent_Acc_Num"); + + entity.Property(e => e.ParentSpin).HasColumnName("Parent_SPIN"); + + entity.Property(e => e.PdfInvAmountToPay) + .HasColumnType("money") + .HasColumnName("PDF_InvAmountToPay"); + + entity.Property(e => e.PpdGst) + .HasColumnName("PPD_GST") + .HasDefaultValueSql("((1))"); + + entity.Property(e => e.PpdGstFree) + .HasColumnName("PPD_GST_Free") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.PpdIgnoreSiteDiscount) + .HasColumnName("PPD_Ignore_Site_Discount") + .HasDefaultValueSql("((0))"); + + entity.Property(e => e.ReadTypeCode) + .HasMaxLength(10) + .HasDefaultValueSql("(N'U')"); + + entity.Property(e => e.RetailerCode) + .IsRequired() + .HasMaxLength(20); + + entity.Property(e => e.SpinvNumberOrig).HasColumnName("SPInvNumberOrig"); + + entity.Property(e => e.Split).HasColumnName("Split%"); + + entity.Property(e => e.SpotRate).HasDefaultValueSql("((0))"); + + entity.Property(e => e.StatementNumber).HasMaxLength(255); + + entity.Property(e => e.SysInvoicesTimestamp) + .IsRequired() + .IsRowVersion() + .IsConcurrencyToken() + .HasColumnName("Sys_Invoices_Timestamp"); + + entity.Property(e => e.UnitTotal).HasColumnName("Unit_Total"); + }); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + } +} \ No newline at end of file diff --git a/SmartPower.Application/Entity/Model/Projection/BulkReversalSummary.cs b/SmartPower.Application/Entity/Model/Projection/BulkReversalSummary.cs new file mode 100644 index 0000000..9b27fbf --- /dev/null +++ b/SmartPower.Application/Entity/Model/Projection/BulkReversalSummary.cs @@ -0,0 +1,10 @@ +namespace SmartPower.Application.Entity.Model.Projection +{ + public class BulkReversalSummary + { + public int? NewSpInvNumber { get; set; } + public int? OrgSpinvNumber { get; set; } + public string RevStatus { get; set; } + public string RevResults { get; set; } + } +} diff --git a/SmartPower.Data.Entity/Model/DeleteVBvCheckInvoiceNilReversal.cs b/SmartPower.Application/Entity/Model/Projection/InvoiceSummary.cs similarity index 60% rename from SmartPower.Data.Entity/Model/DeleteVBvCheckInvoiceNilReversal.cs rename to SmartPower.Application/Entity/Model/Projection/InvoiceSummary.cs index 8425d1d..029812a 100644 --- a/SmartPower.Data.Entity/Model/DeleteVBvCheckInvoiceNilReversal.cs +++ b/SmartPower.Application/Entity/Model/Projection/InvoiceSummary.cs @@ -1,18 +1,16 @@ using System; -using System.Collections.Generic; -#nullable disable - -namespace SmartPower.Data.Entity.Model +namespace SmartPower.Application.Entity.Model.Projection { - public partial class DeleteVBvCheckInvoiceNilReversal + public class InvoiceSummary { - public int SiteNo { get; set; } - public int BatchNo { get; set; } + public string InvNumber { get; set; } public int SpinvNumber { get; set; } + public int BatchNo { get; set; } + public int SiteNo { get; set; } + public string RetailerCode { get; set; } public DateTime? InvStartDate { get; set; } public DateTime? InvEndDate { get; set; } - public string InvNumber { get; set; } - public string InputTypeCode { get; set; } + public decimal? InvOpeningBalance { get; set; } } } diff --git a/SmartPower.Data.Entity/Model/TInvoice.cs b/SmartPower.Application/Entity/Model/TInvoice.cs similarity index 96% rename from SmartPower.Data.Entity/Model/TInvoice.cs rename to SmartPower.Application/Entity/Model/TInvoice.cs index 60e2ed6..aaf1ee1 100644 --- a/SmartPower.Data.Entity/Model/TInvoice.cs +++ b/SmartPower.Application/Entity/Model/TInvoice.cs @@ -3,7 +3,7 @@ #nullable disable -namespace SmartPower.Data.Entity.Model +namespace SmartPower.Application.Entity.Model { public partial class TInvoice { @@ -76,7 +76,5 @@ public partial class TInvoice public bool? ObGst { get; set; } public bool? PpdGst { get; set; } public bool? ApplySitePpd { get; set; } - - public virtual TRetailer RetailerCodeNavigation { get; set; } } } diff --git a/SmartPower.Data.Entity/Model/TReversalsBulkList.cs b/SmartPower.Application/Entity/Model/TReversalsBulkList.cs similarity index 89% rename from SmartPower.Data.Entity/Model/TReversalsBulkList.cs rename to SmartPower.Application/Entity/Model/TReversalsBulkList.cs index a3df29e..ec4ea7b 100644 --- a/SmartPower.Data.Entity/Model/TReversalsBulkList.cs +++ b/SmartPower.Application/Entity/Model/TReversalsBulkList.cs @@ -3,7 +3,7 @@ #nullable disable -namespace SmartPower.Data.Entity.Model +namespace SmartPower.Application.Entity.Model { public partial class TReversalsBulkList { diff --git a/SmartPower.Data.Entity/Repository/BulkReversal.cs b/SmartPower.Application/Entity/Repository/BulkReversal.cs similarity index 73% rename from SmartPower.Data.Entity/Repository/BulkReversal.cs rename to SmartPower.Application/Entity/Repository/BulkReversal.cs index 2b0da06..ab60988 100644 --- a/SmartPower.Data.Entity/Repository/BulkReversal.cs +++ b/SmartPower.Application/Entity/Repository/BulkReversal.cs @@ -1,11 +1,13 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading.Tasks; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; +using SmartPower.Application.Entity.Model.Projection; -namespace SmartPower.Data.Entity.Repository +namespace SmartPower.Application.Entity.Repository { public class BulkReversal : IBulkReversal { @@ -16,9 +18,19 @@ public BulkReversal(DbContext dbContext) _dbContext = dbContext; } - public async Task> GetReversalList(string userName) + public async Task> GetBulkReversals(string userName) { - return await _dbContext.TReversalsBulkLists.AsNoTracking().Where(r => r.UserName == userName).ToListAsync(); + return await _dbContext.TReversalsBulkLists + .AsNoTracking() + .Where(b => b.UserName == userName) + .Select(b => new BulkReversalSummary + { + RevStatus = b.RevStatus, + RevResults = b.RevResults, + NewSpInvNumber = b.NewSpInvNumber, + OrgSpinvNumber = b.OrgSpinvNumber + }) + .ToListAsync(); } public async Task CreateReversalListItem(string userName, int orgSpinvNumber) diff --git a/SmartPower.Data.Entity/Repository/Constant.cs b/SmartPower.Application/Entity/Repository/Constant.cs similarity index 93% rename from SmartPower.Data.Entity/Repository/Constant.cs rename to SmartPower.Application/Entity/Repository/Constant.cs index cca7f56..27bcceb 100644 --- a/SmartPower.Data.Entity/Repository/Constant.cs +++ b/SmartPower.Application/Entity/Repository/Constant.cs @@ -1,4 +1,4 @@ -namespace SmartPower.Data.Entity.Repository +namespace SmartPower.Application.Entity.Repository { public static class Constant { diff --git a/SmartPower.Data.Entity/Repository/IBulkReversal.cs b/SmartPower.Application/Entity/Repository/IBulkReversal.cs similarity index 68% rename from SmartPower.Data.Entity/Repository/IBulkReversal.cs rename to SmartPower.Application/Entity/Repository/IBulkReversal.cs index e348685..f5c833c 100644 --- a/SmartPower.Data.Entity/Repository/IBulkReversal.cs +++ b/SmartPower.Application/Entity/Repository/IBulkReversal.cs @@ -1,11 +1,12 @@ using System.Collections.Generic; using System.Threading.Tasks; +using SmartPower.Application.Entity.Model.Projection; -namespace SmartPower.Data.Entity.Repository +namespace SmartPower.Application.Entity.Repository { public interface IBulkReversal { - Task> GetReversalList(string userName); + Task> GetBulkReversals(string userName); Task CreateReversalListItem(string userName, int orgSpinvNumber); Task ClearReversals(string userName); Task UpdateReversalStatus(string userName); diff --git a/SmartPower.Application/Entity/Repository/IInvoice.cs b/SmartPower.Application/Entity/Repository/IInvoice.cs new file mode 100644 index 0000000..617672a --- /dev/null +++ b/SmartPower.Application/Entity/Repository/IInvoice.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using SmartPower.Application.Entity.Model.Projection; + +namespace SmartPower.Application.Entity.Repository +{ + public interface IInvoice + { + Task GetInvoice(int spInvoiceNumber); + Task> GetInvoices(List spInvoiceNumbers); + } +} \ No newline at end of file diff --git a/SmartPower.Application/Entity/Repository/Invoice.cs b/SmartPower.Application/Entity/Repository/Invoice.cs new file mode 100644 index 0000000..0192bd5 --- /dev/null +++ b/SmartPower.Application/Entity/Repository/Invoice.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using SmartPower.Application.Entity.Model.Projection; + +namespace SmartPower.Application.Entity.Repository +{ + public class Invoice : IInvoice + { + private readonly DbContext _dbContext; + + public Invoice(DbContext dbContext) + { + _dbContext = dbContext; + } + + public async Task GetInvoice(int spInvoiceNumber) + { + return await _dbContext.TInvoices + .AsNoTracking() + .Select(s => new InvoiceSummary + { + SpinvNumber = s.SpinvNumber, + BatchNo = s.BatchNo, + InvEndDate = s.InvEndDate, + InvNumber = s.InvNumber, + InvOpeningBalance = s.InvOpeningBalance, + InvStartDate = s.InvStartDate, + RetailerCode = s.RetailerCode, + SiteNo = s.SiteNo + }) + .SingleOrDefaultAsync(i => i.SpinvNumber == spInvoiceNumber); + } + + public async Task> GetInvoices(List spInvoiceNumbers) + { + return await _dbContext.TInvoices + .AsNoTracking() + .Where(i => spInvoiceNumbers.Contains(i.SpinvNumber)) + .Select(s => new InvoiceSummary + { + SpinvNumber = s.SpinvNumber, + BatchNo = s.BatchNo, + InvEndDate = s.InvEndDate, + InvNumber = s.InvNumber, + InvOpeningBalance = s.InvOpeningBalance, + InvStartDate = s.InvStartDate, + RetailerCode = s.RetailerCode, + SiteNo = s.SiteNo + }) + .ToListAsync(); + } + } +} diff --git a/SmartPower.Application/Service/BulkReversal/CsvExport.cs b/SmartPower.Application/Service/BulkReversal/CsvExport.cs new file mode 100644 index 0000000..4fb6743 --- /dev/null +++ b/SmartPower.Application/Service/BulkReversal/CsvExport.cs @@ -0,0 +1,31 @@ +using System.Text; +using System.Threading.Tasks; + +namespace SmartPower.Application.Service.BulkReversal +{ + public class CsvExport : ICsvExport + { + private readonly Entity.Repository.IBulkReversal _bulkReversalRepository; + + public CsvExport(Entity.Repository.IBulkReversal bulkReversalRepository) + { + _bulkReversalRepository = bulkReversalRepository; + } + + public async Task GenerateCsvStringExport(string userName) + { + var bulkReversals = await _bulkReversalRepository.GetBulkReversals(userName); + + var stringBuilder = new StringBuilder(); + + stringBuilder.AppendLine(Common.Constant.BulkReversal.ExportStringHeaders); + + foreach (var bulkReversal in bulkReversals) + { + stringBuilder.AppendLine($"{bulkReversal.RevResults},{bulkReversal.RevStatus},{bulkReversal.NewSpInvNumber},{bulkReversal.OrgSpinvNumber}"); + } + + return stringBuilder.ToString(); + } + } +} diff --git a/SmartPower.Application/Service/BulkReversal/ICsvExport.cs b/SmartPower.Application/Service/BulkReversal/ICsvExport.cs new file mode 100644 index 0000000..9451012 --- /dev/null +++ b/SmartPower.Application/Service/BulkReversal/ICsvExport.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace SmartPower.Application.Service.BulkReversal +{ + public interface ICsvExport + { + Task GenerateCsvStringExport(string userName); + } +} \ No newline at end of file diff --git a/SmartPower.Data.Entity/SmartPower.Data.Entity.csproj b/SmartPower.Application/SmartPower.Application.csproj similarity index 76% rename from SmartPower.Data.Entity/SmartPower.Data.Entity.csproj rename to SmartPower.Application/SmartPower.Application.csproj index 096e20d..c15f978 100644 --- a/SmartPower.Data.Entity/SmartPower.Data.Entity.csproj +++ b/SmartPower.Application/SmartPower.Application.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -12,4 +12,8 @@ + + + + diff --git a/SmartPower.Client.Blazor.Test/Components/BulkReversalList.cs b/SmartPower.Client.Blazor.Test/Components/BulkReversalList.cs index 61c4469..f67510b 100644 --- a/SmartPower.Client.Blazor.Test/Components/BulkReversalList.cs +++ b/SmartPower.Client.Blazor.Test/Components/BulkReversalList.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; -using SmartPower.Domain.Service; +using SmartPower.Application.Entity.Repository; namespace SmartPower.Client.Blazor.Test.Components { @@ -12,8 +12,8 @@ namespace SmartPower.Client.Blazor.Test.Components [Category("BulkReversalList")] public class BulkReversalList : FixtureBase { - private Mock _bulkReversalService; - private List _bulkReversalModels; + private Mock _bulkReversalRepository; + private List _bulkReversalModels; private Bunit.TestContext _testContext; @@ -22,8 +22,8 @@ public void Setup() { _testContext = new Bunit.TestContext(); - _bulkReversalService = new Mock(); - _bulkReversalModels = CreateMany(Common.Constant.ItemCount); + _bulkReversalRepository = new Mock(); + _bulkReversalModels = CreateMany(Common.Constant.ItemCount); } [OneTimeTearDown] @@ -35,10 +35,10 @@ public void TearDown() [Test] public async Task Component_Renders_Expected_Reversals() { - _bulkReversalService.Setup(b => b.GetReversalList(Common.Constant.CurrentUser)).ReturnsAsync(_bulkReversalModels); + _bulkReversalRepository.Setup(b => b.GetBulkReversals(Common.Constant.CurrentUser)).ReturnsAsync(_bulkReversalModels); _testContext.Services.AddScoped(x => Mapper); - _testContext.Services.AddScoped(x => _bulkReversalService.Object); + _testContext.Services.AddScoped(x => _bulkReversalRepository.Object); var component = _testContext.RenderComponent(); @@ -47,7 +47,7 @@ public async Task Component_Renders_Expected_Reversals() Assert.IsTrue(tableRows.Count == Common.Constant.ItemCount + tableHeaderRow); - _bulkReversalService.Verify(b => b.GetReversalList(Common.Constant.CurrentUser), Times.Once); + _bulkReversalRepository.Verify(b => b.GetBulkReversals(Common.Constant.CurrentUser), Times.Once); } } } diff --git a/SmartPower.Client.Blazor.Test/Pages/BulkReversalInput.cs b/SmartPower.Client.Blazor.Test/Pages/BulkReversalInput.cs index 68aa0fd..50eccc9 100644 --- a/SmartPower.Client.Blazor.Test/Pages/BulkReversalInput.cs +++ b/SmartPower.Client.Blazor.Test/Pages/BulkReversalInput.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; -using SmartPower.Domain.Service; +using SmartPower.Application.Entity.Repository; namespace SmartPower.Client.Blazor.Test.Pages { @@ -12,7 +12,7 @@ namespace SmartPower.Client.Blazor.Test.Pages [Category("BulkReversalInput")] public class BulkReversalInput : FixtureBase { - private Mock _bulkReversalService; + private Mock _bulkReversalRepository; private Mock _navigationManger; private Bunit.TestContext _testContext; @@ -23,7 +23,7 @@ public void Setup() { _testContext = new Bunit.TestContext(); - _bulkReversalService = new Mock(); + _bulkReversalRepository = new Mock(); _navigationManger = new Mock(); } @@ -38,10 +38,10 @@ public async Task Page_Is_Able_To_Submit_Bulk_Reversal() { var orgSpin = Create(); - _bulkReversalService.Setup(b => b.CreateReversal(Common.Constant.CurrentUser, orgSpin)); + _bulkReversalRepository.Setup(b => b.CreateReversalListItem(Common.Constant.CurrentUser, orgSpin)); _testContext.Services.AddScoped(x => Mapper); - _testContext.Services.AddScoped(x => _bulkReversalService.Object); + _testContext.Services.AddScoped(x => _bulkReversalRepository.Object); _component = _testContext.RenderComponent(); @@ -56,7 +56,7 @@ public async Task Page_Is_Able_To_Submit_Bulk_Reversal() _component.Find("form").Submit(); - _bulkReversalService.Verify(b => b.CreateReversal(Common.Constant.CurrentUser, orgSpin), Times.Once); + _bulkReversalRepository.Verify(b => b.CreateReversalListItem(Common.Constant.CurrentUser, orgSpin), Times.Once); var navigationManager = _testContext.Services.GetRequiredService(); diff --git a/SmartPower.Client.Blazor.Test/Pages/BulkReversals.cs b/SmartPower.Client.Blazor.Test/Pages/BulkReversals.cs index e025106..b1502c1 100644 --- a/SmartPower.Client.Blazor.Test/Pages/BulkReversals.cs +++ b/SmartPower.Client.Blazor.Test/Pages/BulkReversals.cs @@ -5,8 +5,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; -using SmartPower.Common; -using SmartPower.Domain.Service; +using SmartPower.Application.Entity.Repository; namespace SmartPower.Client.Blazor.Test.Pages { @@ -15,7 +14,7 @@ namespace SmartPower.Client.Blazor.Test.Pages public class BulkReversals : FixtureBase { private Mock _bulkReversalService; - private List _bulkReversalModels; + private List _bulkReversalModels; private Bunit.TestContext _testContext; @@ -25,7 +24,7 @@ public void Setup() _testContext = new Bunit.TestContext(); _bulkReversalService = new Mock(); - _bulkReversalModels = CreateMany(Common.Constant.ItemCount); + _bulkReversalModels = CreateMany(Common.Constant.ItemCount); } [OneTimeTearDown] @@ -39,16 +38,16 @@ public async Task Component_Behaviour_Expected_For_Bulk_Reversals_With_Confirmat { var batchNumber = Create(); - _bulkReversalService.Setup(b => b.GetReversalList(Constant.CurrentUser)).ReturnsAsync(_bulkReversalModels); - _bulkReversalService.Setup(b => b.CreateReversals(Constant.CurrentUser)).ReturnsAsync(batchNumber); - _bulkReversalService.Setup(b => b.ValidatePendingReversals(Constant.CurrentUser)).ReturnsAsync(true); + _bulkReversalService.Setup(b => b.GetBulkReversals(Common.Constant.CurrentUser)).ReturnsAsync(_bulkReversalModels); + _bulkReversalService.Setup(b => b.CreateReversals(Common.Constant.CurrentUser)).ReturnsAsync(batchNumber); + _bulkReversalService.Setup(b => b.TestSuppliedInvoices(Common.Constant.CurrentUser)).ReturnsAsync(true); _testContext.Services.AddScoped(x => Mapper); _testContext.Services.AddScoped(x => _bulkReversalService.Object); var component = _testContext.RenderComponent(); - _bulkReversalService.Verify(b => b.GetReversalList(Constant.CurrentUser), Times.Once); + _bulkReversalService.Verify(b => b.GetBulkReversals(Common.Constant.CurrentUser), Times.Once); var buttons = component.FindAll("button"); @@ -58,7 +57,7 @@ public async Task Component_Behaviour_Expected_For_Bulk_Reversals_With_Confirmat bulkReversalButton.Click(); - _bulkReversalService.Verify(b => b.ValidatePendingReversals(Constant.CurrentUser), Times.Once); + _bulkReversalService.Verify(b => b.TestSuppliedInvoices(Common.Constant.CurrentUser), Times.Once); var buttonsAfterBulkReversal = component.FindAll("button"); @@ -66,7 +65,7 @@ public async Task Component_Behaviour_Expected_For_Bulk_Reversals_With_Confirmat bulkReversalConfirmationButton.Click(); - _bulkReversalService.Verify(b => b.CreateReversals(Constant.CurrentUser), Times.Once); + _bulkReversalService.Verify(b => b.CreateReversals(Common.Constant.CurrentUser), Times.Once); Assert.IsTrue(component.Markup.Contains(batchNumber.ToString())); } diff --git a/SmartPower.Client.Blazor.Test/Pages/CsvExport.cs b/SmartPower.Client.Blazor.Test/Pages/CsvExport.cs index ba08d18..1427327 100644 --- a/SmartPower.Client.Blazor.Test/Pages/CsvExport.cs +++ b/SmartPower.Client.Blazor.Test/Pages/CsvExport.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Moq; using NUnit.Framework; -using SmartPower.Domain.Service; +using SmartPower.Application.Service.BulkReversal; using SmartPower.Client.Blazor.Pages; namespace SmartPower.Client.Blazor.Test.Pages @@ -11,22 +11,22 @@ namespace SmartPower.Client.Blazor.Test.Pages [Category("CsvExport")] public class CsvExport : FixtureBase { - private Mock _bulkReversalService; + private Mock _csvExport; private CsvExportModel _sut; [OneTimeSetUp] public void Setup() { - _bulkReversalService = new Mock(); + _csvExport = new Mock(); } [Test] public async Task Page_Returns_Expected_FileContent_Result() { - _bulkReversalService.Setup(b => b.ReversalListStringExport(Common.Constant.CurrentUser)).ReturnsAsync(Common.Constant.BulkReversal.ExportStringHeaders); + _csvExport.Setup(b => b.GenerateCsvStringExport(Common.Constant.CurrentUser)).ReturnsAsync(Common.Constant.BulkReversal.ExportStringHeaders); - _sut = new CsvExportModel(_bulkReversalService.Object); + _sut = new CsvExportModel(_csvExport.Object); var result = await _sut.OnGetAsync(); @@ -38,10 +38,9 @@ public async Task Page_Returns_Expected_FileContent_Result() Assert.IsTrue(fileContentResult.ContentType == Common.Constant.BulkReversal.CsvExport.File.FileContentType); Assert.IsTrue(fileContentResult.FileDownloadName == Common.Constant.BulkReversal.CsvExport.File.FileName); - Assert.IsTrue(fileContentResult.FileContents.Length > 0); - _bulkReversalService.Verify(b => b.ReversalListStringExport(Common.Constant.CurrentUser), Times.Once); + _csvExport.Verify(b => b.GenerateCsvStringExport(Common.Constant.CurrentUser), Times.Once); } } } diff --git a/SmartPower.Client.Blazor.Test/SmartPower.Client.Blazor.Test.csproj b/SmartPower.Client.Blazor.Test/SmartPower.Client.Blazor.Test.csproj index ef5798e..9c28b40 100644 --- a/SmartPower.Client.Blazor.Test/SmartPower.Client.Blazor.Test.csproj +++ b/SmartPower.Client.Blazor.Test/SmartPower.Client.Blazor.Test.csproj @@ -17,10 +17,9 @@ + - - diff --git a/SmartPower.Client.Blazor/App.razor b/SmartPower.Client.Blazor/App.razor index dbc8b6f..4d022c9 100644 --- a/SmartPower.Client.Blazor/App.razor +++ b/SmartPower.Client.Blazor/App.razor @@ -1,12 +1,10 @@ - - - - - - - -

Sorry, there's nothing at this address.

-
-
-
-
\ No newline at end of file + + + + + + +

Sorry, there's nothing at this address.

+
+
+
\ No newline at end of file diff --git a/SmartPower.Client.Blazor/Automapper.cs b/SmartPower.Client.Blazor/Automapper.cs index 7afd13d..59895e3 100644 --- a/SmartPower.Client.Blazor/Automapper.cs +++ b/SmartPower.Client.Blazor/Automapper.cs @@ -6,7 +6,8 @@ public class AutoMapper : Profile { public AutoMapper() { - CreateMap(); + CreateMap(); + CreateMap(); } } } diff --git a/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor b/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor index 6a8dfdb..f47e588 100644 --- a/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor +++ b/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor @@ -1,17 +1,6 @@ @page "/bulk-reversal-input" -@using global::AutoMapper - -@inject NavigationManager NavigationManager -@inject IMapper Mapper -@inject Domain.Service.IBulkReversal BulkReversalService - - +

Bulk Reversal Input

diff --git a/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor.cs b/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor.cs index 0d28d8a..6bb986e 100644 --- a/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor.cs +++ b/SmartPower.Client.Blazor/Pages/BulkReversalInput.razor.cs @@ -1,21 +1,32 @@ using System.Threading.Tasks; +using AutoMapper; +using Microsoft.AspNetCore.Components; namespace SmartPower.Client.Blazor.Pages { partial class BulkReversalInput { + [Inject] + public NavigationManager NavigationManager { get; set; } + + [Inject] + public IMapper Mapper { get; set; } + + [Inject] + public Application.Entity.Repository.IBulkReversal BulkReversalRepository { get; set; } + public BulkReversalInput() { BulkReversal = new Dto.Request.BulkReversal { BatchNumber = 2, UserName = Common.Constant.CurrentUser }; } - public string OrgSpinText { get; set; } - public Dto.Request.BulkReversal BulkReversal { get; set; } private async Task HandleValidSubmit() { - await BulkReversalService.CreateReversal(Common.Constant.CurrentUser, BulkReversal.OrgSpin); + await BulkReversalRepository.CreateReversalListItem(Common.Constant.CurrentUser, BulkReversal.OrgSpin); + + await BulkReversalRepository.UpdateReversalStatus(Common.Constant.CurrentUser); NavigationManager.NavigateTo("bulk-reversals"); } diff --git a/SmartPower.Client.Blazor/Pages/BulkReversals.razor b/SmartPower.Client.Blazor/Pages/BulkReversals.razor index 0b89f49..bc07437 100644 --- a/SmartPower.Client.Blazor/Pages/BulkReversals.razor +++ b/SmartPower.Client.Blazor/Pages/BulkReversals.razor @@ -1,19 +1,15 @@ @page "/bulk-reversals" -@using global::AutoMapper - -@inject NavigationManager NavigationManager -@inject IMapper Mapper -@inject Domain.Service.IBulkReversal BulkReversalService +@using SmartPower.Common @if (!string.IsNullOrEmpty(BatchProcessedMessage)) { - + }

Reversals Bulk

-@if (BulkReversalList == null) +@if (BulkReversalSummaryList == null) {

Loading...

} @@ -21,31 +17,12 @@ else { @if (DirtyPendingReversals) { - + }
- +