Customers, suppliers, prospects and leads live in one parties archive with a kind and a subject type (ADR 0029). A customer that also supplies carries is_also_supplier, so it shows in both radars with one code. - Three radars (/anagrafiche/clienti, /fornitori, /contatti) with search, quick filters and bulk disable/enable; the record has eight tabs (main data, addresses, contacts, terms, fiscal and SDI, banks, notes and attachments, history) on the MasterDataPage base. - PartyService saves the whole record in one transaction, checks it with the fiscal pack (VAT number, tax code, recipient code, country), treats a duplicate VAT number or a consumer without tax code as warnings, fills the default recipient code, runs VIES after commit for EU companies, and converts prospects/leads (new customer code, old one kept as previous_code) and suppliers (become customers that also supply). - Delete falls back to disable when the party is referenced. - DemoPartiesSeeder adds 3 salespeople and 21 parties with fictitious but formally valid identifiers; SeedAsync now runs demo seeders when asked. - Test host accepts service overrides so VIES can be stubbed. Docs: ADR 0029, wiki Anagrafiche and demo data pages, regenerated data model, CHANGELOG and STATUS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
4.0 KiB
C#
78 lines
4.0 KiB
C#
using Khaemhat.Application.Parties;
|
|
using Khaemhat.Core.Parties;
|
|
using Khaemhat.Web.Parties;
|
|
using Khaemhat.Web.Shell;
|
|
using Khaemhat.Web.Tests.Shell;
|
|
using Khaemhat.Web.Ui;
|
|
|
|
namespace Khaemhat.Web.Tests.Parties;
|
|
|
|
/// <summary>Addresses, tabs and texts of the party screens (issue #41).</summary>
|
|
[TestClass]
|
|
public sealed class PartyScreensTests
|
|
{
|
|
[TestMethod]
|
|
public void Addresses_GoBackAndForthBetweenArchivesAndRecords()
|
|
{
|
|
Assert.AreEqual(PartyArchive.Suppliers, PartyScreens.ArchiveOf("anagrafiche/fornitori/12?x=1"));
|
|
Assert.AreEqual(PartyArchive.Contacts, PartyScreens.ArchiveOf("/anagrafiche/contatti/nuovo"));
|
|
Assert.AreEqual(PartyArchive.Customers, PartyScreens.ArchiveOf("anagrafiche/clienti"));
|
|
Assert.AreEqual("anagrafiche/fornitori/42", PartyScreens.RecordUrl(PartyArchive.Suppliers, 42));
|
|
Assert.AreEqual("anagrafiche/contatti/nuovo?tipo=lead", PartyScreens.NewUrl(PartyArchive.Contacts, PartyKind.Lead));
|
|
Assert.AreEqual("anagrafiche/contatti/nuovo", PartyScreens.NewUrl(PartyArchive.Contacts, PartyKind.Prospect));
|
|
Assert.AreEqual(PartyKind.Lead, PartyScreens.KindOf(PartyArchive.Contacts, "lead"));
|
|
Assert.AreEqual(PartyKind.Customer, PartyScreens.KindOf(PartyArchive.Customers, "lead"), "A kind of another archive is ignored.");
|
|
Assert.AreEqual(PartyArchive.Contacts, PartyScreens.ArchiveOf(PartyKind.Lead));
|
|
|
|
// Every radar is a page of the menu.
|
|
var menu = MenuCatalog.All.Single(i => i.Key == "Shell.Menu.Parties").Children.Select(c => c.Href).ToList();
|
|
foreach (var archive in Enum.GetValues<PartyArchive>())
|
|
{
|
|
CollectionAssert.Contains(menu, "/" + PartyScreens.RadarUrl(archive));
|
|
}
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Errors_OpenTheTabOfTheirField()
|
|
{
|
|
Assert.AreEqual(PartyScreens.Tabs.Main, PartyScreens.TabOf("VatNumber"));
|
|
Assert.AreEqual(PartyScreens.Tabs.Fiscal, PartyScreens.TabOf("Fiscal.RecipientCode"));
|
|
Assert.AreEqual(PartyScreens.Tabs.Terms, PartyScreens.TabOf("Purchase.OrdersEmail"));
|
|
Assert.AreEqual(PartyScreens.Tabs.Contacts, PartyScreens.TabOf("Contacts.2.Email"));
|
|
Assert.AreEqual(PartyScreens.Tabs.Banks, PartyScreens.TabOf("BankAccounts.0.Iban"));
|
|
Assert.AreEqual(PartyScreens.Tabs.Addresses, PartyScreens.TabOf("Addresses.1.Name"));
|
|
Assert.AreEqual(PartyScreens.Tabs.Notes, PartyScreens.TabOf("Notes"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Choices_HaveTexts_AndLookupsShowTheirCode()
|
|
{
|
|
var texts = ShellTests.Texts;
|
|
foreach (var (group, values) in new (string, IEnumerable<string>)[]
|
|
{
|
|
("Kinds", Enum.GetNames<PartyKind>()), ("SubjectTypes", Enum.GetNames<SubjectType>()), ("Delivery", Enum.GetNames<DocumentDelivery>()),
|
|
("AddressKinds", Enum.GetNames<PartyAddressKind>()), ("Archives", Enum.GetNames<PartyArchive>()),
|
|
("Vies", Enum.GetNames<VatCheckStatus>().Where(v => v != nameof(VatCheckStatus.None))), ("New", Enum.GetNames<PartyKind>()),
|
|
})
|
|
{
|
|
foreach (var value in values)
|
|
{
|
|
Assert.IsTrue(texts.Contains("Parties." + group + "." + value), "Parties." + group + "." + value);
|
|
}
|
|
}
|
|
|
|
// The fields of the service errors have a label for the history.
|
|
foreach (var field in typeof(Party).GetProperties().Where(p => p.CanWrite && p.Name is not ("Id" or "IsDemo" or "RowVersion" or "CreatedAt" or "CreatedBy" or "UpdatedAt" or "UpdatedBy")))
|
|
{
|
|
Assert.IsTrue(texts.Contains("Parties.Fields." + field.Name), field.Name);
|
|
}
|
|
|
|
IReadOnlyList<KhOption<string>> terms = [new("7", "RB60 · Ricevuta bancaria 60 gg")];
|
|
Assert.AreEqual("RB60", PartyScreens.Describe(terms, 7));
|
|
Assert.AreEqual("Ricevuta bancaria 60 gg", PartyScreens.Describe(terms, 7, full: true));
|
|
Assert.IsNull(PartyScreens.Describe(terms, 8));
|
|
Assert.AreEqual(12L, PartyScreens.Id(PartyScreens.Text(12)));
|
|
Assert.IsNull(PartyScreens.Id(string.Empty));
|
|
}
|
|
}
|