bp - company + account data
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -175,7 +175,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'id', 'name', 'address.address1', 'address.address2', 'address.postalCode', 'address.city',
'address.department', 'address.region', 'address.country',
'address.coordinates', 'logo', 'issuer', 'distanceMeters', 'createdOn', 'lastChangedOn',
- 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName', 'accountData'
+ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName'
]
},
{
@@ -233,7 +233,9 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
attributes: [
'id', 'name', 'issuer', 'logo',
'address.address1', 'address.address2', 'address.postalCode', 'address.city',
- 'address.department', 'address.region', 'address.country', 'address.coordinates', 'accountData'
+ 'address.department', 'address.region', 'address.country', 'address.coordinates',
+ 'accountData.accountID', 'accountData.platformFeeStrategy.flatFeePerSession', 'accountData.platformFeeStrategy.percentage',
+ 'accountData.account.businessOwner'
]
},
{
@@ -256,7 +258,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'address.department', 'address.region', 'address.country',
'address.coordinates', 'companyID', 'company.name', 'autoUserSiteAssignment', 'issuer',
'autoUserSiteAssignment', 'distanceMeters', 'public', 'createdOn', 'lastChangedOn',
- 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName', 'connectorStats', 'accountData'
+ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName', 'connectorStats'
]
},
{
@@ -265,7 +267,9 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'id', 'name', 'companyID', 'company.name', 'autoUserSiteAssignment', 'issuer',
'autoUserSiteAssignment', 'distanceMeters', 'public', 'createdOn', 'lastChangedOn', 'tariffID',
'address.address1', 'address.address2', 'address.postalCode', 'address.city',
- 'address.department', 'address.region', 'address.country', 'address.coordinates', 'accountData'
+ 'address.department', 'address.region', 'address.country', 'address.coordinates',
+ 'accountData.accountID', 'accountData.platformFeeStrategy.flatFeePerSession', 'accountData.platformFeeStrategy.percentage',
+ 'accountData.account.businessOwner'
]
},
{

MODIFY
src/storage/mongodb/CompanyStorage.ts
src/storage/mongodb/CompanyStorage.ts
+import Tenant, { TenantComponents } from '../../types/Tenant';
import global, { DatabaseCount, FilterParams, Logo } from '../../types/GlobalType';
import Company from '../../types/Company';
@@ -8,7 +9,6 @@ import DbParams from '../../types/database/DbParams';
import Logging from '../../utils/Logging';
import { ObjectId } from 'mongodb';
import SiteStorage from './SiteStorage';
-import Tenant from '../../types/Tenant';
import Utils from '../../utils/Utils';
const MODULE_NAME = 'CompanyStorage';
@@ -61,7 +61,7 @@ export default class CompanyStorage {
(coordinate) => Utils.convertToFloat(coordinate)) : [],
};
}
- if (companyToSave.accountData) {
+ if (companyToSave.accountData && Utils.isTenantComponentActive(tenant, TenantComponents.BILLING_PLATFORM)) {
companyMDB.accountData = {
accountID: DatabaseUtils.convertToObjectID(companyToSave.accountData.accountID),
platformFeeStrategy: companyToSave.accountData.platformFeeStrategy,
@@ -190,21 +190,22 @@ export default class CompanyStorage {
DatabaseUtils.pushSiteLookupInAggregation(
{ tenantID: tenant.id, aggregation, localField: '_id', foreignField: 'companyID', asField: 'sites' });
}
- // if (params.withAccount) {
- // With Accounts
+ // Connected account
+ if (Utils.isTenantComponentActive(tenant, TenantComponents.BILLING_PLATFORM)) {
+ // Account data
DatabaseUtils.pushAccountLookupInAggregation({
tenantID: tenant.id, aggregation,
asField: 'accountData.account', localField: 'accountData.accountID',
foreignField: '_id', oneToOneCardinality: true, oneToOneCardinalityNotNull: false
});
- // With Account owner
+ // Business Owner
DatabaseUtils.pushUserLookupInAggregation({
tenantID: tenant.id, aggregation: aggregation,
asField: 'accountData.account.businessOwner',
localField: 'accountData.account.businessOwnerID',
foreignField: '_id', oneToOneCardinality: true, oneToOneCardinalityNotNull: false
});
- // }
+ }
// Company Logo
if (params.withLogo) {
aggregation.push({

bp - company + account data