15records per page
fields: [
{
field: 'nombre de lots principaux',
type: 'Number',
get: place => models.parcels.count({
where: { place_id: place.id },
include: [{
model: models.parcelKinds,
as: 'parcelKind',
where: {
principal: true
}
}]
}).then(result => result)
}, {
field: 'nombre de lots annexes',
type: 'Number',
get: place => models.parcels.count({
where: { place_id: place.id },
include: [{
model: models.parcelKinds,
as: 'parcelKind',
where: {
principal: false
}
}]
}).then(result => result)
}, {
field: 'nombre de stationnements',
type: 'Number',
get: place => models.parcels.count({
where: { place_id: place.id },
include: [{
model: models.parcelKinds,
as: 'parcelKind',
where: {
kind: 'Parking',
principal: false
}
}]
}).then(result => result)
}, {
field: 'nombre de garages',
type: 'Number',
get: place => models.parcels.count({
where: { place_id: place.id },
include: [{
model: models.parcelKinds,
as: 'parcelKind',
where: {
kind: 'Garage',
principal: false
}
}]
}).then(result => result)
}, {
field: 'nombre de box/local',
type: 'Number',
get: place => models.parcels.count({
where: { place_id: place.id },
include: [{
model: models.parcelKinds,
as: 'parcelKind',
where: {
kind: 'Local',
principal: false
}
}]
}).then(result => result)
}, {
field: 'nombre de caves',
type: 'Number',
get: place => models.parcels.count({
where: { place_id: place.id },
include: [{
model: models.parcelKinds,
as: 'parcelKind',
where: {
kind: 'Cave',
principal: false
}
}]
}).then(result => result)
}, {
field: 'nombre de batiments',
type: 'Number',
get: place => models.buildings.count(
{ where: { place_id: place.id } }
).then(result => result
)
},
{
field: 'Date de debut de mandat de syndic',
type: 'Date'/*,
get: place => models.managementMandates.findAll({
where: { place_id: place.id }
}).then(managementMandates => {
const today = moment();
const currentMandate = managementMandates.find(managementMandate => moment(managementMandate.startDate) < today && moment(managementMandate.endDate) >= today);
return currentMandate ? currentMandate.startDate : null;
})*/
}, {
field: 'Date de fin de mandat previsionnel',
type: 'Date'/*,
get: place => models.managementMandates.findAll({
where: { place_id: place.id }
}).then(managementMandates => {
const today = moment();
const currentMandate = managementMandates.find(managementMandate => moment(managementMandate.startDate) < today && moment(managementMandate.endDate) >= today);
return currentMandate ? currentMandate.endDate : null;
})*/
}, {
field: 'Honoraires annuels TTC',
type: 'Number'/*,
get: place => models.managementMandates.findAll({
where: { place_id: place.id }
}).then(managementMandates => {
const today = moment();
const currentMandate = managementMandates.find(managementMandate => moment(managementMandate.startDate) < today && moment(managementMandate.endDate) >= today);
return currentMandate ? currentMandate.annualFees : null;
})*/
}, {
field: 'adresse',
type: 'String',
get: place => models.addresses.findOne({
where: {
addressable_id: place.id,
addressable_type: 'Place'
}
}).then(address =>
address && address.street ? `${address.streetNumber ? address.streetNumber : ''} ${address.street} ${address.complementary ? address.complementary : ''} ${address.zipCode} ${address.city.toUpperCase()} ` : ''),
search: async (query, search) => {
const { QueryTypes, Op } = models.objectMapping;
const split = search.split(' ');
// NOTICE: complexe raw query to gather all ids from the places collection that match your business needs
const placesIds = await models.connections.default.query(`
SELECT places.id FROM places
INNER JOIN addresses ON places.id = addresses.addressable_id
WHERE addresses.addressable_type = 'Place'
AND (addresses.street ILIKE '%${split[0]}%'
OR addresses.zip_code ILIKE '%${split[0]}%'
OR addresses.city ILIKE '%${split[0]}%'
OR addresses.street ILIKE '%${split[1]}%'
OR addresses.zip_code ILIKE '%${split[1]}%'
OR addresses.city ILIKE '%${split[1]}%'
)`,
{ type: QueryTypes.SELECT });
// NOTICE: fill the where condition with a simple `id in (ArrayOfIds)` to match ids returned by the complexe query making the polymorphic joins
const searchCondition = { id: { [Op.in]: placesIds.map(a => a.id) } };
query.where[Op.and][0][Op.or].push(searchCondition);
}
}, {
field: 'pre-etats-dates',
type: ['String'],
reference: 'preEtatDateRequests.id'
}, {
field: 'fournisseurs',
type: ['String'],
reference: 'sageProviders.matricule'
}, {
field: 'attestation',
type: 'File'
}, {
field: 'ficheSynthetique',
type: 'File'
}, {
field: 'nom du mandataire',
type: 'String'/*,
get: place => models.propertyRepresentatives.findOne({
where: { place_id: place.id },
order: [['created_at', 'DESC']],
}).then(propertyRepresentative => propertyRepresentative ? propertyRepresentative.fullName : '')*/
}, {
field: 'date de nomination',
type: 'Date'/*,
get: place => models.propertyRepresentatives.findOne({
where: { place_id: place.id },
order: [['created_at', 'DESC']],
}).then(propertyRepresentative => propertyRepresentative ? propertyRepresentative.nominationDate : null)*/
}, {
field: 'date fin de mission mandataire',
type: 'Date'/*,
get: place => models.propertyRepresentatives.findOne({
where: { place_id: place.id },
order: [['created_at', 'DESC']],
}).then(propertyRepresentative => propertyRepresentative ? propertyRepresentative.missionEndsAt : null)*/
}, {
field: 'categories',
type: ['String'],
reference: 'categories.id'
}, {
field: 'collaborateurs',
type: ['String'],
reference: 'roles.id'
}, {
field: 'images',
type: ['String'],
reference: 'attachmentables.id'
}, {
field: 'factures-a-payer',
type: ['String'],
reference: 'place-bills-to-pay.id'
}, {
field: 'factures-payees',
type: ['String'],
reference: 'place-bills-paid.id'
}, {
field: 'fond de travaux disponible',
type: 'Number'
}, {
field: 'tresorerie actuelle',
type: 'Number'
}, {
field: 'depenses',
type: 'Number'
}, {
field: 'total factures a payer',
type: 'Number'
}, {
field: 'budget vote',
type: 'Number'
}, {
field: 'avance de tresorerie',
type: 'Number'
// en cours de modification cote Parthena
}, {
field: 'fonds prevoyance',
type: 'Number'
}, {
field: 'title',
type: 'String',
get: place => `${place.sergicIdFull} - ${place.displayName}`,
search: (query, search) => {
const split = search.split(' ');
const searchCondition = {
[Op.or]: [
{ 'sergic_id_full': { [Op.iLike]: `%${split[0]}%` } },
{ 'sergic_id_full': { [Op.iLike]: `%${split[1]}%` } },
{ 'display_name': { [Op.iLike]: `%${split[0]}%` } },
{ 'display_name': { [Op.iLike]: `%${split[1]}%` } },
],
};
query.where[Op.and][0][Op.or].push(searchCondition);
return query;
}
}, {
field: 'tickets',
type: ['String'],
reference: 'placeTickets.id'
}, {
field: 'alertes-assurances-impayees',
type: ['String'],
reference: 'placeAlerts.id'
}, {
field: 'alertes-tresorerie-insuffisante',
type: ['String'],
reference: 'placeAlerts.id'
}, {
field: 'alertes-rapprochements-bancaires',
type: ['String'],
reference: 'placeAlerts.id'
}, {
field: 'coproprietaires-en-impayes',
type: ['String'],
reference: 'alerts.id'
}, {
field: 'gestionnaire',
type: 'String',
get: place => models.roles.findOne({
where: {
name: 'coowner_manager',
resource_type: 'Place',
resource_id: place.id
},
include: [{
model: models.identities,
as: 'identitiesThroughIdentitiesRoles'
}]
}).then(role => `${role ? role.identitiesThroughIdentitiesRoles[0].firstName : ''} ${role ? role.identitiesThroughIdentitiesRoles[0].lastName.toUpperCase() : ''}`),
search: async (query, search) => {
const { QueryTypes, Op } = models.objectMapping;
const split = search.split(' ');
// NOTICE: complexe raw query to gather all ids from the places collection that match your business needs
const placesIds = await models.connections.default.query(`
SELECT places.id FROM places
INNER JOIN roles ON places.id = roles.resource_id
INNER JOIN identities_roles ON identities_roles.role_id = roles.id
INNER JOIN identities ON identities.id = identities_roles.identity_id
WHERE roles.name = 'coowner_manager'
AND roles.resource_type = 'Place'
AND (identities.first_name ILIKE '%${split[0]}%'
OR identities.last_name ILIKE '%${split[0]}%'
OR identities.first_name ILIKE '%${split[1]}%'
OR identities.last_name ILIKE '%${split[1]}%')`,
{ type: QueryTypes.SELECT });
// NOTICE: fill the where condition with a simple `id in (ArrayOfIds)` to match ids returned by the complexe query making the polymorphic joins
const searchCondition = { id: { [Op.in]: placesIds.map(a => a.id) } };
query.where[Op.and][0][Op.or].push(searchCondition);
}
}, {
field: 'assistant copro',
type: 'String',
get: place => models.roles.findOne({
where: {
name: 'coowner_assistant',
resource_type: 'Place',
resource_id: place.id
},
include: [{
model: models.identities,
as: 'identitiesThroughIdentitiesRoles'
}]
}).then(role =>
`${role ? role.identitiesThroughIdentitiesRoles[0].firstName : ''} ${role ? role.identitiesThroughIdentitiesRoles[0].lastName.toUpperCase() : ''}`),
search: async (query, search) => {
const { QueryTypes, Op } = models.objectMapping;
const split = search.split(' ');
// NOTICE: complexe raw query to gather all ids from the places collection that match your business needs
const placesIds = await models.connections.default.query(`
SELECT places.id FROM places
INNER JOIN roles ON places.id = roles.resource_id
INNER JOIN identities_roles ON identities_roles.role_id = roles.id
INNER JOIN identities ON identities.id = identities_roles.identity_id
WHERE roles.name = 'coowner_assistant'
AND roles.resource_type = 'Place'
AND (identities.first_name ILIKE '%${split[0]}%'
OR identities.last_name ILIKE '%${split[0]}%'
OR identities.first_name ILIKE '%${split[1]}%'
OR identities.last_name ILIKE '%${split[1]}%')`,
{ type: QueryTypes.SELECT });
// NOTICE: fill the where condition with a simple `id in (ArrayOfIds)` to match ids returned by the complexe query making the polymorphic joins
const searchCondition = { id: { [Op.in]: placesIds.map(a => a.id) } };
query.where[Op.and][0][Op.or].push(searchCondition);
}
},```