add connected account to site
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -270,8 +270,10 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'autoUserSiteAssignment', 'distanceMeters', 'public', 'createdOn', 'lastChangedOn', 'tariffID',
'address.address1', 'address.address2', 'address.postalCode', 'address.city',
'address.department', 'address.region', 'address.country', 'address.coordinates',
- 'accountData.accountID', 'accountData.platformFeeStrategy.flatFeePerSession', 'accountData.platformFeeStrategy.percentage',
- 'accountData.account.businessOwner'
+ 'accountData.accountID', 'accountData.platformFeeStrategy.flatFeePerSession',
+ 'accountData.platformFeeStrategy.percentage', 'accountData.account.companyName',
+ 'accountData.account.businessOwner.id', 'accountData.account.businessOwner.email',
+ 'accountData.account.businessOwner.firstName', 'accountData.account.businessOwner.name'
]
},
{

MODIFY
src/storage/mongodb/SiteStorage.ts
src/storage/mongodb/SiteStorage.ts
+import Tenant, { TenantComponents } from '../../types/Tenant';
import global, { DatabaseCount, FilterParams, Image } from '../../types/GlobalType';
import AssetStorage from './AssetStorage';
@@ -10,7 +11,6 @@ import Logging from '../../utils/Logging';
import { ObjectId } from 'mongodb';
import Site from '../../types/Site';
import SiteAreaStorage from './SiteAreaStorage';
-import Tenant from '../../types/Tenant';
import TransactionStorage from './TransactionStorage';
import { UserSite } from '../../types/User';
import Utils from '../../utils/Utils';
@@ -462,6 +462,22 @@ export default class SiteStorage {
}
});
}
+ // 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
+ });
+ // Business Owner
+ DatabaseUtils.pushUserLookupInAggregation({
+ tenantID: tenant.id, aggregation: aggregation,
+ asField: 'accountData.account.businessOwner',
+ localField: 'accountData.account.businessOwnerID',
+ foreignField: '_id', oneToOneCardinality: true, oneToOneCardinalityNotNull: false
+ });
+ }
// Convert Object ID to string
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'companyID');
// Add Last Changed / Created

add connected account to site