diff --git a/src/Payments.Core/Domain/Team.cs b/src/Payments.Core/Domain/Team.cs
index b7d03e39..e58df338 100644
--- a/src/Payments.Core/Domain/Team.cs
+++ b/src/Payments.Core/Domain/Team.cs
@@ -78,6 +78,23 @@ public Team()
public bool SlothAutoApprove { get; set; } = false;
+ ///
+ /// This will be a system admin setting.
+ /// It will relax the rules for Aggie Enterprise chart string validation.
+ /// The idea is that an application using the API will determine what is valid or not.
+ ///
+ /// Possibly we could have an invoice value that could be specified instead if we wanted to get that fancy.
+ ///
+ public bool UseCustomAccountValidation { get; set; } = false;
+
+ ///
+ /// This will be a system admin setting.
+ /// This may be used if UseCustomAccountValidation is true.
+ /// If it is, the recharge debit natural account/expenditure type will be replaced
+ ///
+ [StringLength(6)]
+ public string RechargeDebitNaturalAccount { get; set; }
+
[NotMapped]
public FinancialAccount DefaultAccount {
get {
diff --git a/src/Payments.Core/Jobs/MoneyMovementJob.cs b/src/Payments.Core/Jobs/MoneyMovementJob.cs
index 4a2c2361..bf8c42de 100644
--- a/src/Payments.Core/Jobs/MoneyMovementJob.cs
+++ b/src/Payments.Core/Jobs/MoneyMovementJob.cs
@@ -132,7 +132,7 @@ public async Task FindBankReconcileTransactions(ILogger log)
if (accountOverride != null)
{
//Do we want to validate? Sloth will validate (based on the current config setting in prod), but we can do it here to avoid a failed transaction. This is a bit of a judgement call. If we don't validate, the transaction will fail and the invoice will stay in paid status. If we do validate, the invoice will be rejected and the user will have to fix it.
- var validationResult = await _aggieEnterpriseService.IsAccountValid(accountOverride.FinancialSegmentString);
+ var validationResult = await _aggieEnterpriseService.IsAccountValid(accountOverride.FinancialSegmentString, team);
if (validationResult.IsValid)
{
incomeAeAccount = validationResult.ChartString ?? accountOverride.FinancialSegmentString;
diff --git a/src/Payments.Core/Migrations/20261014152156_CustomCoaValidation.Designer.cs b/src/Payments.Core/Migrations/20261014152156_CustomCoaValidation.Designer.cs
new file mode 100644
index 00000000..7f420222
--- /dev/null
+++ b/src/Payments.Core/Migrations/20261014152156_CustomCoaValidation.Designer.cs
@@ -0,0 +1,1209 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Payments.Core.Data;
+
+#nullable disable
+
+namespace Payments.Core.Migrations
+{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20261014152156_CustomCoaValidation")]
+ partial class CustomCoaValidation
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "6.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex")
+ .HasFilter("[NormalizedName] IS NOT NULL");
+
+ b.ToTable("AspNetRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("ClaimType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClaimValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("RoleId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("ClaimType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClaimValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ProviderKey")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ProviderDisplayName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("RoleId")
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("LoginProvider")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Name")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Value")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Coupon", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Code")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DiscountAmount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("DiscountPercent")
+ .HasColumnType("decimal(18,5)");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("TeamId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TeamId");
+
+ b.ToTable("Coupons");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.FinancialAccount", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Account")
+ .HasMaxLength(7)
+ .HasColumnType("nvarchar(7)");
+
+ b.Property("Chart")
+ .HasMaxLength(1)
+ .HasColumnType("nvarchar(1)");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("FinancialSegmentString")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("IsDefault")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("Project")
+ .HasMaxLength(9)
+ .HasColumnType("nvarchar(9)");
+
+ b.Property("SubAccount")
+ .HasMaxLength(5)
+ .HasColumnType("nvarchar(5)");
+
+ b.Property("TeamId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TeamId");
+
+ b.ToTable("FinancialAccounts");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.History", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("ActionDateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("Actor")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Data")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("InvoiceId")
+ .HasColumnType("int");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvoiceId");
+
+ b.ToTable("History");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Invoice", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("AccountId")
+ .HasColumnType("int");
+
+ b.Property("CalculatedDiscount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("CalculatedSubtotal")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("CalculatedTaxAmount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("CalculatedTaxableAmount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("CalculatedTotal")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("CouponId")
+ .HasColumnType("int");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("CustomerAddress")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CustomerCompany")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CustomerEmail")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CustomerName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Deleted")
+ .HasColumnType("bit");
+
+ b.Property("DeletedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("DraftCount")
+ .HasColumnType("int");
+
+ b.Property("DueDate")
+ .HasColumnType("datetime2");
+
+ b.Property("ExternalId")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("ExternalIdentifier")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("ExternalLink")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("KfsTrackingNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("LinkId")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("ManualDiscount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("Memo")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Paid")
+ .HasColumnType("bit");
+
+ b.Property("PaidAt")
+ .HasColumnType("datetime2");
+
+ b.Property("PaymentProcessorId")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PaymentType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Refunded")
+ .HasColumnType("bit");
+
+ b.Property("RefundedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("Sent")
+ .HasColumnType("bit");
+
+ b.Property("SentAt")
+ .HasColumnType("datetime2");
+
+ b.Property("Status")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("TaxPercent")
+ .HasColumnType("decimal(18,5)");
+
+ b.Property("TeamId")
+ .HasColumnType("int");
+
+ b.Property("Type")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)")
+ .HasDefaultValue("CC");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AccountId");
+
+ b.HasIndex("CouponId");
+
+ b.HasIndex("LinkId");
+
+ b.HasIndex("TeamId");
+
+ b.HasIndex("Type");
+
+ b.HasIndex("TeamId", "ExternalIdentifier", "ExternalId");
+
+ b.ToTable("Invoices");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.InvoiceAttachment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("ContentType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("FileName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Identifier")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("InvoiceId")
+ .HasColumnType("int");
+
+ b.Property("Size")
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvoiceId");
+
+ b.ToTable("InvoiceAttachments");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.InvoiceLink", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Expired")
+ .HasColumnType("bit");
+
+ b.Property("InvoiceId")
+ .HasColumnType("int");
+
+ b.Property("LinkId")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvoiceId");
+
+ b.ToTable("InvoiceLinks");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.LineItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Amount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("InvoiceId")
+ .HasColumnType("int");
+
+ b.Property("Quantity")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("TaxExempt")
+ .HasColumnType("bit");
+
+ b.Property("Total")
+ .HasColumnType("decimal(18,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvoiceId");
+
+ b.ToTable("LineItems");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.LogMessage", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("CorrelationId")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Exception")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("JobId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("JobName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Level")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("LogEvent")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Message")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MessageTemplate")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Properties")
+ .HasColumnType("xml");
+
+ b.Property("Source")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("TimeStamp")
+ .HasColumnType("datetimeoffset");
+
+ b.HasKey("Id");
+
+ b.HasIndex("JobId");
+
+ b.ToTable("Logs", (string)null);
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.MoneyMovementJobRecord", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Name")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("RanOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Status")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("MoneyMovementJobRecords");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.PaymentEvent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Amount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("BillingCity")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("BillingCompany")
+ .HasMaxLength(60)
+ .HasColumnType("nvarchar(60)");
+
+ b.Property("BillingCountry")
+ .HasMaxLength(2)
+ .HasColumnType("nvarchar(2)");
+
+ b.Property("BillingEmail")
+ .HasMaxLength(1500)
+ .HasColumnType("nvarchar(1500)");
+
+ b.Property("BillingFirstName")
+ .HasMaxLength(60)
+ .HasColumnType("nvarchar(60)");
+
+ b.Property("BillingLastName")
+ .HasMaxLength(60)
+ .HasColumnType("nvarchar(60)");
+
+ b.Property("BillingPhone")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("BillingPostalCode")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("BillingState")
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("BillingStreet1")
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("BillingStreet2")
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("CardExpiry")
+ .HasColumnType("datetime2");
+
+ b.Property("CardNumber")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("CardType")
+ .HasMaxLength(3)
+ .HasColumnType("nvarchar(3)");
+
+ b.Property("Decision")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("InvoiceId")
+ .HasColumnType("int");
+
+ b.Property("OccuredAt")
+ .HasColumnType("datetime2");
+
+ b.Property("Processor")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProcessorId")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ReturnedResults")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvoiceId");
+
+ b.ToTable("PaymentEvents");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.RechargeAccount", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Amount")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("ApprovedByKerb")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("ApprovedByName")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("Direction")
+ .HasColumnType("int");
+
+ b.Property("EnteredByKerb")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("EnteredByName")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("FinancialSegmentString")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("InvoiceId")
+ .HasColumnType("int");
+
+ b.Property("Notes")
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("Percentage")
+ .HasColumnType("decimal(5,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ApprovedByKerb");
+
+ b.HasIndex("EnteredByKerb");
+
+ b.HasIndex("InvoiceId");
+
+ b.ToTable("RechargeAccounts");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.TaxReportJobRecord", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Name")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("RanOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Status")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("TaxReportJobRecords");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Team", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("AllowedInvoiceType")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)")
+ .HasDefaultValue("CC");
+
+ b.Property("ApiKey")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ContactEmail")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("ContactName")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("ContactPhoneNumber")
+ .HasMaxLength(40)
+ .HasColumnType("nvarchar(40)");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.Property("RechargeDebitNaturalAccount")
+ .HasMaxLength(6)
+ .HasColumnType("nvarchar(6)");
+
+ b.Property("SlothAutoApprove")
+ .HasColumnType("bit");
+
+ b.Property("Slug")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("nvarchar(40)");
+
+ b.Property("UseCustomAccountValidation")
+ .HasColumnType("bit");
+
+ b.Property("WebHookApiKey")
+ .HasMaxLength(128)
+ .HasColumnType("nvarchar(128)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Teams");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.TeamPermission", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("RoleId")
+ .HasColumnType("int");
+
+ b.Property("TeamId")
+ .HasColumnType("int");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("TeamId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("TeamPermissions");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.TeamRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.HasKey("Id");
+
+ b.ToTable("TeamRoles");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.User", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("int");
+
+ b.Property("CampusKerberos")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("bit");
+
+ b.Property("FirstName")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("LastName")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("bit");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("datetimeoffset");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("PasswordHash")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("bit");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("bit");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex")
+ .HasFilter("[NormalizedUserName] IS NOT NULL");
+
+ b.ToTable("AspNetUsers", (string)null);
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.WebHook", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("ContentType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("TeamId")
+ .HasColumnType("int");
+
+ b.Property("TriggerOnPaid")
+ .HasColumnType("bit");
+
+ b.Property("TriggerOnReconcile")
+ .HasColumnType("bit");
+
+ b.Property("Url")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TeamId");
+
+ b.ToTable("WebHooks");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.HasOne("Payments.Core.Domain.User", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.HasOne("Payments.Core.Domain.User", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Payments.Core.Domain.User", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.HasOne("Payments.Core.Domain.User", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Coupon", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Team", "Team")
+ .WithMany("Coupons")
+ .HasForeignKey("TeamId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Team");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.FinancialAccount", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Team", "Team")
+ .WithMany("Accounts")
+ .HasForeignKey("TeamId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Team");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.History", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Invoice", null)
+ .WithMany("History")
+ .HasForeignKey("InvoiceId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Invoice", b =>
+ {
+ b.HasOne("Payments.Core.Domain.FinancialAccount", "Account")
+ .WithMany()
+ .HasForeignKey("AccountId");
+
+ b.HasOne("Payments.Core.Domain.Coupon", "Coupon")
+ .WithMany("Invoices")
+ .HasForeignKey("CouponId");
+
+ b.HasOne("Payments.Core.Domain.Team", "Team")
+ .WithMany()
+ .HasForeignKey("TeamId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+
+ b.Navigation("Account");
+
+ b.Navigation("Coupon");
+
+ b.Navigation("Team");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.InvoiceAttachment", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Invoice", "Invoice")
+ .WithMany("Attachments")
+ .HasForeignKey("InvoiceId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Invoice");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.InvoiceLink", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Invoice", "Invoice")
+ .WithMany()
+ .HasForeignKey("InvoiceId");
+
+ b.Navigation("Invoice");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.LineItem", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Invoice", null)
+ .WithMany("Items")
+ .HasForeignKey("InvoiceId");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.LogMessage", b =>
+ {
+ b.HasOne("Payments.Core.Domain.MoneyMovementJobRecord", null)
+ .WithMany("Logs")
+ .HasForeignKey("JobId")
+ .OnDelete(DeleteBehavior.Restrict);
+
+ b.HasOne("Payments.Core.Domain.TaxReportJobRecord", null)
+ .WithMany("Logs")
+ .HasForeignKey("JobId")
+ .OnDelete(DeleteBehavior.Restrict);
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.PaymentEvent", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Invoice", "Invoice")
+ .WithMany("PaymentEvents")
+ .HasForeignKey("InvoiceId");
+
+ b.Navigation("Invoice");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.RechargeAccount", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Invoice", "Invoice")
+ .WithMany("RechargeAccounts")
+ .HasForeignKey("InvoiceId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Invoice");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.TeamPermission", b =>
+ {
+ b.HasOne("Payments.Core.Domain.TeamRole", "Role")
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Payments.Core.Domain.Team", "Team")
+ .WithMany("Permissions")
+ .HasForeignKey("TeamId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Payments.Core.Domain.User", "User")
+ .WithMany("TeamPermissions")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("Team");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.WebHook", b =>
+ {
+ b.HasOne("Payments.Core.Domain.Team", "Team")
+ .WithMany("WebHooks")
+ .HasForeignKey("TeamId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Team");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Coupon", b =>
+ {
+ b.Navigation("Invoices");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Invoice", b =>
+ {
+ b.Navigation("Attachments");
+
+ b.Navigation("History");
+
+ b.Navigation("Items");
+
+ b.Navigation("PaymentEvents");
+
+ b.Navigation("RechargeAccounts");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.MoneyMovementJobRecord", b =>
+ {
+ b.Navigation("Logs");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.TaxReportJobRecord", b =>
+ {
+ b.Navigation("Logs");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.Team", b =>
+ {
+ b.Navigation("Accounts");
+
+ b.Navigation("Coupons");
+
+ b.Navigation("Permissions");
+
+ b.Navigation("WebHooks");
+ });
+
+ modelBuilder.Entity("Payments.Core.Domain.User", b =>
+ {
+ b.Navigation("TeamPermissions");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Payments.Core/Migrations/20261014152156_CustomCoaValidation.cs b/src/Payments.Core/Migrations/20261014152156_CustomCoaValidation.cs
new file mode 100644
index 00000000..93f496d3
--- /dev/null
+++ b/src/Payments.Core/Migrations/20261014152156_CustomCoaValidation.cs
@@ -0,0 +1,37 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Payments.Core.Migrations
+{
+ public partial class CustomCoaValidation : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "RechargeDebitNaturalAccount",
+ table: "Teams",
+ type: "nvarchar(6)",
+ maxLength: 6,
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "UseCustomAccountValidation",
+ table: "Teams",
+ type: "bit",
+ nullable: false,
+ defaultValue: false);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "RechargeDebitNaturalAccount",
+ table: "Teams");
+
+ migrationBuilder.DropColumn(
+ name: "UseCustomAccountValidation",
+ table: "Teams");
+ }
+ }
+}
diff --git a/src/Payments.Core/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Payments.Core/Migrations/ApplicationDbContextModelSnapshot.cs
index d4e3df14..fb39721f 100644
--- a/src/Payments.Core/Migrations/ApplicationDbContextModelSnapshot.cs
+++ b/src/Payments.Core/Migrations/ApplicationDbContextModelSnapshot.cs
@@ -768,6 +768,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
+ b.Property("RechargeDebitNaturalAccount")
+ .HasMaxLength(6)
+ .HasColumnType("nvarchar(6)");
+
b.Property("SlothAutoApprove")
.HasColumnType("bit");
@@ -776,6 +780,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(40)
.HasColumnType("nvarchar(40)");
+ b.Property("UseCustomAccountValidation")
+ .HasColumnType("bit");
+
b.Property("WebHookApiKey")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
diff --git a/src/Payments.Core/Models/Configuration/FinanceSettings.cs b/src/Payments.Core/Models/Configuration/FinanceSettings.cs
index c0a3e062..4e5a3e7f 100644
--- a/src/Payments.Core/Models/Configuration/FinanceSettings.cs
+++ b/src/Payments.Core/Models/Configuration/FinanceSettings.cs
@@ -30,6 +30,11 @@ public class FinanceSettings
public bool ValidateRechargeFinancialSegmentString { get; set; } = true;
+ ///
+ /// Feature flag to turn on team level natural account replacement of debit natural account (vs. hard coded value)
+ ///
+ public bool EnableRechargeDebitNaturalAccount { get; set; } = false;
+
public int RechargeAutoApproveDays { get; set; } = 7;
}
}
diff --git a/src/Payments.Core/Services/AggieEnterpriseService.cs b/src/Payments.Core/Services/AggieEnterpriseService.cs
index cbe08ab9..475a1ac4 100644
--- a/src/Payments.Core/Services/AggieEnterpriseService.cs
+++ b/src/Payments.Core/Services/AggieEnterpriseService.cs
@@ -3,6 +3,7 @@
using AggieEnterpriseApi.Types;
using AggieEnterpriseApi.Validation;
using Microsoft.Extensions.Options;
+using Payments.Core.Domain;
using Payments.Core.Models.Configuration;
using Payments.Core.Models.Validation;
using Serilog;
@@ -16,24 +17,66 @@ namespace Payments.Core.Services
{
public interface IAggieEnterpriseService
{
- Task IsAccountValid(string financialSegmentString, bool validateCVRs = true);
+ Task IsAccountValid(string financialSegmentString, Team team, bool validateCVRs = true);
- Task IsRechargeAccountValid(string financialSegmentString, CreditDebit direction, bool validateCVRs = true);
+ Task IsRechargeAccountValid(string financialSegmentString, CreditDebit direction, Team team, bool validateCVRs = true);
+
+ Task> SearchNaturalAccounts(string query);
+
+ Task IsNaturalAccountValid(string naturalAccount);
}
public class AggieEnterpriseService : IAggieEnterpriseService
{
private readonly AggieEnterpriseOptions _aeSettings;
+ private readonly FinanceSettings _financeSettings;
private IAggieEnterpriseClient _aggieClient;
private const string FiscalOfficer = "Fiscal Officer Approver";
- public AggieEnterpriseService(IOptions aeSettings)
+ public AggieEnterpriseService(IOptions aeSettings, IOptions financeSettings)
{
_aeSettings = aeSettings.Value;
+ _financeSettings = financeSettings.Value;
//_aggieClient = GraphQlClient.Get(options.Value.GraphQlUrl, options.Value.Token);
_aggieClient = GraphQlClient.Get(_aeSettings.GraphQlUrl, _aeSettings.TokenEndpoint, _aeSettings.ConsumerKey, _aeSettings.ConsumerSecret, $"{_aeSettings.ScopeApp}-{_aeSettings.ScopeEnv}");
}
+ public async Task> SearchNaturalAccounts(string query)
+ {
+ var filter = new ErpAccountFilterInput
+ {
+ Name = new StringFilterInput { Contains = query.Trim().Replace(" ", "%") }
+ };
+ var result = await _aggieClient.ErpAccountSearch.ExecuteAsync(filter, query.Trim().ToUpperInvariant());
+ var data = result.ReadData();
+ var accounts = data.ErpAccountSearch.Data
+ .Where(account => account.EligibleForUse)
+ .GroupBy(account => account.Code)
+ .ToDictionary(group => group.Key, group => group.First().Name);
+
+ if (data.ErpAccount?.EligibleForUse == true)
+ {
+ accounts[data.ErpAccount.Code] = data.ErpAccount.Name;
+ }
+
+ return accounts;
+ }
+
+ public async Task IsNaturalAccountValid(string naturalAccount)
+ {
+ if (string.IsNullOrWhiteSpace(naturalAccount) || naturalAccount.Length != 6
+ || naturalAccount.Any(character => !(character >= '0' && character <= '9')
+ && !(character >= 'A' && character <= 'Z')))
+ {
+ return false;
+ }
+
+ var result = await _aggieClient.ErpAccountSearch.ExecuteAsync(
+ new ErpAccountFilterInput { Code = new StringFilterInput { Eq = naturalAccount } }, naturalAccount);
+ var account = result.ReadData().ErpAccount;
+ return account?.EligibleForUse == true && account.Code == naturalAccount;
+ }
+
//TODO: Change this to return invalid reasons
private async Task CommonAccountValidation(AccountValidationModel accountValidationModel, string financialSegmentString, bool validateCVRs = true)
@@ -215,12 +258,22 @@ private async Task CommonPpmFundChecks(AccountValidation
return accountValidationModel;
}
- public async Task IsAccountValid(string financialSegmentString, bool validateCVRs = true)
+ public async Task IsAccountValid(string financialSegmentString, Team team, bool validateCVRs = true)
{
var rtValue = new AccountValidationModel();
rtValue = await CommonAccountValidation(rtValue, financialSegmentString, validateCVRs);
+ if (team == null)
+ {
+ Log.Error("Team is null in IsAccountValid");
+ }
+
+ if (team != null && team.UseCustomAccountValidation)
+ {
+ return rtValue; //If the team is using custom account validation, we don't want to do any further checks
+ }
+
if (rtValue.CoaChartType == FinancialChartStringType.Gl)
{
@@ -303,11 +356,21 @@ public async Task IsAccountValid(string financialSegment
return rtValue;
}
- public async Task IsRechargeAccountValid(string financialSegmentString, CreditDebit direction, bool validateCVRs = true)
+ public async Task IsRechargeAccountValid(string financialSegmentString, CreditDebit direction, Team team, bool validateCVRs = true)
{
+ if(team == null)
+ {
+ Log.Error("Team is null in IsRechargeAccountValid");
+ }
+ var debitNaturalAccount = "770006";
+ if(_financeSettings.EnableRechargeDebitNaturalAccount && team != null && team.UseCustomAccountValidation && !string.IsNullOrWhiteSpace(team.RechargeDebitNaturalAccount))
+ {
+ debitNaturalAccount = team.RechargeDebitNaturalAccount;
+ }
+
var rtValue = new AccountValidationModel();
- var newChartString = ReplaceNaturalAccount(financialSegmentString, direction == CreditDebit.Credit ? "775000" : "770006");
+ var newChartString = ReplaceNaturalAccount(financialSegmentString, direction == CreditDebit.Credit ? "775000" : debitNaturalAccount);
var chartStringUpdated = newChartString != financialSegmentString;
financialSegmentString = newChartString;
@@ -320,11 +383,17 @@ public async Task IsRechargeAccountValid(string financia
if(chartStringUpdated)
{
//Add a warning that we changed the natural account for them. Otherwise, they may not notice if it would have been valid except for the change
- rtValue.Warnings.Add(new KeyValuePair("Natural Account", direction == CreditDebit.Credit ? "The Natural Account/Expenditure Type segment has been changed to 775000." : "The Natural Account/Expenditure Type segment has been changed to 770006."));
+ rtValue.Warnings.Add(new KeyValuePair("Natural Account", direction == CreditDebit.Credit ? "The Natural Account/Expenditure Type segment has been changed to 775000." : $"The Natural Account/Expenditure Type segment has been changed to {debitNaturalAccount}."));
}
return rtValue;
}
+ if(team?.UseCustomAccountValidation == true)
+ {
+ rtValue = await MinimumCustomValidationChecks(direction, chartStringUpdated, direction == CreditDebit.Credit ? "775000" : debitNaturalAccount, rtValue);
+ return rtValue;
+ }
+
if (direction == CreditDebit.Credit)
{
//The big unknown for now if the rollup stuff/parent stuff.
@@ -422,6 +491,59 @@ public async Task IsRechargeAccountValid(string financia
return rtValue;
}
+ ///
+ /// For Recharge Accounts
+ ///
+ ///
+ ///
+ ///
+ private async Task MinimumCustomValidationChecks(CreditDebit direction, bool chartStringUpdated, string naturalAccountToUse, AccountValidationModel rtValue)
+ {
+ if (chartStringUpdated)
+ {
+ var segmentName = rtValue.CoaChartType == FinancialChartStringType.Ppm
+ ? "Expenditure Type"
+ : "Natural Account";
+
+ rtValue.Warnings.Add(new KeyValuePair(
+ segmentName,
+ $"The {segmentName} segment has been changed to {naturalAccountToUse}."));
+ }
+
+ if (direction == CreditDebit.Credit)
+ {
+ //For credit, we don't need to do anything else. The custom validation is enough.
+ }
+ else //Debit
+ {
+ if (rtValue.CoaChartType == FinancialChartStringType.Gl)
+ {
+ if (rtValue.IsValid)
+ {
+ var result = await _aggieClient.ErpDepartmentApprovers.ExecuteAsync(rtValue.GlSegments.Department);
+ var data = result.ReadData();
+ if (data != null)
+ {
+ if (data.ErpFinancialDepartment != null && data.ErpFinancialDepartment.Approvers != null)
+ {
+ foreach (var approver in data.ErpFinancialDepartment.Approvers.Where(a => a.ApproverType == FiscalOfficer))
+ {
+ rtValue.Approvers.Add(new Approver
+ {
+ FirstName = approver.FirstName,
+ LastName = approver.LastName,
+ Email = approver.EmailAddress,
+ });
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return rtValue;
+ }
+
private PpmSegmentInput ConvertToPpmSegmentInput(PpmSegments segments)
{
return new PpmSegmentInput
diff --git a/src/Payments.Mvc/ClientApp/src/components/rechargeAccountsControl.tsx b/src/Payments.Mvc/ClientApp/src/components/rechargeAccountsControl.tsx
index 486e7b1d..66252917 100644
--- a/src/Payments.Mvc/ClientApp/src/components/rechargeAccountsControl.tsx
+++ b/src/Payments.Mvc/ClientApp/src/components/rechargeAccountsControl.tsx
@@ -14,6 +14,7 @@ import {
} from '../helpers/calculations';
interface IProps {
+ teamSlug: string;
rechargeAccounts: InvoiceRechargeItem[];
invoiceTotal: number;
onChange: (rechargeAccounts: InvoiceRechargeItem[]) => void;
@@ -363,7 +364,9 @@ export default class RechargeAccountsControl extends React.Component<
const response = await fetch(
`/api/recharge/validate?chartString=${encodeURIComponent(
chartString
- )}&direction=${directionValue}&checkApprover=${checkApprover}`,
+ )}&direction=${directionValue}&checkApprover=${checkApprover}&teamSlug=${encodeURIComponent(
+ this.props.teamSlug
+ )}`,
{
method: 'GET',
headers: {
diff --git a/src/Payments.Mvc/ClientApp/src/components/sendModal.tsx b/src/Payments.Mvc/ClientApp/src/components/sendModal.tsx
index e4bf841f..488ed73b 100644
--- a/src/Payments.Mvc/ClientApp/src/components/sendModal.tsx
+++ b/src/Payments.Mvc/ClientApp/src/components/sendModal.tsx
@@ -160,6 +160,7 @@ export default class SendModal extends React.PureComponent {
paid: false,
paidDate: null,
team: {
+ slug: team.slug,
name: team.name,
contactName: '',
contactEmail: team.contactEmail,
diff --git a/src/Payments.Mvc/ClientApp/src/containers/CreateInvoiceContainer.tsx b/src/Payments.Mvc/ClientApp/src/containers/CreateInvoiceContainer.tsx
index dc82f73d..fb05e7ff 100644
--- a/src/Payments.Mvc/ClientApp/src/containers/CreateInvoiceContainer.tsx
+++ b/src/Payments.Mvc/ClientApp/src/containers/CreateInvoiceContainer.tsx
@@ -180,6 +180,7 @@ export default class CreateInvoiceContainer extends React.Component<
{invoiceType === 'Recharge' && (