@oneblink/sdk-core 0.3.2-beta.4 → 0.3.2-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abnService.js +18 -10
- package/dist/abnService.js.map +1 -1
- package/package.json +1 -1
package/dist/abnService.js
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.displayABNNumberFromABNRecord = exports.getABNNumberFromABNRecord = exports.displayBusinessNameFromABNRecord = exports.getBusinessNameFromABNRecord = void 0;
|
|
4
|
+
const createLegalName = ({ familyName, givenName, otherGivenName, }) => {
|
|
5
|
+
let legalName = '';
|
|
6
|
+
if (givenName)
|
|
7
|
+
legalName += `${givenName} `;
|
|
8
|
+
// Concat middle name
|
|
9
|
+
if (otherGivenName)
|
|
10
|
+
legalName += `${otherGivenName} `;
|
|
11
|
+
// Concat last name
|
|
12
|
+
if (familyName)
|
|
13
|
+
legalName += `${familyName}`;
|
|
14
|
+
return legalName;
|
|
15
|
+
};
|
|
4
16
|
const getBusinessNameFromABNRecord = (abnRecord) => {
|
|
5
17
|
var _a, _b;
|
|
18
|
+
if (abnRecord.entityType.entityTypeCode === 'IND' && abnRecord.legalName) {
|
|
19
|
+
const legalName = createLegalName(abnRecord.legalName);
|
|
20
|
+
if (legalName)
|
|
21
|
+
return legalName.trim();
|
|
22
|
+
}
|
|
6
23
|
if ((_a = abnRecord.mainName) === null || _a === void 0 ? void 0 : _a.organisationName) {
|
|
7
24
|
return abnRecord.mainName.organisationName;
|
|
8
25
|
}
|
|
@@ -10,16 +27,7 @@ const getBusinessNameFromABNRecord = (abnRecord) => {
|
|
|
10
27
|
return abnRecord.mainTradingName.organisationName;
|
|
11
28
|
}
|
|
12
29
|
if (abnRecord.legalName) {
|
|
13
|
-
const
|
|
14
|
-
let legalName = '';
|
|
15
|
-
if (givenName)
|
|
16
|
-
legalName += `${givenName} `;
|
|
17
|
-
// Concat middle name
|
|
18
|
-
if (otherGivenName)
|
|
19
|
-
legalName += `${otherGivenName} `;
|
|
20
|
-
// Concat last name
|
|
21
|
-
if (familyName)
|
|
22
|
-
legalName += `${familyName}`;
|
|
30
|
+
const legalName = createLegalName(abnRecord.legalName);
|
|
23
31
|
if (legalName)
|
|
24
32
|
return legalName.trim();
|
|
25
33
|
}
|
package/dist/abnService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abnService.js","sourceRoot":"","sources":["../src/abnService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"abnService.js","sourceRoot":"","sources":["../src/abnService.ts"],"names":[],"mappings":";;;AAEA,MAAM,eAAe,GAAG,CAAC,EACvB,UAAU,EACV,SAAS,EACT,cAAc,GACsB,EAAE,EAAE;IACxC,IAAI,SAAS,GAAG,EAAE,CAAA;IAClB,IAAI,SAAS;QAAE,SAAS,IAAI,GAAG,SAAS,GAAG,CAAA;IAC3C,qBAAqB;IACrB,IAAI,cAAc;QAAE,SAAS,IAAI,GAAG,cAAc,GAAG,CAAA;IACrD,mBAAmB;IACnB,IAAI,UAAU;QAAE,SAAS,IAAI,GAAG,UAAU,EAAE,CAAA;IAE5C,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAEM,MAAM,4BAA4B,GAAG,CAC1C,SAAoB,EACA,EAAE;;IACtB,IAAI,SAAS,CAAC,UAAU,CAAC,cAAc,KAAK,KAAK,IAAI,SAAS,CAAC,SAAS,EAAE;QACxE,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC,IAAI,EAAE,CAAA;KACvC;IAED,IAAI,MAAA,SAAS,CAAC,QAAQ,0CAAE,gBAAgB,EAAE;QACxC,OAAO,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAA;KAC3C;IACD,IAAI,MAAA,SAAS,CA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enName,\n}: NonNullable<ABNRecord['legalName']>) => {\n let legalName = ''\n if (givenName) legalName += `${givenName} `\n // Concat middle name\n if (otherGivenName) legalName += `${otherGivenName} `\n // Concat last name\n if (familyName) legalName += `${familyName}`\n\n return legalName\n}\n\nexport const getBusinessNameFromABNRecord = (\n abnRecord: ABNRecord,\n): string | undefined => {\n if (abnRecord.entityType.entityTypeCode === 'IND' && abnRecord.legalName) {\n const legalName = createLegalName(abnRecord.legalName)\n if (legalName) return legalName.trim()\n }\n\n if (abnRecord.mainName?.organisationName) {\n return abnRecord.mainName.organisationName\n }\n if (abnRecord.mainTradingName?.organisationName) {\n return abnRecord.mainTradingName.organisationName\n }\n if (abnRecord.legalName) {\n const legalName = createLegalName(abnRecord.legalName)\n if (legalName) return legalName.trim()\n }\n}\n\nexport const displayBusinessNameFromABNRecord = (\n abnRecord: ABNRecord,\n): string => {\n const businessName = getBusinessNameFromABNRecord(abnRecord)\n return businessName || 'Unknown Business Name'\n}\n\nexport const getABNNumberFromABNRecord = (\n abnRecord: ABNRecord,\n): string | undefined => {\n if (!abnRecord.ABN) return\n if (Array.isArray(abnRecord.ABN)) {\n const relevantABN = abnRecord.ABN.find((abn) => abn.isCurrentIndicator)\n return relevantABN?.identifierValue\n }\n return abnRecord.ABN.identifierValue\n}\nexport const displayABNNumberFromABNRecord = (abnRecord: ABNRecord): string => {\n const abnNumber = getABNNumberFromABNRecord(abnRecord)\n return abnNumber || 'Unknown ABN Number'\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneblink/sdk-core",
|
|
3
3
|
"description": "OneBlink SDK for JavaScript (works in Browsers and NodeJS)",
|
|
4
|
-
"version": "0.3.2-beta.
|
|
4
|
+
"version": "0.3.2-beta.5",
|
|
5
5
|
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/oneblink/sdk-core-js/issues"
|