Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
249 changes: 249 additions & 0 deletions SmartPower.Application/Entity/DbContext.cs
Original file line number Diff line number Diff line change
@@ -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<DbContext> options) : base(options) { }

public virtual DbSet<TReversalsBulkList> TReversalsBulkLists { get; set; }
public virtual DbSet<TInvoice> 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<TReversalsBulkList>(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<TInvoice>(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);
}
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable disable

namespace SmartPower.Data.Entity.Model
namespace SmartPower.Application.Entity.Model
{
public partial class TInvoice
{
Expand Down Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable disable

namespace SmartPower.Data.Entity.Model
namespace SmartPower.Application.Entity.Model
{
public partial class TReversalsBulkList
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -16,9 +18,19 @@ public BulkReversal(DbContext dbContext)
_dbContext = dbContext;
}

public async Task<List<Model.TReversalsBulkList>> GetReversalList(string userName)
public async Task<List<BulkReversalSummary>> 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SmartPower.Data.Entity.Repository
namespace SmartPower.Application.Entity.Repository
{
public static class Constant
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<Model.TReversalsBulkList>> GetReversalList(string userName);
Task<List<BulkReversalSummary>> GetBulkReversals(string userName);
Task CreateReversalListItem(string userName, int orgSpinvNumber);
Task ClearReversals(string userName);
Task UpdateReversalStatus(string userName);
Expand Down
12 changes: 12 additions & 0 deletions SmartPower.Application/Entity/Repository/IInvoice.cs
Original file line number Diff line number Diff line change
@@ -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<InvoiceSummary> GetInvoice(int spInvoiceNumber);
Task<List<InvoiceSummary>> GetInvoices(List<int> spInvoiceNumbers);
}
}
Loading