Advanced Client work for Safeco
This commit is contained in:
parent
7e87e59683
commit
26406053db
1 changed files with 32 additions and 2 deletions
|
|
@ -336,8 +336,38 @@ export default class ClientData {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getClientByTag(clientTag: string) {
|
static getClientByTag(clientTag: string) {
|
||||||
return [...essentialClients, ...advancedClients].find(
|
return this.resolveClientForTest(clientTag);
|
||||||
client => client.clientTag === clientTag
|
}
|
||||||
|
|
||||||
|
static getClientByAccountNumber(accountNumber: string) {
|
||||||
|
const advancedMatch = advancedClients.find(client => client.accountNumber === accountNumber);
|
||||||
|
if (advancedMatch) {
|
||||||
|
return advancedMatch;
|
||||||
|
}
|
||||||
|
return essentialClients.find(client => client.accountNumber === accountNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resolveClientForTest(clientTag: string, accountNumber?: string): IClient | undefined {
|
||||||
|
const normalizedTag = clientTag.toLowerCase();
|
||||||
|
|
||||||
|
if (accountNumber) {
|
||||||
|
const clientByAccount = this.getClientByAccountNumber(accountNumber);
|
||||||
|
if (clientByAccount?.clientTag.toLowerCase() === normalizedTag) {
|
||||||
|
return clientByAccount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const essentialMatch = essentialClients.find(
|
||||||
|
client => client.clientTag.toLowerCase() === normalizedTag
|
||||||
);
|
);
|
||||||
|
const advancedMatch = advancedClients.find(
|
||||||
|
client => client.clientTag.toLowerCase() === normalizedTag
|
||||||
|
);
|
||||||
|
|
||||||
|
if (essentialMatch && advancedMatch) {
|
||||||
|
return essentialMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
return advancedMatch ?? essentialMatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue