I can create a new organisation
var root = db.getSiblingDB('adb-persons').getCollection('organization').findOne({ "legacyId": "000000000000000000000000" });
var newOrgId = new ObjectId();
var orgName = 'Immo-Sandbox'
// Agency setup
var agency = {};
agency._id = newOrgId;
agency.type = "PersonCompany";
agency.name = orgName;
// Org setup
var org = {};
org._id = newOrgId;
org.agency = agency;
org.alias = orgName;
org.organisationId = root._id.valueOf();
org._class = 'fr.lifeconnect.adb.person.model.entity.OrganizationEntity';
db.getSiblingDB('adb-persons').getCollection('organization').insertOne(org);
// Complete agency for person creation
agency.organisationId = newOrgId.valueOf();
agency.corporateName = orgName;
agency.timeZone = 'Europe/Paris';
agency.contactCategories = ["CONTACT_CATEGORY.ORGANIZATION"];
agency._class = 'fr.lifeconnect.adb.person.model.entity.PersonEntity';
db.getSiblingDB('adb-persons').getCollection('persons').insertOne(agency);
I can provision fiscal year
var organisationId = '674724e5ed73d37a1d296783';
var year = 2024;
db.getSiblingDB('adb-accounting').getCollection('fiscal_year').insertOne({
"fiscalYear": year,
"organisationId": organisationId,
"activity": "ACTIVITY.PROPERTY_MANAGEMENT",
"target": {
"targetId": ObjectId(organisationId),
"targetType": "Organization"
},
"beginDate": ISODate((year - 1) + "-12-31T23:00:00.000+01:00"),
"endDate": ISODate(year + "-12-30T23:00:00.000+01:00"),
"periods": Array.from({ length: 12 }, (_, i) => ({
"period": year + "-" + String(i + 1).padStart(2, '0'),
"open": true,
"_class": "fr.lifeconnect.adb.accounting.model.entity.FiscalYearPeriodEntity"
})),
"_class": "fr.lifeconnect.adb.accounting.model.entity.FiscalYearEntity",
"open": true
});
I can provision fiscal year for all organisations
const createIfNotExists = 2025;
db.getSiblingDB('adb-persons')
.getCollection('organization').find({ "legacyId": { "$ne": "000000000000000000000000" } })
.forEach(org => {
// Define the fiscal year collection
const fiscalYearCollection = db.getSiblingDB('adb-accounting').getCollection('fiscal_year');
const orgId = org._id.valueOf();
const existingFY = fiscalYearCollection.findOne({
fiscalYear: createIfNotExists,
organisationId: orgId
});
if (!existingFY) {
const newFiscalYear = {
fiscalYear: createIfNotExists,
organisationId: org._id.valueOf(),
activity: "ACTIVITY.PROPERTY_MANAGEMENT",
target: {
targetId: org._id,
targetType: "Organization"
},
beginDate: new Date(`${createIfNotExists - 1}-12-31T23:00:00.000+01:00`),
endDate: new Date(`${createIfNotExists}-12-30T23:00:00.000+01:00`),
periods: Array.from({ length: 12 }, (_, i) => ({
period: `${createIfNotExists}-${String(i + 1).padStart(2, '0')}`,
open: true,
_class: "fr.lifeconnect.adb.accounting.model.entity.FiscalYearPeriodEntity"
})),
_class: "fr.lifeconnect.adb.accounting.model.entity.FiscalYearEntity",
open: true
};
// Insert the fiscal year document into the collection
fiscalYearCollection.insertOne(newFiscalYear);
print(`${createIfNotExists} FY does NOT exists for organization ${orgId}, creating...` + JSON.stringify(newFiscalYear));
} else {
print(`${createIfNotExists} FY already exists for organization ${orgId}, NOT creating...`);
}
});
Add a logo
// TODO: provide script to upload logo