mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 09:58:12 +00:00
feat(etrade): take the selected licence's trade name as the company name
A TIN routinely trades under a name that is not its registered one, and holds several licences with different trade names — of 58 TINs checked against eTrade, 8 had at least one licence whose trade name differs from the registered `BusinessName`, one of them across three licences. `extractRegistrationData` now resolves `companyName` from the selected licence's `TradeName`, falling back to `BusinessName` (16 of 309 licences carry a blank trade name, so the fallback is load-bearing). EIMS is pinned back to `BusinessName` for the seller's `LegalName`: an invoice is a MoR tax filing and must carry the legal entity, not the trade name. It is the only other caller.
This commit is contained in:
@@ -78,6 +78,27 @@ describe('ETradeService business selection', () => {
|
|||||||
expect(data.businesses?.[0].activity).toBe('Export trade in minerals');
|
expect(data.businesses?.[0].activity).toBe('Export trade in minerals');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("takes the selected licence's trade name as the company name", () => {
|
||||||
|
const { service } = build();
|
||||||
|
const data = service.extractRegistrationData(
|
||||||
|
{
|
||||||
|
LicenceNumber: 'MT/AA/14/670/128936/2007',
|
||||||
|
TradeName: 'Pave Freight Forwarding',
|
||||||
|
} as ETradeBusinessInfo,
|
||||||
|
companyInfo(),
|
||||||
|
);
|
||||||
|
expect(data.companyName).toBe('Pave Freight Forwarding');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to the registered name when the licence has no trade name', () => {
|
||||||
|
const { service } = build();
|
||||||
|
const data = service.extractRegistrationData(
|
||||||
|
{ LicenceNumber: 'x', TradeName: ' ' } as ETradeBusinessInfo,
|
||||||
|
companyInfo(),
|
||||||
|
);
|
||||||
|
expect(data.companyName).toBe('PAVE LOGISTICS AND TRADING P L C');
|
||||||
|
});
|
||||||
|
|
||||||
it('lists every licence for the picker, code prefixes stripped', () => {
|
it('lists every licence for the picker, code prefixes stripped', () => {
|
||||||
const { service } = build();
|
const { service } = build();
|
||||||
const data = service.extractRegistrationData(
|
const data = service.extractRegistrationData(
|
||||||
|
|||||||
@@ -102,10 +102,16 @@ export class ETradeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `companyInfo` carries the registered organization name (`BusinessName`);
|
* `businessInfo` carries the selected licence's `TradeName`; `companyInfo`
|
||||||
* `businessInfo` only carries the licence's `TradeName`. Pass both so the
|
* carries the registered organization name (`BusinessName`). The company name
|
||||||
* company name resolves to the legal entity rather than the trade name — and
|
* resolves to the trade name of the licence the customer picked — a TIN
|
||||||
* never to `ManagerNameEng`, which is the manager's personal name.
|
* routinely trades under a name that is not its registered one, and the
|
||||||
|
* business they selected is the one they operate as here. `BusinessName` is
|
||||||
|
* the fallback, because eTrade leaves `TradeName` blank on plenty of licences.
|
||||||
|
* Never `ManagerNameEng`, which is the manager's personal name.
|
||||||
|
*
|
||||||
|
* Callers that need the legal entity (tax filings, EIMS seller details) must
|
||||||
|
* read `companyInfo.BusinessName` themselves — it is not this field.
|
||||||
*/
|
*/
|
||||||
extractRegistrationData(
|
extractRegistrationData(
|
||||||
businessInfo: ETradeBusinessInfo,
|
businessInfo: ETradeBusinessInfo,
|
||||||
@@ -115,7 +121,7 @@ export class ETradeService {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
companyName:
|
companyName:
|
||||||
companyInfo?.BusinessName?.trim() || businessInfo.TradeName?.trim() || "",
|
businessInfo.TradeName?.trim() || companyInfo?.BusinessName?.trim() || "",
|
||||||
licenceNumber: businessInfo.LicenceNumber,
|
licenceNumber: businessInfo.LicenceNumber,
|
||||||
statusDescription: businessInfo.StatusDescription,
|
statusDescription: businessInfo.StatusDescription,
|
||||||
dateRegistered: businessInfo.DateRegistered,
|
dateRegistered: businessInfo.DateRegistered,
|
||||||
|
|||||||
@@ -118,7 +118,11 @@ export class EimsSellerCacheService implements OnModuleInit {
|
|||||||
woreda: data.woreda,
|
woreda: data.woreda,
|
||||||
});
|
});
|
||||||
this.cached = {
|
this.cached = {
|
||||||
LegalName: data.companyName || undefined,
|
// The *legal* entity name, not the licence's trade name that
|
||||||
|
// `data.companyName` now carries — an EIMS seller is filed under its
|
||||||
|
// registered name.
|
||||||
|
LegalName:
|
||||||
|
companyInfo?.BusinessName?.trim() || data.companyName || undefined,
|
||||||
Phone: data.mobilePhone || data.regularPhone || undefined,
|
Phone: data.mobilePhone || data.regularPhone || undefined,
|
||||||
Region: geo?.Region,
|
Region: geo?.Region,
|
||||||
Wereda: geo?.Wereda,
|
Wereda: geo?.Wereda,
|
||||||
|
|||||||
@@ -76,9 +76,14 @@ export interface ETradeBusinessOption {
|
|||||||
|
|
||||||
export interface CompanyRegistrationData {
|
export interface CompanyRegistrationData {
|
||||||
/**
|
/**
|
||||||
* The registered organization name — `ETradeCompanyInfo.BusinessName`, falling
|
* The selected licence's trade name — `ETradeBusinessInfo.TradeName`, falling
|
||||||
* back to the licence's `TradeName`. Never the manager/owner's personal name;
|
* back to the registered organization name (`ETradeCompanyInfo.BusinessName`)
|
||||||
* that is {@link managerName}.
|
* when eTrade leaves the licence's trade name blank. Never the manager/owner's
|
||||||
|
* personal name; that is {@link managerName}.
|
||||||
|
*
|
||||||
|
* NOT the legal entity name: a TIN often trades under a different name, and
|
||||||
|
* some hold several licences with different trade names. Anything that needs
|
||||||
|
* the registered name (tax/EIMS) must read `BusinessName` directly.
|
||||||
*/
|
*/
|
||||||
companyName: string;
|
companyName: string;
|
||||||
licenceNumber: string;
|
licenceNumber: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user