The demo company gets a bank account with the capital paid in, collections and supplier payments (one customer pays only half), a RiBa remittance presented, credited and with one effect back unpaid, a draft remittance for the next weeks, a direct debit mandate, a CSV statement to reconcile with a rule for the bank fees, and a first reminder already sent. The seeder runs only when FIN is licensed and only once. The tests run the demo on a real instance: collections registered and cancelled, the CBI file written, the statement reconciled, reminders and cash flow, with the trial balance checked after every flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5bbc2120a1
commit
4014373797
4 files changed
+622
No files matched your search
@@ -0,0 +1,374 @@
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using Khaemhat.Application.Instance;
|
||||
using Khaemhat.Application.Ledger;
|
||||
using Khaemhat.Application.Licensing;
|
||||
using Khaemhat.Application.Modules;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Application.Treasury;
|
||||
using Khaemhat.Core.Accounting;
|
||||
using Khaemhat.Core.Parties;
|
||||
using Khaemhat.Core.Tables;
|
||||
using Khaemhat.Core.Treasury;
|
||||
using Khaemhat.Data;
|
||||
using Khaemhat.Data.Querying;
|
||||
|
||||
namespace Khaemhat.Application.Seeding;
|
||||
|
||||
/// <summary>
|
||||
/// The demo treasury (SPEC §14, issues #69-#72): the bank account of the company, the collections of the invoices
|
||||
/// paid by transfer (one only in part), the payments to the suppliers, a RiBa remittance presented and credited with an
|
||||
/// unpaid effect, a direct debit mandate, a bank statement still to reconcile with a saved rule for the fees, and the
|
||||
/// first reminder already sent to a customer. It runs after the demo ledger, only when the treasury (FIN) is licensed and only once: when the company has
|
||||
/// collections or remittances it adds nothing.
|
||||
/// </summary>
|
||||
/// <param name="payments">Collections and payments.</param>
|
||||
/// <param name="remittances">The remittances.</param>
|
||||
/// <param name="mandates">The mandates.</param>
|
||||
/// <param name="reconciliation">The bank statements.</param>
|
||||
/// <param name="factory">Reads and writes the company.</param>
|
||||
/// <param name="licenses">Whether the treasury is licensed.</param>
|
||||
/// <param name="clock">Today.</param>
|
||||
public sealed class DemoTreasurySeeder(
|
||||
PaymentService payments, RemittanceService remittances, MandateService mandates, BankReconciliationService reconciliation, IUnitOfWorkFactory factory,
|
||||
ILicenseGate licenses, TimeProvider clock)
|
||||
: ICompanySeeder
|
||||
{
|
||||
/// <summary>The code of the demo bank account.</summary>
|
||||
public const string BankCode = "BPD";
|
||||
|
||||
/// <summary>The capital paid into the bank on the first day of the year.</summary>
|
||||
public const decimal OpeningBalance = 25000m;
|
||||
|
||||
/// <summary>The account of the capital paid in by the shareholders.</summary>
|
||||
public const string CapitalAccount = "10.01.004";
|
||||
|
||||
/// <summary>The fees of the unpaid effect.</summary>
|
||||
public const decimal UnpaidFees = 6.50m;
|
||||
|
||||
/// <summary>The monthly fee of the bank account, matched by a saved rule.</summary>
|
||||
public const decimal AccountFee = 12.50m;
|
||||
|
||||
private static readonly Actor Seed = Actor.System;
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order => 50;
|
||||
|
||||
/// <summary>An Italian IBAN with its check digits computed from ABI, CAB and account.</summary>
|
||||
/// <param name="cin">The CIN letter.</param>
|
||||
/// <param name="abi">The ABI code.</param>
|
||||
/// <param name="cab">The CAB code.</param>
|
||||
/// <param name="account">The account number (12 characters).</param>
|
||||
/// <returns>The IBAN.</returns>
|
||||
public static string Iban(char cin, string abi, string cab, string account)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(abi);
|
||||
ArgumentNullException.ThrowIfNull(cab);
|
||||
ArgumentNullException.ThrowIfNull(account);
|
||||
var bban = cin + abi + cab + account;
|
||||
var digits = new StringBuilder();
|
||||
foreach (var c in bban + "IT00")
|
||||
{
|
||||
digits.Append(char.IsLetter(c) ? (c - 'A' + 10).ToString(CultureInfo.InvariantCulture) : c.ToString());
|
||||
}
|
||||
|
||||
var check = 98 - (int)(BigInteger.Parse(digits.ToString(), CultureInfo.InvariantCulture) % 97);
|
||||
return "IT" + check.ToString("00", CultureInfo.InvariantCulture) + bban;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SeedAsync(string companyCode, CompanySeedContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(context);
|
||||
if (!context.Demo || !licenses.IsModuleActive(ModuleCodes.Finance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var today = DateOnly.FromDateTime(TimeZoneInfo.ConvertTime(clock.GetUtcNow(), TimeZoneInfo.Local).DateTime);
|
||||
long bankId;
|
||||
await using (var uow = await factory.CreateAsync(DatabaseScope.Company(companyCode), cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (await uow.Repository<GlAccount, long>().CountAsync(Query.For<GlAccount>(), cancellationToken).ConfigureAwait(false) == 0
|
||||
|| await uow.Repository<Payment, long>().CountAsync(Query.For<Payment>(), cancellationToken).ConfigureAwait(false) > 0
|
||||
|| await uow.Repository<Remittance, long>().CountAsync(Query.For<Remittance>(), cancellationToken).ConfigureAwait(false) > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await uow.BeginAsync(cancellationToken).ConfigureAwait(false);
|
||||
bankId = await BankAsync(uow, cancellationToken).ConfigureAwait(false);
|
||||
await OpeningAsync(uow, new DateOnly(today.Year, 1, 1), cancellationToken).ConfigureAwait(false);
|
||||
await uow.CommitAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await CollectionsAsync(companyCode, bankId, today, cancellationToken).ConfigureAwait(false);
|
||||
await RibaAsync(companyCode, bankId, today, cancellationToken).ConfigureAwait(false);
|
||||
await MandateAsync(companyCode, today, cancellationToken).ConfigureAwait(false);
|
||||
await StatementAsync(companyCode, bankId, today, cancellationToken).ConfigureAwait(false);
|
||||
await RemindersAsync(companyCode, today, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static async Task<long> BankAsync(IUnitOfWork uow, CancellationToken cancellationToken)
|
||||
{
|
||||
var banks = uow.Repository<BankAccount, long>();
|
||||
var bank = await banks.FindAsync(Query.For<BankAccount>().Where(b => b.Code == BankCode), cancellationToken).ConfigureAwait(false);
|
||||
if (bank is null)
|
||||
{
|
||||
bank = new BankAccount
|
||||
{
|
||||
Code = BankCode,
|
||||
Description = "Conto corrente ordinario",
|
||||
BankName = "Banca Popolare Dimostrativa",
|
||||
Iban = Iban('X', "05034", "01000", "000000012345"),
|
||||
Bic = "DEMOITM1XXX",
|
||||
SiaCode = "A1B2C",
|
||||
CucCode = "DEMO1234",
|
||||
CreditorId = "IT66ZZZ00000000000000000",
|
||||
AccountCode = DemoLedgerSeeder.BankAccount,
|
||||
IsDefault = true,
|
||||
IsDemo = true,
|
||||
};
|
||||
bank.Id = await banks.InsertAsync(bank, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var profile = await uow.Repository<CompanyProfile, long>().FindAsync(Query.For<CompanyProfile>(), cancellationToken).ConfigureAwait(false);
|
||||
if (profile is not null && profile.DefaultBankAccountId is null)
|
||||
{
|
||||
profile.DefaultBankAccountId = bank.Id;
|
||||
await uow.Repository<CompanyProfile, long>().UpdateAsync(profile, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await CustomerBanksAsync(uow, cancellationToken).ConfigureAwait(false);
|
||||
return bank.Id;
|
||||
}
|
||||
|
||||
// The shareholders paid the capital into the bank on the first day of the year, so the account starts in credit.
|
||||
private static async Task OpeningAsync(IUnitOfWork uow, DateOnly day, CancellationToken cancellationToken)
|
||||
{
|
||||
var bank = await LedgerStore.AccountAsync(uow, DemoLedgerSeeder.BankAccount, cancellationToken).ConfigureAwait(false);
|
||||
var capital = await LedgerStore.AccountAsync(uow, CapitalAccount, cancellationToken).ConfigureAwait(false);
|
||||
if (bank is null || capital is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await TreasuryStore.PostAsync(uow, "GIRO", day, "Versamento soci in conto capitale", null,
|
||||
[new PaymentPostedLine(bank.Id, null, null, null, OpeningBalance, 0m), new PaymentPostedLine(capital.Id, null, null, null, 0m, OpeningBalance)], true, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// The customers who pay by RiBa or direct debit need the coordinates of their bank: the demo parties that have none
|
||||
// get one, so the remittances are complete.
|
||||
private static async Task CustomerBanksAsync(IUnitOfWork uow, CancellationToken cancellationToken)
|
||||
{
|
||||
var collected = (await uow.Repository<PaymentMethod, long>().ListAsync(Query.For<PaymentMethod>(), cancellationToken).ConfigureAwait(false)).Items
|
||||
.Where(m => m.Code is "RIBA" or "SDD" or "SDDB").Select(m => (long?)m.Id).ToList();
|
||||
var receivable = OpenItemDirection.Receivable;
|
||||
var parties = (await uow.Repository<OpenItem, long>().ListAsync(
|
||||
Query.For<OpenItem>().Where(o => o.Direction == receivable && !o.Closed && collected.Contains(o.PaymentMethodId)), cancellationToken).ConfigureAwait(false)).Items
|
||||
.Select(o => o.PartyId).Distinct().Order().ToList();
|
||||
(string Abi, string Cab, string Name)[] branches = [("03069", "01000", "Banca del Territorio"), ("02008", "30330", "Banca Subalpina"), ("05696", "11000", "Credito Cooperativo Demo")];
|
||||
var n = 0;
|
||||
foreach (var partyId in parties)
|
||||
{
|
||||
var accounts = uow.Repository<PartyBankAccount, long>();
|
||||
if (await accounts.CountAsync(Query.For<PartyBankAccount>().Where(a => a.PartyId == partyId), cancellationToken).ConfigureAwait(false) > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var branch = branches[n++ % branches.Length];
|
||||
await accounts.InsertAsync(new PartyBankAccount
|
||||
{
|
||||
PartyId = partyId,
|
||||
Iban = Iban('K', branch.Abi, branch.Cab, (100000 + partyId).ToString("000000000000", CultureInfo.InvariantCulture)),
|
||||
BankName = branch.Name,
|
||||
BankCode = branch.Abi,
|
||||
BranchCode = branch.Cab,
|
||||
IsDefault = true,
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
// The invoices paid by transfer or on the spot are collected on their due date when it is more than three weeks
|
||||
// ago; the oldest of one customer only in half, so the schedule shows a partial item. The suppliers, RiBa included,
|
||||
// are paid on their due date when it is more than a week ago.
|
||||
private async Task CollectionsAsync(string companyCode, long bankId, DateOnly today, CancellationToken cancellationToken)
|
||||
{
|
||||
List<OpenItem> items;
|
||||
Dictionary<long, PaymentMethod> methods;
|
||||
await using (var uow = await factory.CreateAsync(DatabaseScope.Company(companyCode), cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
var limit = today.AddDays(-7);
|
||||
var customers = today.AddDays(-21);
|
||||
items = [.. (await uow.Repository<OpenItem, long>().ListAsync(
|
||||
Query.For<OpenItem>().Where(o => !o.Closed && o.DueDate <= limit).OrderBy(o => o.DueDate).OrderBy(o => o.Id), cancellationToken).ConfigureAwait(false)).Items
|
||||
.Where(o => o.Direction == OpenItemDirection.Payable || o.DueDate <= customers)];
|
||||
methods = (await uow.Repository<PaymentMethod, long>().ListAsync(Query.For<PaymentMethod>(), cancellationToken).ConfigureAwait(false)).Items.ToDictionary(m => m.Id);
|
||||
}
|
||||
|
||||
var partialDone = false;
|
||||
foreach (var item in items.Where(i => i.Residual > 0m))
|
||||
{
|
||||
var method = item.PaymentMethodId is { } m ? methods.GetValueOrDefault(m) : null;
|
||||
var receivable = item.Direction == OpenItemDirection.Receivable;
|
||||
if (receivable && method?.Code is "RIBA" or "SDD" or "SDDB")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var amount = item.Residual;
|
||||
if (receivable && !partialDone && method?.Code == "BON")
|
||||
{
|
||||
// The first transfer collected only in half: the rest stays overdue for the reminders.
|
||||
amount = Math.Round(item.Residual / 2m, 2, MidpointRounding.AwayFromZero);
|
||||
partialDone = true;
|
||||
}
|
||||
|
||||
await payments.RegisterAsync(Seed, companyCode, new PaymentInput(
|
||||
receivable ? PaymentDirection.Receipt : PaymentDirection.Disbursement, item.PartyId, item.DueDate, item.PaymentMethodId, bankId,
|
||||
receivable ? 0m : 1.50m, "CRO " + item.Id.ToString("000000", CultureInfo.InvariantCulture), null,
|
||||
[new PaymentLineInput(item.Id, amount)]), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
// The RiBa due before today in a remittance presented and credited, the effect of one customer back unpaid;
|
||||
// those due in the next 45 days in a draft remittance ready for the file.
|
||||
private async Task RibaAsync(string companyCode, long bankId, DateOnly today, CancellationToken cancellationToken)
|
||||
{
|
||||
var due = (await remittances.CandidatesAsync(Seed, companyCode, RemittanceKind.Riba, today.AddDays(-1), cancellationToken).ConfigureAwait(false))
|
||||
.Where(c => c.Ready).ToList();
|
||||
if (due.Count > 0)
|
||||
{
|
||||
var presentation = due.Min(c => c.Row.Item.DueDate).AddDays(-20);
|
||||
var remittance = await remittances.CreateAsync(Seed, companyCode, new RemittanceInput(
|
||||
RemittanceKind.Riba, bankId, presentation, today.AddDays(-1), false, "Distinta dimostrativa", [.. due.Select(c => c.Row.Item.Id)]), cancellationToken).ConfigureAwait(false);
|
||||
await remittances.PresentAsync(Seed, companyCode, remittance.Id, cancellationToken).ConfigureAwait(false);
|
||||
var latest = due.Max(c => c.Row.Item.DueDate);
|
||||
await remittances.CreditAsync(Seed, companyCode, remittance.Id, latest, cancellationToken).ConfigureAwait(false);
|
||||
var lines = (await remittances.GetAsync(Seed, companyCode, remittance.Id, cancellationToken).ConfigureAwait(false))!.Value.Lines;
|
||||
var unpaid = lines.OrderByDescending(l => l.Line.DueDate).First();
|
||||
var day = unpaid.Line.DueDate.AddDays(5);
|
||||
await remittances.UnpaidAsync(Seed, companyCode, unpaid.Line.Id, day > today ? today : day, UnpaidFees, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var next = (await remittances.CandidatesAsync(Seed, companyCode, RemittanceKind.Riba, today.AddDays(45), cancellationToken).ConfigureAwait(false))
|
||||
.Where(c => c.Ready && c.Row.Item.DueDate >= today && c.Row.Item.Status != OpenItemStatus.Unpaid).ToList();
|
||||
if (next.Count > 0)
|
||||
{
|
||||
await remittances.CreateAsync(Seed, companyCode, new RemittanceInput(
|
||||
RemittanceKind.Riba, bankId, today, today.AddDays(45), true, "Da presentare con anticipo s.b.f.", [.. next.Select(c => c.Row.Item.Id)]), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task MandateAsync(string companyCode, DateOnly today, CancellationToken cancellationToken)
|
||||
{
|
||||
await using var uow = await factory.CreateAsync(DatabaseScope.Company(companyCode), cancellationToken).ConfigureAwait(false);
|
||||
var party = await uow.Repository<Party, long>().FindAsync(Query.For<Party>().Where(p => p.Name == "Idrotermica Piemonte S.r.l."), cancellationToken).ConfigureAwait(false);
|
||||
if (party is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var account = await uow.Repository<PartyBankAccount, long>().FindAsync(Query.For<PartyBankAccount>().Where(a => a.PartyId == party.Id), cancellationToken).ConfigureAwait(false);
|
||||
await mandates.SaveAsync(Seed, companyCode, new MandateInput(
|
||||
null, party.Id, "KH-MND-" + party.Code, new DateOnly(today.Year, 1, 15), SddScheme.Core, account?.Iban ?? Iban('A', "06230", "10000", "000046012345"), null, false,
|
||||
"Mandato firmato in sede"), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// A statement of the last days in CSV: a transfer received for an open invoice, a transfer to a supplier
|
||||
// already recorded, the monthly fee of the account (matched by a saved rule) and a movement nobody knows yet.
|
||||
private async Task StatementAsync(string companyCode, long bankId, DateOnly today, CancellationToken cancellationToken)
|
||||
{
|
||||
OpenItem? open;
|
||||
Payment? paid;
|
||||
string? openParty;
|
||||
long? feeAccount;
|
||||
await using (var uow = await factory.CreateAsync(DatabaseScope.Company(companyCode), cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
var receivable = OpenItemDirection.Receivable;
|
||||
// The customer who paid half pays the rest: the movement matches the item, which names the invoice.
|
||||
open = (await uow.Repository<OpenItem, long>().ListAsync(
|
||||
Query.For<OpenItem>().Where(o => o.Direction == receivable && !o.Closed && (o.Status == OpenItemStatus.Partial || o.Status == OpenItemStatus.Open)).OrderBy(o => o.DueDate),
|
||||
cancellationToken).ConfigureAwait(false)).Items
|
||||
.Where(o => o.Residual > 0m && o.DocumentNumber is not null && o.DueDate <= today)
|
||||
.OrderByDescending(o => o.Status == OpenItemStatus.Partial).FirstOrDefault();
|
||||
openParty = open is null ? null : (await uow.Repository<Party, long>().GetAsync(open.PartyId, cancellationToken).ConfigureAwait(false))?.Name;
|
||||
paid = await uow.Repository<Payment, long>().FindAsync(
|
||||
Query.For<Payment>().Where(p => p.Direction == PaymentDirection.Disbursement).OrderByDescending(p => p.PaymentDate), cancellationToken).ConfigureAwait(false);
|
||||
feeAccount = (await uow.Repository<GlAccount, long>().FindAsync(Query.For<GlAccount>().Where(a => a.Code == "21.03.011"), cancellationToken).ConfigureAwait(false))?.Id;
|
||||
}
|
||||
|
||||
if (feeAccount is { } fees)
|
||||
{
|
||||
await reconciliation.SaveRuleAsync(Seed, companyCode, new BankRuleInput(null, "Canone e commissioni", "COMMISSIONI", BankRuleDirection.Out, fees, "Canone mensile conto corrente", false), cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var culture = CultureInfo.GetCultureInfo("it-IT");
|
||||
var csv = new StringBuilder("Data contabile;Data valuta;Descrizione;Importo\r\n");
|
||||
void Row(DateOnly day, string text, decimal amount) =>
|
||||
csv.Append(day.ToString("dd/MM/yyyy", culture)).Append(';').Append(day.ToString("dd/MM/yyyy", culture)).Append(';').Append(text).Append(';')
|
||||
.Append(amount.ToString("0.00", culture)).Append("\r\n");
|
||||
if (open is not null)
|
||||
{
|
||||
Row(today.AddDays(-4), "BONIFICO A VOSTRO FAVORE DA " + (openParty ?? string.Empty).ToUpperInvariant() + " SALDO FT " + open.DocumentNumber, open.Residual);
|
||||
}
|
||||
|
||||
if (paid is not null)
|
||||
{
|
||||
Row(paid.PaymentDate, "BONIFICO SEPA " + paid.Reference, -(paid.Amount + paid.Fees));
|
||||
}
|
||||
|
||||
Row(today.AddDays(-3), "COMMISSIONI E CANONE MENSILE CONTO", -AccountFee);
|
||||
Row(today.AddDays(-2), "PAGAMENTO POS CARBURANTE", -64.20m);
|
||||
await reconciliation.ImportAsync(Seed, companyCode, bankId, "estratto-demo.csv", Encoding.UTF8.GetBytes(csv.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// The first reminder already sent ten days ago to the customer with the oldest overdue item.
|
||||
private async Task RemindersAsync(string companyCode, DateOnly today, CancellationToken cancellationToken)
|
||||
{
|
||||
await using var uow = await factory.CreateAsync(DatabaseScope.Company(companyCode), cancellationToken).ConfigureAwait(false);
|
||||
await uow.BeginAsync(cancellationToken).ConfigureAwait(false);
|
||||
var receivable = OpenItemDirection.Receivable;
|
||||
var limit = today.AddDays(-20);
|
||||
var overdue = (await uow.Repository<OpenItem, long>().ListAsync(
|
||||
Query.For<OpenItem>().Where(o => o.Direction == receivable && !o.Closed && o.DueDate <= limit && o.Status != OpenItemStatus.InRemittance).OrderBy(o => o.DueDate), cancellationToken)
|
||||
.ConfigureAwait(false)).Items.Where(o => o.Residual > 0m).ToList();
|
||||
var parties = await TreasuryStore.PartiesAsync(uow, overdue.Select(o => o.PartyId), cancellationToken).ConfigureAwait(false);
|
||||
var first = overdue.FirstOrDefault(o => parties.TryGetValue(o.PartyId, out var p) && p.SubjectType != SubjectType.PublicAdministration);
|
||||
if (first is null)
|
||||
{
|
||||
await uow.CommitAsync(cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var party = parties[first.PartyId];
|
||||
var items = overdue.Where(o => o.PartyId == first.PartyId).ToList();
|
||||
var sent = today.AddDays(-10);
|
||||
await uow.Repository<DunningLetter, long>().InsertAsync(new DunningLetter
|
||||
{
|
||||
PartyId = party.Id,
|
||||
Level = 1,
|
||||
SentOn = sent,
|
||||
Channel = DunningChannel.Email,
|
||||
Recipients = party.Email,
|
||||
Subject = "Promemoria scadenze",
|
||||
ItemCount = items.Count,
|
||||
OverdueAmount = items.Sum(i => i.Residual),
|
||||
Status = DunningLetterStatus.Sent,
|
||||
SentBy = "demo",
|
||||
IsDemo = true,
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.DunningLevel = 1;
|
||||
item.LastDunningDate = sent;
|
||||
await uow.Repository<OpenItem, long>().UpdateAsync(item, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await uow.CommitAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -209,6 +209,8 @@ internal static class KhaemhatServices
|
||||
services.AddSingleton<ICompanySeeder>(sp => sp.GetRequiredService<DemoPurchasesSeeder>());
|
||||
services.AddSingleton<DemoLedgerSeeder>();
|
||||
services.AddSingleton<ICompanySeeder>(sp => sp.GetRequiredService<DemoLedgerSeeder>());
|
||||
services.AddSingleton<DemoTreasurySeeder>();
|
||||
services.AddSingleton<ICompanySeeder>(sp => sp.GetRequiredService<DemoTreasurySeeder>());
|
||||
services.AddSingleton<CompanyService>();
|
||||
services.AddSingleton<CompanyContextResolver>();
|
||||
services.AddScoped<ICompanyContext, WebCompanyContext>();
|
||||
|
||||
@@ -134,6 +134,7 @@ public static class SeedCommand
|
||||
await services.GetRequiredService<DemoSalesSeeder>().SeedAsync(code, new CompanySeedContext(IsNew: false, Base: false, Demo: true)).ConfigureAwait(false);
|
||||
await services.GetRequiredService<DemoPurchasesSeeder>().SeedAsync(code, new CompanySeedContext(IsNew: false, Base: false, Demo: true)).ConfigureAwait(false);
|
||||
await services.GetRequiredService<DemoLedgerSeeder>().SeedAsync(code, new CompanySeedContext(IsNew: false, Base: false, Demo: true)).ConfigureAwait(false);
|
||||
await services.GetRequiredService<DemoTreasurySeeder>().SeedAsync(code, new CompanySeedContext(IsNew: false, Base: false, Demo: true)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user