Compare commits

..

5 Commits

Author SHA1 Message Date
Flatlogic Bot
bde727ced3 Nimona 2025-07-09 18:58:33 +00:00
Flatlogic Bot
53f8266cef Updated via schema editor on 2025-07-09 18:54 2025-07-09 18:55:47 +00:00
Flatlogic Bot
5dab74c8fc Updated via schema editor on 2025-07-09 18:08 2025-07-09 18:09:52 +00:00
Flatlogic Bot
dd29c9c1fa Revert to version bd3620b 2025-07-09 18:09:43 +00:00
Flatlogic Bot
b40e80b9b2 Auto commit: 2025-07-09T17:32:45.302Z 2025-07-09 17:32:45 +00:00
60 changed files with 2245 additions and 1403 deletions

File diff suppressed because one or more lines are too long

View File

@ -15,16 +15,15 @@ module.exports = class DocumentsDBApi {
{ {
id: data.id || undefined, id: data.id || undefined,
nameofemployee_organization: data.nameofemployee_organization || null,
document_number: data.document_number || null, document_number: data.document_number || null,
document_type: data.document_type || null, description: data.description || null,
prepared_by: data.prepared_by || null, date: data.date || null,
status: data.status || null, payment_type: data.payment_type || null,
cash_balance: data.cash_balance || false, Amount: data.Amount || null,
project_code: data.project_code || null,
payment_date: data.payment_date || null, document_status: data.document_status || null,
amount: data.amount || null,
shelf_number: data.shelf_number || null, shelf_number: data.shelf_number || null,
approved_by: data.approved_by || null,
importHash: data.importHash || null, importHash: data.importHash || null,
createdById: currentUser.id, createdById: currentUser.id,
updatedById: currentUser.id, updatedById: currentUser.id,
@ -32,10 +31,6 @@ module.exports = class DocumentsDBApi {
{ transaction }, { transaction },
); );
await documents.setProject(data.project || null, {
transaction,
});
await documents.setOrganizations(data.organizations || null, { await documents.setOrganizations(data.organizations || null, {
transaction, transaction,
}); });
@ -51,16 +46,15 @@ module.exports = class DocumentsDBApi {
const documentsData = data.map((item, index) => ({ const documentsData = data.map((item, index) => ({
id: item.id || undefined, id: item.id || undefined,
nameofemployee_organization: item.nameofemployee_organization || null,
document_number: item.document_number || null, document_number: item.document_number || null,
document_type: item.document_type || null, description: item.description || null,
prepared_by: item.prepared_by || null, date: item.date || null,
status: item.status || null, payment_type: item.payment_type || null,
cash_balance: item.cash_balance || false, Amount: item.Amount || null,
project_code: item.project_code || null,
payment_date: item.payment_date || null, document_status: item.document_status || null,
amount: item.amount || null,
shelf_number: item.shelf_number || null, shelf_number: item.shelf_number || null,
approved_by: item.approved_by || null,
importHash: item.importHash || null, importHash: item.importHash || null,
createdById: currentUser.id, createdById: currentUser.id,
updatedById: currentUser.id, updatedById: currentUser.id,
@ -86,43 +80,36 @@ module.exports = class DocumentsDBApi {
const updatePayload = {}; const updatePayload = {};
if (data.nameofemployee_organization !== undefined)
updatePayload.nameofemployee_organization =
data.nameofemployee_organization;
if (data.document_number !== undefined) if (data.document_number !== undefined)
updatePayload.document_number = data.document_number; updatePayload.document_number = data.document_number;
if (data.document_type !== undefined) if (data.description !== undefined)
updatePayload.document_type = data.document_type; updatePayload.description = data.description;
if (data.prepared_by !== undefined) if (data.date !== undefined) updatePayload.date = data.date;
updatePayload.prepared_by = data.prepared_by;
if (data.status !== undefined) updatePayload.status = data.status; if (data.payment_type !== undefined)
updatePayload.payment_type = data.payment_type;
if (data.cash_balance !== undefined) if (data.Amount !== undefined) updatePayload.Amount = data.Amount;
updatePayload.cash_balance = data.cash_balance;
if (data.payment_date !== undefined) if (data.project_code !== undefined)
updatePayload.payment_date = data.payment_date; updatePayload.project_code = data.project_code;
if (data.amount !== undefined) updatePayload.amount = data.amount; if (data.document_status !== undefined)
updatePayload.document_status = data.document_status;
if (data.shelf_number !== undefined) if (data.shelf_number !== undefined)
updatePayload.shelf_number = data.shelf_number; updatePayload.shelf_number = data.shelf_number;
if (data.approved_by !== undefined)
updatePayload.approved_by = data.approved_by;
updatePayload.updatedById = currentUser.id; updatePayload.updatedById = currentUser.id;
await documents.update(updatePayload, { transaction }); await documents.update(updatePayload, { transaction });
if (data.project !== undefined) {
await documents.setProject(
data.project,
{ transaction },
);
}
if (data.organizations !== undefined) { if (data.organizations !== undefined) {
await documents.setOrganizations( await documents.setOrganizations(
data.organizations, data.organizations,
@ -196,10 +183,6 @@ module.exports = class DocumentsDBApi {
transaction, transaction,
}); });
output.project = await documents.getProject({
transaction,
});
output.organizations = await documents.getOrganizations({ output.organizations = await documents.getOrganizations({
transaction, transaction,
}); });
@ -229,32 +212,6 @@ module.exports = class DocumentsDBApi {
const transaction = (options && options.transaction) || undefined; const transaction = (options && options.transaction) || undefined;
let include = [ let include = [
{
model: db.projects,
as: 'project',
where: filter.project
? {
[Op.or]: [
{
id: {
[Op.in]: filter.project
.split('|')
.map((term) => Utils.uuid(term)),
},
},
{
name: {
[Op.or]: filter.project
.split('|')
.map((term) => ({ [Op.iLike]: `%${term}%` })),
},
},
],
}
: {},
},
{ {
model: db.organizations, model: db.organizations,
as: 'organizations', as: 'organizations',
@ -269,6 +226,17 @@ module.exports = class DocumentsDBApi {
}; };
} }
if (filter.nameofemployee_organization) {
where = {
...where,
[Op.and]: Utils.ilike(
'documents',
'nameofemployee_organization',
filter.nameofemployee_organization,
),
};
}
if (filter.document_number) { if (filter.document_number) {
where = { where = {
...where, ...where,
@ -280,10 +248,21 @@ module.exports = class DocumentsDBApi {
}; };
} }
if (filter.prepared_by) { if (filter.description) {
where = { where = {
...where, ...where,
[Op.and]: Utils.ilike('documents', 'prepared_by', filter.prepared_by), [Op.and]: Utils.ilike('documents', 'description', filter.description),
};
}
if (filter.project_code) {
where = {
...where,
[Op.and]: Utils.ilike(
'documents',
'project_code',
filter.project_code,
),
}; };
} }
@ -298,21 +277,14 @@ module.exports = class DocumentsDBApi {
}; };
} }
if (filter.approved_by) { if (filter.dateRange) {
where = { const [start, end] = filter.dateRange;
...where,
[Op.and]: Utils.ilike('documents', 'approved_by', filter.approved_by),
};
}
if (filter.payment_dateRange) {
const [start, end] = filter.payment_dateRange;
if (start !== undefined && start !== null && start !== '') { if (start !== undefined && start !== null && start !== '') {
where = { where = {
...where, ...where,
payment_date: { date: {
...where.payment_date, ...where.date,
[Op.gte]: start, [Op.gte]: start,
}, },
}; };
@ -321,22 +293,22 @@ module.exports = class DocumentsDBApi {
if (end !== undefined && end !== null && end !== '') { if (end !== undefined && end !== null && end !== '') {
where = { where = {
...where, ...where,
payment_date: { date: {
...where.payment_date, ...where.date,
[Op.lte]: end, [Op.lte]: end,
}, },
}; };
} }
} }
if (filter.amountRange) { if (filter.AmountRange) {
const [start, end] = filter.amountRange; const [start, end] = filter.AmountRange;
if (start !== undefined && start !== null && start !== '') { if (start !== undefined && start !== null && start !== '') {
where = { where = {
...where, ...where,
amount: { Amount: {
...where.amount, ...where.Amount,
[Op.gte]: start, [Op.gte]: start,
}, },
}; };
@ -345,8 +317,8 @@ module.exports = class DocumentsDBApi {
if (end !== undefined && end !== null && end !== '') { if (end !== undefined && end !== null && end !== '') {
where = { where = {
...where, ...where,
amount: { Amount: {
...where.amount, ...where.Amount,
[Op.lte]: end, [Op.lte]: end,
}, },
}; };
@ -360,24 +332,17 @@ module.exports = class DocumentsDBApi {
}; };
} }
if (filter.document_type) { if (filter.payment_type) {
where = { where = {
...where, ...where,
document_type: filter.document_type, payment_type: filter.payment_type,
}; };
} }
if (filter.status) { if (filter.document_status) {
where = { where = {
...where, ...where,
status: filter.status, document_status: filter.document_status,
};
}
if (filter.cash_balance) {
where = {
...where,
cash_balance: filter.cash_balance,
}; };
} }
@ -468,22 +433,22 @@ module.exports = class DocumentsDBApi {
where = { where = {
[Op.or]: [ [Op.or]: [
{ ['id']: Utils.uuid(query) }, { ['id']: Utils.uuid(query) },
Utils.ilike('documents', 'document_number', query), Utils.ilike('documents', 'id', query),
], ],
}; };
} }
const records = await db.documents.findAll({ const records = await db.documents.findAll({
attributes: ['id', 'document_number'], attributes: ['id', 'id'],
where, where,
limit: limit ? Number(limit) : undefined, limit: limit ? Number(limit) : undefined,
offset: offset ? Number(offset) : undefined, offset: offset ? Number(offset) : undefined,
orderBy: [['document_number', 'ASC']], orderBy: [['id', 'ASC']],
}); });
return records.map((record) => ({ return records.map((record) => ({
id: record.id, id: record.id,
label: record.document_number, label: record.id,
})); }));
} }
}; };

View File

@ -20,6 +20,7 @@ module.exports = class Field_site_payment_requisitionsDBApi {
employee_name: data.employee_name || null, employee_name: data.employee_name || null,
departure_place: data.departure_place || null, departure_place: data.departure_place || null,
departure_date: data.departure_date || null, departure_date: data.departure_date || null,
arrival_place: data.arrival_place || null,
return_date: data.return_date || null, return_date: data.return_date || null,
requisition_date: data.requisition_date || null, requisition_date: data.requisition_date || null,
requested_amount: data.requested_amount || null, requested_amount: data.requested_amount || null,
@ -68,6 +69,7 @@ module.exports = class Field_site_payment_requisitionsDBApi {
employee_name: item.employee_name || null, employee_name: item.employee_name || null,
departure_place: item.departure_place || null, departure_place: item.departure_place || null,
departure_date: item.departure_date || null, departure_date: item.departure_date || null,
arrival_place: item.arrival_place || null,
return_date: item.return_date || null, return_date: item.return_date || null,
requisition_date: item.requisition_date || null, requisition_date: item.requisition_date || null,
requested_amount: item.requested_amount || null, requested_amount: item.requested_amount || null,
@ -120,6 +122,9 @@ module.exports = class Field_site_payment_requisitionsDBApi {
if (data.departure_date !== undefined) if (data.departure_date !== undefined)
updatePayload.departure_date = data.departure_date; updatePayload.departure_date = data.departure_date;
if (data.arrival_place !== undefined)
updatePayload.arrival_place = data.arrival_place;
if (data.return_date !== undefined) if (data.return_date !== undefined)
updatePayload.return_date = data.return_date; updatePayload.return_date = data.return_date;
@ -354,6 +359,17 @@ module.exports = class Field_site_payment_requisitionsDBApi {
}; };
} }
if (filter.arrival_place) {
where = {
...where,
[Op.and]: Utils.ilike(
'field_site_payment_requisitions',
'arrival_place',
filter.arrival_place,
),
};
}
if (filter.requester) { if (filter.requester) {
where = { where = {
...where, ...where,
@ -616,22 +632,26 @@ module.exports = class Field_site_payment_requisitionsDBApi {
where = { where = {
[Op.or]: [ [Op.or]: [
{ ['id']: Utils.uuid(query) }, { ['id']: Utils.uuid(query) },
Utils.ilike('field_site_payment_requisitions', 'id', query), Utils.ilike(
'field_site_payment_requisitions',
'employee_name',
query,
),
], ],
}; };
} }
const records = await db.field_site_payment_requisitions.findAll({ const records = await db.field_site_payment_requisitions.findAll({
attributes: ['id', 'id'], attributes: ['id', 'employee_name'],
where, where,
limit: limit ? Number(limit) : undefined, limit: limit ? Number(limit) : undefined,
offset: offset ? Number(offset) : undefined, offset: offset ? Number(offset) : undefined,
orderBy: [['id', 'ASC']], orderBy: [['employee_name', 'ASC']],
}); });
return records.map((record) => ({ return records.map((record) => ({
id: record.id, id: record.id,
label: record.id, label: record.employee_name,
})); }));
} }
}; };

View File

@ -169,6 +169,15 @@ module.exports = class OrganizationsDBApi {
transaction, transaction,
}); });
output.departments_organizations =
await organizations.getDepartments_organizations({
transaction,
});
output.places_organizations = await organizations.getPlaces_organizations({
transaction,
});
return output; return output;
} }
@ -295,22 +304,22 @@ module.exports = class OrganizationsDBApi {
where = { where = {
[Op.or]: [ [Op.or]: [
{ ['id']: Utils.uuid(query) }, { ['id']: Utils.uuid(query) },
Utils.ilike('organizations', 'name', query), Utils.ilike('organizations', 'id', query),
], ],
}; };
} }
const records = await db.organizations.findAll({ const records = await db.organizations.findAll({
attributes: ['id', 'name'], attributes: ['id', 'id'],
where, where,
limit: limit ? Number(limit) : undefined, limit: limit ? Number(limit) : undefined,
offset: offset ? Number(offset) : undefined, offset: offset ? Number(offset) : undefined,
orderBy: [['name', 'ASC']], orderBy: [['id', 'ASC']],
}); });
return records.map((record) => ({ return records.map((record) => ({
id: record.id, id: record.id,
label: record.name, label: record.id,
})); }));
} }
}; };

View File

@ -208,7 +208,7 @@ module.exports = class PaymentsDBApi {
}, },
}, },
{ {
document_number: { id: {
[Op.or]: filter.document [Op.or]: filter.document
.split('|') .split('|')
.map((term) => ({ [Op.iLike]: `%${term}%` })), .map((term) => ({ [Op.iLike]: `%${term}%` })),

View File

@ -158,10 +158,6 @@ module.exports = class ProjectsDBApi {
const output = projects.get({ plain: true }); const output = projects.get({ plain: true });
output.documents_project = await projects.getDocuments_project({
transaction,
});
output.field_site_payment_requisitions_project = output.field_site_payment_requisitions_project =
await projects.getField_site_payment_requisitions_project({ await projects.getField_site_payment_requisitions_project({
transaction, transaction,

View File

@ -0,0 +1,65 @@
module.exports = {
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async up(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.addColumn(
'documents',
'nameofemployee_organization',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.renameColumn(
'documents',
'document_number',
'document_numner',
{ transaction },
);
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async down(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.renameColumn(
'documents',
'document_numner',
'document_number',
{ transaction },
);
await queryInterface.removeColumn(
'documents',
'nameofemployee_organization',
{ transaction },
);
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
};

View File

@ -0,0 +1,363 @@
module.exports = {
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async up(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.createTable(
'organizations',
{
id: {
type: Sequelize.DataTypes.UUID,
defaultValue: Sequelize.DataTypes.UUIDV4,
primaryKey: true,
},
createdById: {
type: Sequelize.DataTypes.UUID,
references: {
key: 'id',
model: 'users',
},
},
updatedById: {
type: Sequelize.DataTypes.UUID,
references: {
key: 'id',
model: 'users',
},
},
createdAt: { type: Sequelize.DataTypes.DATE },
updatedAt: { type: Sequelize.DataTypes.DATE },
deletedAt: { type: Sequelize.DataTypes.DATE },
importHash: {
type: Sequelize.DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{ transaction },
);
await queryInterface.addColumn(
'organizations',
'name',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.removeColumn('documents', 'document_numner', {
transaction,
});
await queryInterface.removeColumn('documents', 'projectId', {
transaction,
});
await queryInterface.removeColumn('documents', 'document_type', {
transaction,
});
await queryInterface.removeColumn('documents', 'prepared_by', {
transaction,
});
await queryInterface.removeColumn('documents', 'status', { transaction });
await queryInterface.removeColumn('documents', 'cash_balance', {
transaction,
});
await queryInterface.removeColumn('documents', 'payment_date', {
transaction,
});
await queryInterface.removeColumn('documents', 'amount', { transaction });
await queryInterface.removeColumn('documents', 'shelf_number', {
transaction,
});
await queryInterface.removeColumn('documents', 'approved_by', {
transaction,
});
await queryInterface.addColumn(
'documents',
'document_number',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'description',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'date',
{
type: Sequelize.DataTypes.DATEONLY,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'payment_type',
{
type: Sequelize.DataTypes.ENUM,
values: ['BPV', 'JV', 'RV', 'CPV'],
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'Amount',
{
type: Sequelize.DataTypes.DECIMAL,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'project_code',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'document_status',
{
type: Sequelize.DataTypes.ENUM,
values: ['Approved', 'Complete', 'On progress', 'Filled'],
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'shelf_number',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.dropTable('organizations', { transaction });
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async down(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.removeColumn('documents', 'shelf_number', {
transaction,
});
await queryInterface.removeColumn('documents', 'document_status', {
transaction,
});
await queryInterface.removeColumn('documents', 'project_code', {
transaction,
});
await queryInterface.removeColumn('documents', 'Amount', { transaction });
await queryInterface.removeColumn('documents', 'payment_type', {
transaction,
});
await queryInterface.removeColumn('documents', 'date', { transaction });
await queryInterface.removeColumn('documents', 'description', {
transaction,
});
await queryInterface.removeColumn('documents', 'document_number', {
transaction,
});
await queryInterface.addColumn(
'documents',
'approved_by',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'shelf_number',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'amount',
{
type: Sequelize.DataTypes.DECIMAL,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'payment_date',
{
type: Sequelize.DataTypes.DATE,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'cash_balance',
{
type: Sequelize.DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'status',
{
type: Sequelize.DataTypes.ENUM,
values: ['Filed', 'InProgress'],
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'prepared_by',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'document_type',
{
type: Sequelize.DataTypes.ENUM,
values: ['BPV', 'JV', 'RV'],
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'projectId',
{
type: Sequelize.DataTypes.UUID,
references: {
model: 'projects',
key: 'id',
},
},
{ transaction },
);
await queryInterface.addColumn(
'documents',
'document_numner',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await queryInterface.removeColumn('organizations', 'name', {
transaction,
});
await queryInterface.dropTable('organizations', { transaction });
await queryInterface.createTable(
'organizations',
{
id: {
type: Sequelize.DataTypes.UUID,
defaultValue: Sequelize.DataTypes.UUIDV4,
primaryKey: true,
},
createdById: {
type: Sequelize.DataTypes.UUID,
references: {
key: 'id',
model: 'users',
},
},
updatedById: {
type: Sequelize.DataTypes.UUID,
references: {
key: 'id',
model: 'users',
},
},
createdAt: { type: Sequelize.DataTypes.DATE },
updatedAt: { type: Sequelize.DataTypes.DATE },
deletedAt: { type: Sequelize.DataTypes.DATE },
importHash: {
type: Sequelize.DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{ transaction },
);
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
};

View File

@ -14,46 +14,49 @@ module.exports = function (sequelize, DataTypes) {
primaryKey: true, primaryKey: true,
}, },
nameofemployee_organization: {
type: DataTypes.TEXT,
},
document_number: { document_number: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
}, },
document_type: { description: {
type: DataTypes.ENUM,
values: ['BPV', 'JV', 'RV'],
},
prepared_by: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
}, },
status: { date: {
type: DataTypes.DATEONLY,
get: function () {
return this.getDataValue('date')
? moment.utc(this.getDataValue('date')).format('YYYY-MM-DD')
: null;
},
},
payment_type: {
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: ['Filed', 'InProgress'], values: ['BPV', 'JV', 'RV', 'CPV'],
}, },
cash_balance: { Amount: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
payment_date: {
type: DataTypes.DATE,
},
amount: {
type: DataTypes.DECIMAL, type: DataTypes.DECIMAL,
}, },
shelf_number: { project_code: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
}, },
approved_by: { document_status: {
type: DataTypes.ENUM,
values: ['Approved', 'Complete', 'On progress', 'Filled'],
},
shelf_number: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
}, },
@ -83,14 +86,6 @@ module.exports = function (sequelize, DataTypes) {
//end loop //end loop
db.documents.belongsTo(db.projects, {
as: 'project',
foreignKey: {
name: 'projectId',
},
constraints: false,
});
db.documents.belongsTo(db.organizations, { db.documents.belongsTo(db.organizations, {
as: 'organizations', as: 'organizations',
foreignKey: { foreignKey: {

View File

@ -44,14 +44,6 @@ module.exports = function (sequelize, DataTypes) {
projects.associate = (db) => { projects.associate = (db) => {
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity /// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
db.projects.hasMany(db.documents, {
as: 'documents_project',
foreignKey: {
name: 'projectId',
},
constraints: false,
});
db.projects.hasMany(db.field_site_payment_requisitions, { db.projects.hasMany(db.field_site_payment_requisitions, {
as: 'field_site_payment_requisitions_project', as: 'field_site_payment_requisitions_project',
foreignKey: { foreignKey: {

View File

@ -118,6 +118,8 @@ module.exports = {
'projects', 'projects',
'roles', 'roles',
'permissions', 'permissions',
'departments',
'places',
'organizations', 'organizations',
, ,
]; ];
@ -795,6 +797,56 @@ primary key ("roles_permissionsId", "permissionId")
permissionId: getId('DELETE_PROJECTS'), permissionId: getId('DELETE_PROJECTS'),
}, },
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('CREATE_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('READ_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('UPDATE_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('DELETE_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('CREATE_PLACES'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('READ_PLACES'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('UPDATE_PLACES'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('Administrator'),
permissionId: getId('DELETE_PLACES'),
},
{ {
createdAt, createdAt,
updatedAt, updatedAt,
@ -970,6 +1022,56 @@ primary key ("roles_permissionsId", "permissionId")
permissionId: getId('DELETE_PERMISSIONS'), permissionId: getId('DELETE_PERMISSIONS'),
}, },
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('CREATE_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('READ_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('UPDATE_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('DELETE_DEPARTMENTS'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('CREATE_PLACES'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('READ_PLACES'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('UPDATE_PLACES'),
},
{
createdAt,
updatedAt,
roles_permissionsId: getId('SuperAdmin'),
permissionId: getId('DELETE_PLACES'),
},
{ {
createdAt, createdAt,
updatedAt, updatedAt,

View File

@ -9,131 +9,77 @@ const Payments = db.payments;
const Projects = db.projects; const Projects = db.projects;
const Organizations = db.organizations;
const Departments = db.departments; const Departments = db.departments;
const Places = db.places; const Places = db.places;
const Organizations = db.organizations;
const DocumentsData = [ const DocumentsData = [
{ {
// type code here for "relation_one" field
nameofemployee_organization: 'Sheldon Glashow',
document_number: 'DOC001', document_number: 'DOC001',
// type code here for "relation_one" field description: 'Richard Feynman',
document_type: 'RV', date: new Date(Date.now()),
prepared_by: 'jdoe', payment_type: 'JV',
status: 'InProgress', Amount: 13.65,
cash_balance: true, project_code: 'Noam Chomsky',
payment_date: new Date('2023-10-01T10:00:00Z'), document_status: 'Approved',
amount: 1000,
shelf_number: 'S001', shelf_number: 'S001',
approved_by: 'asmith',
// type code here for "relation_one" field
}, },
{ {
// type code here for "relation_one" field
nameofemployee_organization: 'Jean Piaget',
document_number: 'DOC002', document_number: 'DOC002',
// type code here for "relation_one" field description: 'Trofim Lysenko',
document_type: 'BPV', date: new Date(Date.now()),
prepared_by: 'asmith', payment_type: 'BPV',
status: 'InProgress', Amount: 84.59,
cash_balance: false, project_code: 'Carl Linnaeus',
payment_date: new Date('2023-10-02T11:00:00Z'), document_status: 'Complete',
amount: 2000,
shelf_number: 'S002', shelf_number: 'S002',
approved_by: 'bwhite',
// type code here for "relation_one" field
}, },
{ {
// type code here for "relation_one" field
nameofemployee_organization: 'Charles Sherrington',
document_number: 'DOC003', document_number: 'DOC003',
// type code here for "relation_one" field description: 'Francis Galton',
document_type: 'JV', date: new Date(Date.now()),
prepared_by: 'bwhite', payment_type: 'CPV',
status: 'InProgress', Amount: 16.57,
cash_balance: true, project_code: 'Konrad Lorenz',
payment_date: new Date('2023-10-03T12:00:00Z'), document_status: 'Filled',
amount: 1500,
shelf_number: 'S003', shelf_number: 'S003',
approved_by: 'cgreen',
// type code here for "relation_one" field
},
{
document_number: 'DOC004',
// type code here for "relation_one" field
document_type: 'BPV',
prepared_by: 'cgreen',
status: 'Filed',
cash_balance: true,
payment_date: new Date('2023-10-04T13:00:00Z'),
amount: 2500,
shelf_number: 'S004',
approved_by: 'dblack',
// type code here for "relation_one" field
},
{
document_number: 'DOC005',
// type code here for "relation_one" field
document_type: 'BPV',
prepared_by: 'dblack',
status: 'Filed',
cash_balance: true,
payment_date: new Date('2023-10-05T14:00:00Z'),
amount: 3000,
shelf_number: 'S005',
approved_by: 'jdoe',
// type code here for "relation_one" field
}, },
]; ];
@ -157,7 +103,7 @@ const FieldSitePaymentRequisitionsData = [
requested_amount: 5000, requested_amount: 5000,
payment_type: 'BPV', payment_type: 'RV',
status: 'Paid', status: 'Paid',
@ -223,7 +169,7 @@ const FieldSitePaymentRequisitionsData = [
payment_type: 'BPV', payment_type: 'BPV',
status: 'Pending', status: 'Approved',
requester: 'bwhite', requester: 'bwhite',
@ -233,70 +179,6 @@ const FieldSitePaymentRequisitionsData = [
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{
// type code here for "relation_one" field
department: 'Operations',
employee_name: 'Charlie Green',
// type code here for "relation_one" field
departure_place: 'Houston',
departure_date: new Date('2023-10-04T11:00:00Z'),
return_date: new Date('2023-10-14T21:00:00Z'),
requisition_date: new Date('2023-09-28T12:00:00Z'),
requested_amount: 8000,
payment_type: 'JV',
status: 'Approved',
requester: 'cgreen',
approver: 'dblack',
due_date: new Date('2023-10-18T20:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
department: 'Investments',
employee_name: 'David Black',
// type code here for "relation_one" field
departure_place: 'Miami',
departure_date: new Date('2023-10-05T12:00:00Z'),
return_date: new Date('2023-10-15T22:00:00Z'),
requisition_date: new Date('2023-09-29T13:00:00Z'),
requested_amount: 9000,
payment_type: 'RV',
status: 'Pending',
requester: 'dblack',
approver: 'jdoe',
due_date: new Date('2023-10-19T21:00:00Z'),
// type code here for "relation_one" field
},
]; ];
const PaymentsData = [ const PaymentsData = [
@ -307,7 +189,7 @@ const PaymentsData = [
amount: 500, amount: 500,
payment_type: 'Addition', payment_type: 'Subtraction',
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
@ -331,30 +213,6 @@ const PaymentsData = [
amount: 750, amount: 750,
payment_type: 'Addition',
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
date: new Date('2023-10-04T13:00:00Z'),
amount: 1250,
payment_type: 'Subtraction',
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
date: new Date('2023-10-05T14:00:00Z'),
amount: 1500,
payment_type: 'Subtraction', payment_type: 'Subtraction',
// type code here for "relation_one" field // type code here for "relation_one" field
@ -367,7 +225,7 @@ const ProjectsData = [
code: 'PA001', code: 'PA001',
type: 'CDC', type: 'Other',
// type code here for "relation_one" field // type code here for "relation_one" field
@ -379,7 +237,7 @@ const ProjectsData = [
code: 'PB002', code: 'PB002',
type: 'MOH', type: 'Other',
// type code here for "relation_one" field // type code here for "relation_one" field
@ -397,52 +255,6 @@ const ProjectsData = [
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{
name: 'Project Delta',
code: 'PD004',
type: 'CDC',
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
name: 'Project Epsilon',
code: 'PE005',
type: 'Other',
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const OrganizationsData = [
{
name: 'Global Finance Inc.',
},
{
name: 'Legal Solutions Ltd.',
},
{
name: 'Financial Services Group',
},
{
name: 'Corporate Finance Co.',
},
{
name: 'Investment Partners',
},
]; ];
const DepartmentsData = [ const DepartmentsData = [
@ -457,14 +269,6 @@ const DepartmentsData = [
{ {
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
},
]; ];
const PlacesData = [ const PlacesData = [
@ -479,13 +283,19 @@ const PlacesData = [
{ {
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
];
const OrganizationsData = [
{ {
// type code here for "relation_one" field name: 'Global Finance Inc.',
}, },
{ {
// type code here for "relation_one" field name: 'Legal Solutions Ltd.',
},
{
name: 'Financial Services Group',
}, },
]; ];
@ -524,85 +334,6 @@ async function associateUserWithOrganization() {
if (User2?.setOrganization) { if (User2?.setOrganization) {
await User2.setOrganization(relatedOrganization2); await User2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User3 = await Users.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (User3?.setOrganization) {
await User3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User4 = await Users.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (User4?.setOrganization) {
await User4.setOrganization(relatedOrganization4);
}
}
async function associateDocumentWithProject() {
const relatedProject0 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const Document0 = await Documents.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Document0?.setProject) {
await Document0.setProject(relatedProject0);
}
const relatedProject1 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const Document1 = await Documents.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Document1?.setProject) {
await Document1.setProject(relatedProject1);
}
const relatedProject2 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const Document2 = await Documents.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Document2?.setProject) {
await Document2.setProject(relatedProject2);
}
const relatedProject3 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const Document3 = await Documents.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Document3?.setProject) {
await Document3.setProject(relatedProject3);
}
const relatedProject4 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const Document4 = await Documents.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Document4?.setProject) {
await Document4.setProject(relatedProject4);
}
} }
async function associateDocumentWithOrganization() { async function associateDocumentWithOrganization() {
@ -638,28 +369,6 @@ async function associateDocumentWithOrganization() {
if (Document2?.setOrganization) { if (Document2?.setOrganization) {
await Document2.setOrganization(relatedOrganization2); await Document2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Document3 = await Documents.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Document3?.setOrganization) {
await Document3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Document4 = await Documents.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Document4?.setOrganization) {
await Document4.setOrganization(relatedOrganization4);
}
} }
async function associateFieldSitePaymentRequisitionWithOrganization() { async function associateFieldSitePaymentRequisitionWithOrganization() {
@ -698,30 +407,6 @@ async function associateFieldSitePaymentRequisitionWithOrganization() {
if (FieldSitePaymentRequisition2?.setOrganization) { if (FieldSitePaymentRequisition2?.setOrganization) {
await FieldSitePaymentRequisition2.setOrganization(relatedOrganization2); await FieldSitePaymentRequisition2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const FieldSitePaymentRequisition3 =
await FieldSitePaymentRequisitions.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (FieldSitePaymentRequisition3?.setOrganization) {
await FieldSitePaymentRequisition3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const FieldSitePaymentRequisition4 =
await FieldSitePaymentRequisitions.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (FieldSitePaymentRequisition4?.setOrganization) {
await FieldSitePaymentRequisition4.setOrganization(relatedOrganization4);
}
} }
async function associateFieldSitePaymentRequisitionWithProject() { async function associateFieldSitePaymentRequisitionWithProject() {
@ -760,30 +445,6 @@ async function associateFieldSitePaymentRequisitionWithProject() {
if (FieldSitePaymentRequisition2?.setProject) { if (FieldSitePaymentRequisition2?.setProject) {
await FieldSitePaymentRequisition2.setProject(relatedProject2); await FieldSitePaymentRequisition2.setProject(relatedProject2);
} }
const relatedProject3 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const FieldSitePaymentRequisition3 =
await FieldSitePaymentRequisitions.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (FieldSitePaymentRequisition3?.setProject) {
await FieldSitePaymentRequisition3.setProject(relatedProject3);
}
const relatedProject4 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const FieldSitePaymentRequisition4 =
await FieldSitePaymentRequisitions.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (FieldSitePaymentRequisition4?.setProject) {
await FieldSitePaymentRequisition4.setProject(relatedProject4);
}
} }
async function associateFieldSitePaymentRequisitionWithOrganization() { async function associateFieldSitePaymentRequisitionWithOrganization() {
@ -822,30 +483,6 @@ async function associateFieldSitePaymentRequisitionWithOrganization() {
if (FieldSitePaymentRequisition2?.setOrganization) { if (FieldSitePaymentRequisition2?.setOrganization) {
await FieldSitePaymentRequisition2.setOrganization(relatedOrganization2); await FieldSitePaymentRequisition2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const FieldSitePaymentRequisition3 =
await FieldSitePaymentRequisitions.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (FieldSitePaymentRequisition3?.setOrganization) {
await FieldSitePaymentRequisition3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const FieldSitePaymentRequisition4 =
await FieldSitePaymentRequisitions.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (FieldSitePaymentRequisition4?.setOrganization) {
await FieldSitePaymentRequisition4.setOrganization(relatedOrganization4);
}
} }
async function associatePaymentWithDocument() { async function associatePaymentWithDocument() {
@ -881,28 +518,6 @@ async function associatePaymentWithDocument() {
if (Payment2?.setDocument) { if (Payment2?.setDocument) {
await Payment2.setDocument(relatedDocument2); await Payment2.setDocument(relatedDocument2);
} }
const relatedDocument3 = await Documents.findOne({
offset: Math.floor(Math.random() * (await Documents.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Payment3?.setDocument) {
await Payment3.setDocument(relatedDocument3);
}
const relatedDocument4 = await Documents.findOne({
offset: Math.floor(Math.random() * (await Documents.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Payment4?.setDocument) {
await Payment4.setDocument(relatedDocument4);
}
} }
async function associatePaymentWithOrganization() { async function associatePaymentWithOrganization() {
@ -938,28 +553,6 @@ async function associatePaymentWithOrganization() {
if (Payment2?.setOrganization) { if (Payment2?.setOrganization) {
await Payment2.setOrganization(relatedOrganization2); await Payment2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Payment3?.setOrganization) {
await Payment3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Payment4?.setOrganization) {
await Payment4.setOrganization(relatedOrganization4);
}
} }
async function associateProjectWithOrganization() { async function associateProjectWithOrganization() {
@ -995,28 +588,6 @@ async function associateProjectWithOrganization() {
if (Project2?.setOrganization) { if (Project2?.setOrganization) {
await Project2.setOrganization(relatedOrganization2); await Project2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Project3 = await Projects.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Project3?.setOrganization) {
await Project3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Project4 = await Projects.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Project4?.setOrganization) {
await Project4.setOrganization(relatedOrganization4);
}
} }
async function associateProjectWithOrganization() { async function associateProjectWithOrganization() {
@ -1052,28 +623,6 @@ async function associateProjectWithOrganization() {
if (Project2?.setOrganization) { if (Project2?.setOrganization) {
await Project2.setOrganization(relatedOrganization2); await Project2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Project3 = await Projects.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Project3?.setOrganization) {
await Project3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Project4 = await Projects.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Project4?.setOrganization) {
await Project4.setOrganization(relatedOrganization4);
}
} }
async function associateDepartmentWithOrganization() { async function associateDepartmentWithOrganization() {
@ -1109,28 +658,6 @@ async function associateDepartmentWithOrganization() {
if (Department2?.setOrganization) { if (Department2?.setOrganization) {
await Department2.setOrganization(relatedOrganization2); await Department2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Department3 = await Departments.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Department3?.setOrganization) {
await Department3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Department4 = await Departments.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Department4?.setOrganization) {
await Department4.setOrganization(relatedOrganization4);
}
} }
async function associatePlaceWithOrganization() { async function associatePlaceWithOrganization() {
@ -1166,28 +693,6 @@ async function associatePlaceWithOrganization() {
if (Place2?.setOrganization) { if (Place2?.setOrganization) {
await Place2.setOrganization(relatedOrganization2); await Place2.setOrganization(relatedOrganization2);
} }
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Place3 = await Places.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Place3?.setOrganization) {
await Place3.setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Place4 = await Places.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Place4?.setOrganization) {
await Place4.setOrganization(relatedOrganization4);
}
} }
module.exports = { module.exports = {
@ -1202,19 +707,17 @@ module.exports = {
await Projects.bulkCreate(ProjectsData); await Projects.bulkCreate(ProjectsData);
await Organizations.bulkCreate(OrganizationsData);
await Departments.bulkCreate(DepartmentsData); await Departments.bulkCreate(DepartmentsData);
await Places.bulkCreate(PlacesData); await Places.bulkCreate(PlacesData);
await Organizations.bulkCreate(OrganizationsData);
await Promise.all([ await Promise.all([
// Similar logic for "relation_many" // Similar logic for "relation_many"
await associateUserWithOrganization(), await associateUserWithOrganization(),
await associateDocumentWithProject(),
await associateDocumentWithOrganization(), await associateDocumentWithOrganization(),
await associateFieldSitePaymentRequisitionWithOrganization(), await associateFieldSitePaymentRequisitionWithOrganization(),
@ -1250,10 +753,10 @@ module.exports = {
await queryInterface.bulkDelete('projects', null, {}); await queryInterface.bulkDelete('projects', null, {});
await queryInterface.bulkDelete('organizations', null, {});
await queryInterface.bulkDelete('departments', null, {}); await queryInterface.bulkDelete('departments', null, {});
await queryInterface.bulkDelete('places', null, {}); await queryInterface.bulkDelete('places', null, {});
await queryInterface.bulkDelete('organizations', null, {});
}, },
}; };

View File

@ -0,0 +1,87 @@
const { v4: uuid } = require('uuid');
const db = require('../models');
const Sequelize = require('sequelize');
const config = require('../../config');
module.exports = {
/**
* @param{import("sequelize").QueryInterface} queryInterface
* @return {Promise<void>}
*/
async up(queryInterface) {
const createdAt = new Date();
const updatedAt = new Date();
/** @type {Map<string, string>} */
const idMap = new Map();
/**
* @param {string} key
* @return {string}
*/
function getId(key) {
if (idMap.has(key)) {
return idMap.get(key);
}
const id = uuid();
idMap.set(key, id);
return id;
}
/**
* @param {string} name
*/
function createPermissions(name) {
return [
{
id: getId(`CREATE_${name.toUpperCase()}`),
createdAt,
updatedAt,
name: `CREATE_${name.toUpperCase()}`,
},
{
id: getId(`READ_${name.toUpperCase()}`),
createdAt,
updatedAt,
name: `READ_${name.toUpperCase()}`,
},
{
id: getId(`UPDATE_${name.toUpperCase()}`),
createdAt,
updatedAt,
name: `UPDATE_${name.toUpperCase()}`,
},
{
id: getId(`DELETE_${name.toUpperCase()}`),
createdAt,
updatedAt,
name: `DELETE_${name.toUpperCase()}`,
},
];
}
const entities = ['organizations'];
const createdPermissions = entities.flatMap(createPermissions);
// Add permissions to database
await queryInterface.bulkInsert('permissions', createdPermissions);
// Get permissions ids
const permissionsIds = createdPermissions.map((p) => p.id);
// Get admin role
const adminRole = await db.roles.findOne({
where: { name: config.roles.super_admin },
});
if (adminRole) {
// Add permissions to admin role if it exists
await adminRole.addPermissions(permissionsIds);
}
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete(
'permissions',
entities.flatMap(createPermissions),
);
},
};

View File

@ -35,6 +35,10 @@ const rolesRoutes = require('./routes/roles');
const permissionsRoutes = require('./routes/permissions'); const permissionsRoutes = require('./routes/permissions');
const departmentsRoutes = require('./routes/departments');
const placesRoutes = require('./routes/places');
const organizationsRoutes = require('./routes/organizations'); const organizationsRoutes = require('./routes/organizations');
const getBaseUrl = (url) => { const getBaseUrl = (url) => {
@ -144,6 +148,18 @@ app.use(
permissionsRoutes, permissionsRoutes,
); );
app.use(
'/api/departments',
passport.authenticate('jwt', { session: false }),
departmentsRoutes,
);
app.use(
'/api/places',
passport.authenticate('jwt', { session: false }),
placesRoutes,
);
app.use( app.use(
'/api/organizations', '/api/organizations',
passport.authenticate('jwt', { session: false }), passport.authenticate('jwt', { session: false }),

View File

@ -22,20 +22,23 @@ router.use(checkCrudPermissions('documents'));
* type: object * type: object
* properties: * properties:
* nameofemployee_organization:
* type: string
* default: nameofemployee_organization
* document_number: * document_number:
* type: string * type: string
* default: document_number * default: document_number
* prepared_by: * description:
* type: string * type: string
* default: prepared_by * default: description
* project_code:
* type: string
* default: project_code
* shelf_number: * shelf_number:
* type: string * type: string
* default: shelf_number * default: shelf_number
* approved_by:
* type: string
* default: approved_by
* amount: * Amount:
* type: integer * type: integer
* format: int64 * format: int64
@ -327,13 +330,15 @@ router.get(
if (filetype && filetype === 'csv') { if (filetype && filetype === 'csv') {
const fields = [ const fields = [
'id', 'id',
'nameofemployee_organization',
'document_number', 'document_number',
'prepared_by', 'description',
'project_code',
'shelf_number', 'shelf_number',
'approved_by',
'amount', 'Amount',
'payment_date',
'date',
]; ];
const opts = { fields }; const opts = { fields };
try { try {

View File

@ -44,13 +44,15 @@ module.exports = class SearchService {
users: ['firstName', 'lastName', 'phoneNumber', 'email'], users: ['firstName', 'lastName', 'phoneNumber', 'email'],
documents: [ documents: [
'nameofemployee_organization',
'document_number', 'document_number',
'prepared_by', 'description',
'project_code',
'shelf_number', 'shelf_number',
'approved_by',
], ],
field_site_payment_requisitions: [ field_site_payment_requisitions: [
@ -60,8 +62,6 @@ module.exports = class SearchService {
'departure_place', 'departure_place',
'arrival_place',
'requester', 'requester',
'approver', 'approver',
@ -72,7 +72,7 @@ module.exports = class SearchService {
organizations: ['name'], organizations: ['name'],
}; };
const columnsInt = { const columnsInt = {
documents: ['amount'], documents: ['Amount'],
field_site_payment_requisitions: ['requested_amount'], field_site_payment_requisitions: ['requested_amount'],

View File

@ -62,7 +62,7 @@ const CardDocuments = ({
href={`/documents/documents-view/?id=${item.id}`} href={`/documents/documents-view/?id=${item.id}`}
className='text-lg font-bold leading-6 line-clamp-1' className='text-lg font-bold leading-6 line-clamp-1'
> >
{item.document_number} {item.id}
</Link> </Link>
<div className='ml-auto '> <div className='ml-auto '>
@ -78,7 +78,31 @@ const CardDocuments = ({
<dl className='divide-y divide-stone-300 dark:divide-dark-700 px-6 py-4 text-sm leading-6 h-64 overflow-y-auto'> <dl className='divide-y divide-stone-300 dark:divide-dark-700 px-6 py-4 text-sm leading-6 h-64 overflow-y-auto'>
<div className='flex justify-between gap-x-4 py-3'> <div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'> <dt className=' text-gray-500 dark:text-dark-600'>
DocumentNumber organizations
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{dataFormatter.organizationsOneListFormatter(
item.organizations,
)}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
Nameofemployee Organization
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.nameofemployee_organization}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
Document Number
</dt> </dt>
<dd className='flex items-start gap-x-2'> <dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'> <div className='font-medium line-clamp-4'>
@ -89,66 +113,31 @@ const CardDocuments = ({
<div className='flex justify-between gap-x-4 py-3'> <div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'> <dt className=' text-gray-500 dark:text-dark-600'>
Project Description
</dt> </dt>
<dd className='flex items-start gap-x-2'> <dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'> <div className='font-medium line-clamp-4'>
{dataFormatter.projectsOneListFormatter(item.project)} {item.description}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>Date</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{dataFormatter.dateFormatter(item.date)}
</div> </div>
</dd> </dd>
</div> </div>
<div className='flex justify-between gap-x-4 py-3'> <div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'> <dt className=' text-gray-500 dark:text-dark-600'>
DocumentType Payment Type
</dt> </dt>
<dd className='flex items-start gap-x-2'> <dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'> <div className='font-medium line-clamp-4'>
{item.document_type} {item.payment_type}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
PreparedBy
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.prepared_by}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
Status
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.status}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
CashBalance
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{dataFormatter.booleanFormatter(item.cash_balance)}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
PaymentDate
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{dataFormatter.dateTimeFormatter(item.payment_date)}
</div> </div>
</dd> </dd>
</div> </div>
@ -159,14 +148,36 @@ const CardDocuments = ({
</dt> </dt>
<dd className='flex items-start gap-x-2'> <dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'> <div className='font-medium line-clamp-4'>
{item.amount} {item.Amount}
</div> </div>
</dd> </dd>
</div> </div>
<div className='flex justify-between gap-x-4 py-3'> <div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'> <dt className=' text-gray-500 dark:text-dark-600'>
ShelfNumber Project Code
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.project_code}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
Document Status
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.document_status}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
Shelf Number
</dt> </dt>
<dd className='flex items-start gap-x-2'> <dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'> <div className='font-medium line-clamp-4'>
@ -174,17 +185,6 @@ const CardDocuments = ({
</div> </div>
</dd> </dd>
</div> </div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
ApprovedBy
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.approved_by}
</div>
</dd>
</div>
</dl> </dl>
</li> </li>
))} ))}

View File

@ -55,61 +55,69 @@ const ListDocuments = ({
> >
<div className={'flex-1 px-3'}> <div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}> <p className={'text-xs text-gray-500 '}>
DocumentNumber organizations
</p>
<p className={'line-clamp-2'}>
{dataFormatter.organizationsOneListFormatter(
item.organizations,
)}
</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>
Nameofemployee Organization
</p>
<p className={'line-clamp-2'}>
{item.nameofemployee_organization}
</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>
Document Number
</p> </p>
<p className={'line-clamp-2'}>{item.document_number}</p> <p className={'line-clamp-2'}>{item.document_number}</p>
</div> </div>
<div className={'flex-1 px-3'}> <div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Project</p> <p className={'text-xs text-gray-500 '}>Description</p>
<p className={'line-clamp-2'}>{item.description}</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Date</p>
<p className={'line-clamp-2'}> <p className={'line-clamp-2'}>
{dataFormatter.projectsOneListFormatter(item.project)} {dataFormatter.dateFormatter(item.date)}
</p> </p>
</div> </div>
<div className={'flex-1 px-3'}> <div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>DocumentType</p> <p className={'text-xs text-gray-500 '}>Payment Type</p>
<p className={'line-clamp-2'}>{item.document_type}</p> <p className={'line-clamp-2'}>{item.payment_type}</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>PreparedBy</p>
<p className={'line-clamp-2'}>{item.prepared_by}</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Status</p>
<p className={'line-clamp-2'}>{item.status}</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>CashBalance</p>
<p className={'line-clamp-2'}>
{dataFormatter.booleanFormatter(item.cash_balance)}
</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>PaymentDate</p>
<p className={'line-clamp-2'}>
{dataFormatter.dateTimeFormatter(item.payment_date)}
</p>
</div> </div>
<div className={'flex-1 px-3'}> <div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Amount</p> <p className={'text-xs text-gray-500 '}>Amount</p>
<p className={'line-clamp-2'}>{item.amount}</p> <p className={'line-clamp-2'}>{item.Amount}</p>
</div> </div>
<div className={'flex-1 px-3'}> <div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>ShelfNumber</p> <p className={'text-xs text-gray-500 '}>Project Code</p>
<p className={'line-clamp-2'}>{item.project_code}</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>
Document Status
</p>
<p className={'line-clamp-2'}>{item.document_status}</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Shelf Number</p>
<p className={'line-clamp-2'}>{item.shelf_number}</p> <p className={'line-clamp-2'}>{item.shelf_number}</p>
</div> </div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>ApprovedBy</p>
<p className={'line-clamp-2'}>{item.approved_by}</p>
</div>
</Link> </Link>
<ListActionsPopover <ListActionsPopover
onDelete={onDelete} onDelete={onDelete}

View File

@ -39,20 +39,8 @@ export const loadColumns = async (
return [ return [
{ {
field: 'document_number', field: 'organizations',
headerName: 'DocumentNumber', headerName: 'organizations',
flex: 1,
minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell',
editable: hasUpdatePermission,
},
{
field: 'project',
headerName: 'Project',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,
@ -65,14 +53,14 @@ export const loadColumns = async (
type: 'singleSelect', type: 'singleSelect',
getOptionValue: (value: any) => value?.id, getOptionValue: (value: any) => value?.id,
getOptionLabel: (value: any) => value?.label, getOptionLabel: (value: any) => value?.label,
valueOptions: await callOptionsApi('projects'), valueOptions: await callOptionsApi('organizations'),
valueGetter: (params: GridValueGetterParams) => valueGetter: (params: GridValueGetterParams) =>
params?.value?.id ?? params?.value, params?.value?.id ?? params?.value,
}, },
{ {
field: 'document_type', field: 'nameofemployee_organization',
headerName: 'DocumentType', headerName: 'Nameofemployee Organization',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,
@ -83,8 +71,8 @@ export const loadColumns = async (
}, },
{ {
field: 'prepared_by', field: 'document_number',
headerName: 'PreparedBy', headerName: 'Document Number',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,
@ -95,8 +83,8 @@ export const loadColumns = async (
}, },
{ {
field: 'status', field: 'description',
headerName: 'Status', headerName: 'Description',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,
@ -107,8 +95,8 @@ export const loadColumns = async (
}, },
{ {
field: 'cash_balance', field: 'date',
headerName: 'CashBalance', headerName: 'Date',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,
@ -117,12 +105,13 @@ export const loadColumns = async (
editable: hasUpdatePermission, editable: hasUpdatePermission,
type: 'boolean', type: 'date',
valueGetter: (params: GridValueGetterParams) => new Date(params.row.date),
}, },
{ {
field: 'payment_date', field: 'payment_type',
headerName: 'PaymentDate', headerName: 'Payment Type',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,
@ -130,14 +119,10 @@ export const loadColumns = async (
cellClassName: 'datagrid--cell', cellClassName: 'datagrid--cell',
editable: hasUpdatePermission, editable: hasUpdatePermission,
type: 'dateTime',
valueGetter: (params: GridValueGetterParams) =>
new Date(params.row.payment_date),
}, },
{ {
field: 'amount', field: 'Amount',
headerName: 'Amount', headerName: 'Amount',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
@ -151,8 +136,8 @@ export const loadColumns = async (
}, },
{ {
field: 'shelf_number', field: 'project_code',
headerName: 'ShelfNumber', headerName: 'Project Code',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,
@ -163,8 +148,20 @@ export const loadColumns = async (
}, },
{ {
field: 'approved_by', field: 'document_status',
headerName: 'ApprovedBy', headerName: 'Document Status',
flex: 1,
minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell',
editable: hasUpdatePermission,
},
{
field: 'shelf_number',
headerName: 'Shelf Number',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false, filterable: false,

View File

@ -65,7 +65,7 @@ const CardField_site_payment_requisitions = ({
href={`/field_site_payment_requisitions/field_site_payment_requisitions-view/?id=${item.id}`} href={`/field_site_payment_requisitions/field_site_payment_requisitions-view/?id=${item.id}`}
className='text-lg font-bold leading-6 line-clamp-1' className='text-lg font-bold leading-6 line-clamp-1'
> >
{item.id} {item.employee_name}
</Link> </Link>
<div className='ml-auto '> <div className='ml-auto '>
@ -147,6 +147,17 @@ const CardField_site_payment_requisitions = ({
</dd> </dd>
</div> </div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
ArrivalPlace
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.arrival_place}
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'> <div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'> <dt className=' text-gray-500 dark:text-dark-600'>
ReturnDate ReturnDate

View File

@ -157,7 +157,7 @@ const ListField_site_payment_requisitions = ({
onDelete={onDelete} onDelete={onDelete}
itemId={item.id} itemId={item.id}
pathEdit={`/field_site_payment_requisitions/field_site_payment_requisitions-edit/?id=${item.id}`} pathEdit={`/field_site_payment_requisitions/field_site_payment_requisitions-edit/?id=${item.id}`}
pathEdit={`/field_site_payment_requisitions/${item.id}/edit`} pathView={`/field_site_payment_requisitions/field_site_payment_requisitions-view/?id=${item.id}`}
hasUpdatePermission={hasUpdatePermission} hasUpdatePermission={hasUpdatePermission}
/> />
</div> </div>

View File

@ -471,8 +471,6 @@ const TableSampleField_site_payment_requisitions = ({
{dataGrid} {dataGrid}
{showGrid && dataGrid}
{selectedRows.length > 0 && {selectedRows.length > 0 &&
createPortal( createPortal(
<BaseButton <BaseButton

View File

@ -266,12 +266,12 @@ export const loadColumns = async (
<div key={params?.row?.id}> <div key={params?.row?.id}>
<ListActionsPopover <ListActionsPopover
onDelete={onDelete} onDelete={onDelete}
itemId={params.row.id} itemId={params?.row?.id}
pathEdit={`/field_site_payment_requisitions/${params.row.id}`} pathEdit={`/field_site_payment_requisitions/field_site_payment_requisitions-edit/?id=${params?.row?.id}`}
pathView={`/field_site_payment_requisitions/field_site_payment_requisitions-view/?id=${params.row.id}`} pathView={`/field_site_payment_requisitions/field_site_payment_requisitions-view/?id=${params?.row?.id}`}
hasUpdatePermission={hasUpdatePermission} hasUpdatePermission={hasUpdatePermission}
/> />
</div> </div>,
]; ];
}, },
}, },

View File

@ -65,7 +65,7 @@ const CardOrganizations = ({
href={`/organizations/organizations-view/?id=${item.id}`} href={`/organizations/organizations-view/?id=${item.id}`}
className='text-lg font-bold leading-6 line-clamp-1' className='text-lg font-bold leading-6 line-clamp-1'
> >
{item.name} {item.id}
</Link> </Link>
<div className='ml-auto '> <div className='ml-auto '>

View File

@ -17,7 +17,7 @@ export default function WebSiteFooter({ projectName }: WebSiteFooterProps) {
const borders = useAppSelector((state) => state.style.borders); const borders = useAppSelector((state) => state.style.borders);
const websiteHeder = useAppSelector((state) => state.style.websiteHeder); const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
const style = FooterStyle.WITH_PROJECT_NAME; const style = FooterStyle.WITH_PAGES;
const design = FooterDesigns.DEFAULT_DESIGN; const design = FooterDesigns.DEFAULT_DESIGN;

View File

@ -17,7 +17,7 @@ export default function WebSiteHeader({ projectName }: WebSiteHeaderProps) {
const websiteHeder = useAppSelector((state) => state.style.websiteHeder); const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
const borders = useAppSelector((state) => state.style.borders); const borders = useAppSelector((state) => state.style.borders);
const style = HeaderStyle.PAGES_LEFT; const style = HeaderStyle.PAGES_RIGHT;
const design = HeaderDesigns.DESIGN_DIVERSITY; const design = HeaderDesigns.DESIGN_DIVERSITY;
return ( return (

View File

@ -41,21 +41,21 @@ export default {
documentsManyListFormatter(val) { documentsManyListFormatter(val) {
if (!val || !val.length) return []; if (!val || !val.length) return [];
return val.map((item) => item.document_number); return val.map((item) => item.id);
}, },
documentsOneListFormatter(val) { documentsOneListFormatter(val) {
if (!val) return ''; if (!val) return '';
return val.document_number; return val.id;
}, },
documentsManyListFormatterEdit(val) { documentsManyListFormatterEdit(val) {
if (!val || !val.length) return []; if (!val || !val.length) return [];
return val.map((item) => { return val.map((item) => {
return { id: item.id, label: item.document_number }; return { id: item.id, label: item.id };
}); });
}, },
documentsOneListFormatterEdit(val) { documentsOneListFormatterEdit(val) {
if (!val) return ''; if (!val) return '';
return { label: val.document_number, id: val.id }; return { label: val.id, id: val.id };
}, },
projectsManyListFormatter(val) { projectsManyListFormatter(val) {
@ -117,20 +117,20 @@ export default {
organizationsManyListFormatter(val) { organizationsManyListFormatter(val) {
if (!val || !val.length) return []; if (!val || !val.length) return [];
return val.map((item) => item.name); return val.map((item) => item.id);
}, },
organizationsOneListFormatter(val) { organizationsOneListFormatter(val) {
if (!val) return ''; if (!val) return '';
return val.name; return val.id;
}, },
organizationsManyListFormatterEdit(val) { organizationsManyListFormatterEdit(val) {
if (!val || !val.length) return []; if (!val || !val.length) return [];
return val.map((item) => { return val.map((item) => {
return { id: item.id, label: item.name }; return { id: item.id, label: item.id };
}); });
}, },
organizationsOneListFormatterEdit(val) { organizationsOneListFormatterEdit(val) {
if (!val) return ''; if (!val) return '';
return { label: val.name, id: val.id }; return { label: val.id, id: val.id };
}, },
}; };

View File

@ -76,6 +76,22 @@ const menuAside: MenuAsideItem[] = [
icon: icon.mdiShieldAccountOutline ?? icon.mdiTable, icon: icon.mdiShieldAccountOutline ?? icon.mdiTable,
permissions: 'READ_PERMISSIONS', permissions: 'READ_PERMISSIONS',
}, },
{
href: '/departments/departments-list',
label: 'Departments',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: icon.mdiTable ?? icon.mdiTable,
permissions: 'READ_DEPARTMENTS',
},
{
href: '/places/places-list',
label: 'Places',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: icon.mdiTable ?? icon.mdiTable,
permissions: 'READ_PLACES',
},
{ {
href: '/organizations/organizations-list', href: '/organizations/organizations-list',
label: 'Organizations', label: 'Organizations',

View File

@ -36,6 +36,8 @@ const Dashboard = () => {
const [projects, setProjects] = React.useState(loadingMessage); const [projects, setProjects] = React.useState(loadingMessage);
const [roles, setRoles] = React.useState(loadingMessage); const [roles, setRoles] = React.useState(loadingMessage);
const [permissions, setPermissions] = React.useState(loadingMessage); const [permissions, setPermissions] = React.useState(loadingMessage);
const [departments, setDepartments] = React.useState(loadingMessage);
const [places, setPlaces] = React.useState(loadingMessage);
const [organizations, setOrganizations] = React.useState(loadingMessage); const [organizations, setOrganizations] = React.useState(loadingMessage);
const [widgetsRole, setWidgetsRole] = React.useState({ const [widgetsRole, setWidgetsRole] = React.useState({
@ -57,6 +59,8 @@ const Dashboard = () => {
'projects', 'projects',
'roles', 'roles',
'permissions', 'permissions',
'departments',
'places',
'organizations', 'organizations',
]; ];
const fns = [ const fns = [
@ -67,6 +71,8 @@ const Dashboard = () => {
setProjects, setProjects,
setRoles, setRoles,
setPermissions, setPermissions,
setDepartments,
setPlaces,
setOrganizations, setOrganizations,
]; ];
@ -431,6 +437,70 @@ const Dashboard = () => {
</Link> </Link>
)} )}
{hasPermission(currentUser, 'READ_DEPARTMENTS') && (
<Link href={'/departments/departments-list'}>
<div
className={`${
corners !== 'rounded-full' ? corners : 'rounded-3xl'
} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className='flex justify-between align-center'>
<div>
<div className='text-lg leading-tight text-gray-500 dark:text-gray-400'>
Departments
</div>
<div className='text-3xl leading-tight font-semibold'>
{departments}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w='w-16'
h='h-16'
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>
)}
{hasPermission(currentUser, 'READ_PLACES') && (
<Link href={'/places/places-list'}>
<div
className={`${
corners !== 'rounded-full' ? corners : 'rounded-3xl'
} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className='flex justify-between align-center'>
<div>
<div className='text-lg leading-tight text-gray-500 dark:text-gray-400'>
Places
</div>
<div className='text-3xl leading-tight font-semibold'>
{places}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w='w-16'
h='h-16'
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>
)}
{hasPermission(currentUser, 'READ_ORGANIZATIONS') && ( {hasPermission(currentUser, 'READ_ORGANIZATIONS') && (
<Link href={'/organizations/organizations-list'}> <Link href={'/organizations/organizations-list'}>
<div <div

View File

@ -0,0 +1,137 @@
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js';
import Head from 'next/head';
import React, { ReactElement, useEffect, useState } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import dayjs from 'dayjs';
import CardBox from '../../components/CardBox';
import LayoutAuthenticated from '../../layouts/Authenticated';
import SectionMain from '../../components/SectionMain';
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
import { getPageTitle } from '../../config';
import { Field, Form, Formik } from 'formik';
import FormField from '../../components/FormField';
import BaseDivider from '../../components/BaseDivider';
import BaseButtons from '../../components/BaseButtons';
import BaseButton from '../../components/BaseButton';
import FormCheckRadio from '../../components/FormCheckRadio';
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
import FormFilePicker from '../../components/FormFilePicker';
import FormImagePicker from '../../components/FormImagePicker';
import { SelectField } from '../../components/SelectField';
import { SelectFieldMany } from '../../components/SelectFieldMany';
import { SwitchField } from '../../components/SwitchField';
import { RichTextField } from '../../components/RichTextField';
import { update, fetch } from '../../stores/departments/departmentsSlice';
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
import { useRouter } from 'next/router';
import { saveFile } from '../../helpers/fileSaver';
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from '../../components/ImageField';
import { hasPermission } from '../../helpers/userPermissions';
const EditDepartments = () => {
const router = useRouter();
const dispatch = useAppDispatch();
const initVals = {
organizations: null,
};
const [initialValues, setInitialValues] = useState(initVals);
const { departments } = useAppSelector((state) => state.departments);
const { currentUser } = useAppSelector((state) => state.auth);
const { departmentsId } = router.query;
useEffect(() => {
dispatch(fetch({ id: departmentsId }));
}, [departmentsId]);
useEffect(() => {
if (typeof departments === 'object') {
setInitialValues(departments);
}
}, [departments]);
useEffect(() => {
if (typeof departments === 'object') {
const newInitialVal = { ...initVals };
Object.keys(initVals).forEach(
(el) => (newInitialVal[el] = departments[el]),
);
setInitialValues(newInitialVal);
}
}, [departments]);
const handleSubmit = async (data) => {
await dispatch(update({ id: departmentsId, data }));
await router.push('/departments/departments-list');
};
return (
<>
<Head>
<title>{getPageTitle('Edit departments')}</title>
</Head>
<SectionMain>
<SectionTitleLineWithButton
icon={mdiChartTimelineVariant}
title={'Edit departments'}
main
>
{''}
</SectionTitleLineWithButton>
<CardBox>
<Formik
enableReinitialize
initialValues={initialValues}
onSubmit={(values) => handleSubmit(values)}
>
<Form>
<FormField label='organizations' labelFor='organizations'>
<Field
name='organizations'
id='organizations'
component={SelectField}
options={initialValues.organizations}
itemRef={'organizations'}
showField={'id'}
></Field>
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />
<BaseButton type='reset' color='info' outline label='Reset' />
<BaseButton
type='reset'
color='danger'
outline
label='Cancel'
onClick={() => router.push('/departments/departments-list')}
/>
</BaseButtons>
</Form>
</Formik>
</CardBox>
</SectionMain>
</>
);
};
EditDepartments.getLayout = function getLayout(page: ReactElement) {
return (
<LayoutAuthenticated permission={'UPDATE_DEPARTMENTS'}>
{page}
</LayoutAuthenticated>
);
};
export default EditDepartments;

View File

@ -0,0 +1,135 @@
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js';
import Head from 'next/head';
import React, { ReactElement, useEffect, useState } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import dayjs from 'dayjs';
import CardBox from '../../components/CardBox';
import LayoutAuthenticated from '../../layouts/Authenticated';
import SectionMain from '../../components/SectionMain';
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
import { getPageTitle } from '../../config';
import { Field, Form, Formik } from 'formik';
import FormField from '../../components/FormField';
import BaseDivider from '../../components/BaseDivider';
import BaseButtons from '../../components/BaseButtons';
import BaseButton from '../../components/BaseButton';
import FormCheckRadio from '../../components/FormCheckRadio';
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
import FormFilePicker from '../../components/FormFilePicker';
import FormImagePicker from '../../components/FormImagePicker';
import { SelectField } from '../../components/SelectField';
import { SelectFieldMany } from '../../components/SelectFieldMany';
import { SwitchField } from '../../components/SwitchField';
import { RichTextField } from '../../components/RichTextField';
import { update, fetch } from '../../stores/departments/departmentsSlice';
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
import { useRouter } from 'next/router';
import { saveFile } from '../../helpers/fileSaver';
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from '../../components/ImageField';
import { hasPermission } from '../../helpers/userPermissions';
const EditDepartmentsPage = () => {
const router = useRouter();
const dispatch = useAppDispatch();
const initVals = {
organizations: null,
};
const [initialValues, setInitialValues] = useState(initVals);
const { departments } = useAppSelector((state) => state.departments);
const { currentUser } = useAppSelector((state) => state.auth);
const { id } = router.query;
useEffect(() => {
dispatch(fetch({ id: id }));
}, [id]);
useEffect(() => {
if (typeof departments === 'object') {
setInitialValues(departments);
}
}, [departments]);
useEffect(() => {
if (typeof departments === 'object') {
const newInitialVal = { ...initVals };
Object.keys(initVals).forEach(
(el) => (newInitialVal[el] = departments[el]),
);
setInitialValues(newInitialVal);
}
}, [departments]);
const handleSubmit = async (data) => {
await dispatch(update({ id: id, data }));
await router.push('/departments/departments-list');
};
return (
<>
<Head>
<title>{getPageTitle('Edit departments')}</title>
</Head>
<SectionMain>
<SectionTitleLineWithButton
icon={mdiChartTimelineVariant}
title={'Edit departments'}
main
>
{''}
</SectionTitleLineWithButton>
<CardBox>
<Formik
enableReinitialize
initialValues={initialValues}
onSubmit={(values) => handleSubmit(values)}
>
<Form>
<FormField label='organizations' labelFor='organizations'>
<Field
name='organizations'
id='organizations'
component={SelectField}
options={initialValues.organizations}
itemRef={'organizations'}
showField={'id'}
></Field>
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />
<BaseButton type='reset' color='info' outline label='Reset' />
<BaseButton
type='reset'
color='danger'
outline
label='Cancel'
onClick={() => router.push('/departments/departments-list')}
/>
</BaseButtons>
</Form>
</Formik>
</CardBox>
</SectionMain>
</>
);
};
EditDepartmentsPage.getLayout = function getLayout(page: ReactElement) {
return (
<LayoutAuthenticated permission={'UPDATE_DEPARTMENTS'}>
{page}
</LayoutAuthenticated>
);
};
export default EditDepartmentsPage;

View File

@ -0,0 +1,88 @@
import React, { ReactElement, useEffect } from 'react';
import Head from 'next/head';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import dayjs from 'dayjs';
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
import { useRouter } from 'next/router';
import { fetch } from '../../stores/departments/departmentsSlice';
import { saveFile } from '../../helpers/fileSaver';
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from '../../components/ImageField';
import LayoutAuthenticated from '../../layouts/Authenticated';
import { getPageTitle } from '../../config';
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
import SectionMain from '../../components/SectionMain';
import CardBox from '../../components/CardBox';
import BaseButton from '../../components/BaseButton';
import BaseDivider from '../../components/BaseDivider';
import { mdiChartTimelineVariant } from '@mdi/js';
import { SwitchField } from '../../components/SwitchField';
import FormField from '../../components/FormField';
import { hasPermission } from '../../helpers/userPermissions';
const DepartmentsView = () => {
const router = useRouter();
const dispatch = useAppDispatch();
const { departments } = useAppSelector((state) => state.departments);
const { currentUser } = useAppSelector((state) => state.auth);
const { id } = router.query;
function removeLastCharacter(str) {
console.log(str, `str`);
return str.slice(0, -1);
}
useEffect(() => {
dispatch(fetch({ id }));
}, [dispatch, id]);
return (
<>
<Head>
<title>{getPageTitle('View departments')}</title>
</Head>
<SectionMain>
<SectionTitleLineWithButton
icon={mdiChartTimelineVariant}
title={removeLastCharacter('View departments')}
main
>
<BaseButton
color='info'
label='Edit'
href={`/departments/departments-edit/?id=${id}`}
/>
</SectionTitleLineWithButton>
<CardBox>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>organizations</p>
<p>{departments?.organizations?.id ?? 'No data'}</p>
</div>
<BaseDivider />
<BaseButton
color='info'
label='Back'
onClick={() => router.push('/departments/departments-list')}
/>
</CardBox>
</SectionMain>
</>
);
};
DepartmentsView.getLayout = function getLayout(page: ReactElement) {
return (
<LayoutAuthenticated permission={'READ_DEPARTMENTS'}>
{page}
</LayoutAuthenticated>
);
};
export default DepartmentsView;

View File

@ -38,27 +38,25 @@ const EditDocuments = () => {
const router = useRouter(); const router = useRouter();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const initVals = { const initVals = {
organizations: null,
nameofemployee_organization: '',
document_number: '', document_number: '',
project: null, description: '',
document_type: '', date: new Date(),
prepared_by: '', payment_type: '',
status: '', Amount: '',
cash_balance: false, project_code: '',
payment_date: new Date(), document_status: '',
amount: '',
shelf_number: '', shelf_number: '',
approved_by: '',
organizations: null,
}; };
const [initialValues, setInitialValues] = useState(initVals); const [initialValues, setInitialValues] = useState(initVals);
@ -115,86 +113,6 @@ const EditDocuments = () => {
onSubmit={(values) => handleSubmit(values)} onSubmit={(values) => handleSubmit(values)}
> >
<Form> <Form>
<FormField label='DocumentNumber'>
<Field name='document_number' placeholder='DocumentNumber' />
</FormField>
<FormField label='Project' labelFor='project'>
<Field
name='project'
id='project'
component={SelectField}
options={initialValues.project}
itemRef={'projects'}
showField={'name'}
></Field>
</FormField>
<FormField label='DocumentType' labelFor='document_type'>
<Field
name='document_type'
id='document_type'
component='select'
>
<option value='BPV'>BPV</option>
<option value='JV'>JV</option>
<option value='RV'>RV</option>
</Field>
</FormField>
<FormField label='PreparedBy'>
<Field name='prepared_by' placeholder='PreparedBy' />
</FormField>
<FormField label='Status' labelFor='status'>
<Field name='status' id='status' component='select'>
<option value='Filed'>Filed</option>
<option value='InProgress'>InProgress</option>
</Field>
</FormField>
<FormField label='CashBalance' labelFor='cash_balance'>
<Field
name='cash_balance'
id='cash_balance'
component={SwitchField}
></Field>
</FormField>
<FormField label='PaymentDate'>
<DatePicker
dateFormat='yyyy-MM-dd hh:mm'
showTimeSelect
selected={
initialValues.payment_date
? new Date(
dayjs(initialValues.payment_date).format(
'YYYY-MM-DD hh:mm',
),
)
: null
}
onChange={(date) =>
setInitialValues({ ...initialValues, payment_date: date })
}
/>
</FormField>
<FormField label='Amount'>
<Field type='number' name='amount' placeholder='Amount' />
</FormField>
<FormField label='ShelfNumber'>
<Field name='shelf_number' placeholder='ShelfNumber' />
</FormField>
<FormField label='ApprovedBy'>
<Field name='approved_by' placeholder='ApprovedBy' />
</FormField>
<FormField label='organizations' labelFor='organizations'> <FormField label='organizations' labelFor='organizations'>
<Field <Field
name='organizations' name='organizations'
@ -202,10 +120,81 @@ const EditDocuments = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
<FormField label='Nameofemployee Organization'>
<Field
name='nameofemployee_organization'
placeholder='Nameofemployee Organization'
/>
</FormField>
<FormField label='Document Number'>
<Field name='document_number' placeholder='Document Number' />
</FormField>
<FormField label='Description'>
<Field name='description' placeholder='Description' />
</FormField>
<FormField label='Date'>
<DatePicker
dateFormat='yyyy-MM-dd'
selected={
initialValues.date
? new Date(
dayjs(initialValues.date).format('YYYY-MM-DD hh:mm'),
)
: null
}
onChange={(date) =>
setInitialValues({ ...initialValues, date: date })
}
/>
</FormField>
<FormField label='Payment Type' labelFor='payment_type'>
<Field name='payment_type' id='payment_type' component='select'>
<option value='BPV'>BPV</option>
<option value='JV'>JV</option>
<option value='RV'>RV</option>
<option value='CPV'>CPV</option>
</Field>
</FormField>
<FormField label='Amount'>
<Field type='number' name='Amount' placeholder='Amount' />
</FormField>
<FormField label='Project Code'>
<Field name='project_code' placeholder='Project Code' />
</FormField>
<FormField label='Document Status' labelFor='document_status'>
<Field
name='document_status'
id='document_status'
component='select'
>
<option value='Approved'>Approved</option>
<option value='Complete'>Complete</option>
<option value='On progress'>On progress</option>
<option value='Filled'>Filled</option>
</Field>
</FormField>
<FormField label='Shelf Number'>
<Field name='shelf_number' placeholder='Shelf Number' />
</FormField>
<BaseDivider /> <BaseDivider />
<BaseButtons> <BaseButtons>
<BaseButton type='submit' color='info' label='Submit' /> <BaseButton type='submit' color='info' label='Submit' />

View File

@ -38,27 +38,25 @@ const EditDocumentsPage = () => {
const router = useRouter(); const router = useRouter();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const initVals = { const initVals = {
organizations: null,
nameofemployee_organization: '',
document_number: '', document_number: '',
project: null, description: '',
document_type: '', date: new Date(),
prepared_by: '', payment_type: '',
status: '', Amount: '',
cash_balance: false, project_code: '',
payment_date: new Date(), document_status: '',
amount: '',
shelf_number: '', shelf_number: '',
approved_by: '',
organizations: null,
}; };
const [initialValues, setInitialValues] = useState(initVals); const [initialValues, setInitialValues] = useState(initVals);
@ -113,86 +111,6 @@ const EditDocumentsPage = () => {
onSubmit={(values) => handleSubmit(values)} onSubmit={(values) => handleSubmit(values)}
> >
<Form> <Form>
<FormField label='DocumentNumber'>
<Field name='document_number' placeholder='DocumentNumber' />
</FormField>
<FormField label='Project' labelFor='project'>
<Field
name='project'
id='project'
component={SelectField}
options={initialValues.project}
itemRef={'projects'}
showField={'name'}
></Field>
</FormField>
<FormField label='DocumentType' labelFor='document_type'>
<Field
name='document_type'
id='document_type'
component='select'
>
<option value='BPV'>BPV</option>
<option value='JV'>JV</option>
<option value='RV'>RV</option>
</Field>
</FormField>
<FormField label='PreparedBy'>
<Field name='prepared_by' placeholder='PreparedBy' />
</FormField>
<FormField label='Status' labelFor='status'>
<Field name='status' id='status' component='select'>
<option value='Filed'>Filed</option>
<option value='InProgress'>InProgress</option>
</Field>
</FormField>
<FormField label='CashBalance' labelFor='cash_balance'>
<Field
name='cash_balance'
id='cash_balance'
component={SwitchField}
></Field>
</FormField>
<FormField label='PaymentDate'>
<DatePicker
dateFormat='yyyy-MM-dd hh:mm'
showTimeSelect
selected={
initialValues.payment_date
? new Date(
dayjs(initialValues.payment_date).format(
'YYYY-MM-DD hh:mm',
),
)
: null
}
onChange={(date) =>
setInitialValues({ ...initialValues, payment_date: date })
}
/>
</FormField>
<FormField label='Amount'>
<Field type='number' name='amount' placeholder='Amount' />
</FormField>
<FormField label='ShelfNumber'>
<Field name='shelf_number' placeholder='ShelfNumber' />
</FormField>
<FormField label='ApprovedBy'>
<Field name='approved_by' placeholder='ApprovedBy' />
</FormField>
<FormField label='organizations' labelFor='organizations'> <FormField label='organizations' labelFor='organizations'>
<Field <Field
name='organizations' name='organizations'
@ -200,10 +118,81 @@ const EditDocumentsPage = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
<FormField label='Nameofemployee Organization'>
<Field
name='nameofemployee_organization'
placeholder='Nameofemployee Organization'
/>
</FormField>
<FormField label='Document Number'>
<Field name='document_number' placeholder='Document Number' />
</FormField>
<FormField label='Description'>
<Field name='description' placeholder='Description' />
</FormField>
<FormField label='Date'>
<DatePicker
dateFormat='yyyy-MM-dd'
selected={
initialValues.date
? new Date(
dayjs(initialValues.date).format('YYYY-MM-DD hh:mm'),
)
: null
}
onChange={(date) =>
setInitialValues({ ...initialValues, date: date })
}
/>
</FormField>
<FormField label='Payment Type' labelFor='payment_type'>
<Field name='payment_type' id='payment_type' component='select'>
<option value='BPV'>BPV</option>
<option value='JV'>JV</option>
<option value='RV'>RV</option>
<option value='CPV'>CPV</option>
</Field>
</FormField>
<FormField label='Amount'>
<Field type='number' name='Amount' placeholder='Amount' />
</FormField>
<FormField label='Project Code'>
<Field name='project_code' placeholder='Project Code' />
</FormField>
<FormField label='Document Status' labelFor='document_status'>
<Field
name='document_status'
id='document_status'
component='select'
>
<option value='Approved'>Approved</option>
<option value='Complete'>Complete</option>
<option value='On progress'>On progress</option>
<option value='Filled'>Filled</option>
</Field>
</FormField>
<FormField label='Shelf Number'>
<Field name='shelf_number' placeholder='Shelf Number' />
</FormField>
<BaseDivider /> <BaseDivider />
<BaseButtons> <BaseButtons>
<BaseButton type='submit' color='info' label='Submit' /> <BaseButton type='submit' color='info' label='Submit' />

View File

@ -29,27 +29,28 @@ const DocumentsTablesPage = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const [filters] = useState([ const [filters] = useState([
{ label: 'DocumentNumber', title: 'document_number' }, {
{ label: 'PreparedBy', title: 'prepared_by' }, label: 'Nameofemployee Organization',
{ label: 'ShelfNumber', title: 'shelf_number' }, title: 'nameofemployee_organization',
{ label: 'ApprovedBy', title: 'approved_by' }, },
{ label: 'Document Number', title: 'document_number' },
{ label: 'Description', title: 'description' },
{ label: 'Project Code', title: 'project_code' },
{ label: 'Shelf Number', title: 'shelf_number' },
{ label: 'Amount', title: 'amount', number: 'true' }, { label: 'Amount', title: 'Amount', number: 'true' },
{ label: 'PaymentDate', title: 'payment_date', date: 'true' },
{ label: 'Project', title: 'project' },
{ {
label: 'DocumentType', label: 'Payment Type',
title: 'document_type', title: 'payment_type',
type: 'enum', type: 'enum',
options: ['BPV', 'JV', 'RV'], options: ['BPV', 'JV', 'RV', 'CPV'],
}, },
{ {
label: 'Status', label: 'Document Status',
title: 'status', title: 'document_status',
type: 'enum', type: 'enum',
options: ['Filed', 'InProgress'], options: ['Approved', 'Complete', 'On progress', 'Filled'],
}, },
]); ]);

View File

@ -33,27 +33,26 @@ import { useRouter } from 'next/router';
import moment from 'moment'; import moment from 'moment';
const initialValues = { const initialValues = {
organizations: '',
nameofemployee_organization: '',
document_number: '', document_number: '',
project: '', description: '',
document_type: 'BPV', date: '',
dateDate: '',
prepared_by: '', payment_type: 'BPV',
status: 'Filed', Amount: '',
cash_balance: false, project_code: '',
payment_date: '', document_status: 'Approved',
amount: '',
shelf_number: '', shelf_number: '',
approved_by: '',
organizations: '',
}; };
const DocumentsNew = () => { const DocumentsNew = () => {
@ -83,74 +82,6 @@ const DocumentsNew = () => {
onSubmit={(values) => handleSubmit(values)} onSubmit={(values) => handleSubmit(values)}
> >
<Form> <Form>
<FormField label='DocumentNumber'>
<Field name='document_number' placeholder='DocumentNumber' />
</FormField>
<FormField label='Project' labelFor='project'>
<Field
name='project'
id='project'
component={SelectField}
options={[]}
itemRef={'projects'}
></Field>
</FormField>
<FormField label='DocumentType' labelFor='document_type'>
<Field
name='document_type'
id='document_type'
component='select'
>
<option value='BPV'>BPV</option>
<option value='JV'>JV</option>
<option value='RV'>RV</option>
</Field>
</FormField>
<FormField label='PreparedBy'>
<Field name='prepared_by' placeholder='PreparedBy' />
</FormField>
<FormField label='Status' labelFor='status'>
<Field name='status' id='status' component='select'>
<option value='Filed'>Filed</option>
<option value='InProgress'>InProgress</option>
</Field>
</FormField>
<FormField label='CashBalance' labelFor='cash_balance'>
<Field
name='cash_balance'
id='cash_balance'
component={SwitchField}
></Field>
</FormField>
<FormField label='PaymentDate'>
<Field
type='datetime-local'
name='payment_date'
placeholder='PaymentDate'
/>
</FormField>
<FormField label='Amount'>
<Field type='number' name='amount' placeholder='Amount' />
</FormField>
<FormField label='ShelfNumber'>
<Field name='shelf_number' placeholder='ShelfNumber' />
</FormField>
<FormField label='ApprovedBy'>
<Field name='approved_by' placeholder='ApprovedBy' />
</FormField>
<FormField label='organizations' labelFor='organizations'> <FormField label='organizations' labelFor='organizations'>
<Field <Field
name='organizations' name='organizations'
@ -161,6 +92,65 @@ const DocumentsNew = () => {
></Field> ></Field>
</FormField> </FormField>
<FormField label='Nameofemployee Organization'>
<Field
name='nameofemployee_organization'
placeholder='Nameofemployee Organization'
/>
</FormField>
<FormField label='Document Number'>
<Field name='document_number' placeholder='Document Number' />
</FormField>
<FormField label='Description'>
<Field name='description' placeholder='Description' />
</FormField>
<FormField label='Date'>
<Field type='date' name='date' placeholder='Date' />
</FormField>
<FormField label='Payment Type' labelFor='payment_type'>
<Field name='payment_type' id='payment_type' component='select'>
<option value='BPV'>BPV</option>
<option value='JV'>JV</option>
<option value='RV'>RV</option>
<option value='CPV'>CPV</option>
</Field>
</FormField>
<FormField label='Amount'>
<Field type='number' name='Amount' placeholder='Amount' />
</FormField>
<FormField label='Project Code'>
<Field name='project_code' placeholder='Project Code' />
</FormField>
<FormField label='Document Status' labelFor='document_status'>
<Field
name='document_status'
id='document_status'
component='select'
>
<option value='Approved'>Approved</option>
<option value='Complete'>Complete</option>
<option value='On progress'>On progress</option>
<option value='Filled'>Filled</option>
</Field>
</FormField>
<FormField label='Shelf Number'>
<Field name='shelf_number' placeholder='Shelf Number' />
</FormField>
<BaseDivider /> <BaseDivider />
<BaseButtons> <BaseButtons>
<BaseButton type='submit' color='info' label='Submit' /> <BaseButton type='submit' color='info' label='Submit' />

View File

@ -29,27 +29,28 @@ const DocumentsTablesPage = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const [filters] = useState([ const [filters] = useState([
{ label: 'DocumentNumber', title: 'document_number' }, {
{ label: 'PreparedBy', title: 'prepared_by' }, label: 'Nameofemployee Organization',
{ label: 'ShelfNumber', title: 'shelf_number' }, title: 'nameofemployee_organization',
{ label: 'ApprovedBy', title: 'approved_by' }, },
{ label: 'Document Number', title: 'document_number' },
{ label: 'Description', title: 'description' },
{ label: 'Project Code', title: 'project_code' },
{ label: 'Shelf Number', title: 'shelf_number' },
{ label: 'Amount', title: 'amount', number: 'true' }, { label: 'Amount', title: 'Amount', number: 'true' },
{ label: 'PaymentDate', title: 'payment_date', date: 'true' },
{ label: 'Project', title: 'project' },
{ {
label: 'DocumentType', label: 'Payment Type',
title: 'document_type', title: 'payment_type',
type: 'enum', type: 'enum',
options: ['BPV', 'JV', 'RV'], options: ['BPV', 'JV', 'RV', 'CPV'],
}, },
{ {
label: 'Status', label: 'Document Status',
title: 'status', title: 'document_status',
type: 'enum', type: 'enum',
options: ['Filed', 'InProgress'], options: ['Approved', 'Complete', 'On progress', 'Filled'],
}, },
]); ]);

View File

@ -59,81 +59,70 @@ const DocumentsView = () => {
</SectionTitleLineWithButton> </SectionTitleLineWithButton>
<CardBox> <CardBox>
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>DocumentNumber</p> <p className={'block font-bold mb-2'}>organizations</p>
<p>{documents?.organizations?.id ?? 'No data'}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>
Nameofemployee Organization
</p>
<p>{documents?.nameofemployee_organization}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Document Number</p>
<p>{documents?.document_number}</p> <p>{documents?.document_number}</p>
</div> </div>
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Project</p> <p className={'block font-bold mb-2'}>Description</p>
<p>{documents?.description}</p>
<p>{documents?.project?.name ?? 'No data'}</p>
</div> </div>
<div className={'mb-4'}> <FormField label='Date'>
<p className={'block font-bold mb-2'}>DocumentType</p> {documents.date ? (
<p>{documents?.document_type ?? 'No data'}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>PreparedBy</p>
<p>{documents?.prepared_by}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Status</p>
<p>{documents?.status ?? 'No data'}</p>
</div>
<FormField label='CashBalance'>
<SwitchField
field={{ name: 'cash_balance', value: documents?.cash_balance }}
form={{ setFieldValue: () => null }}
disabled
/>
</FormField>
<FormField label='PaymentDate'>
{documents.payment_date ? (
<DatePicker <DatePicker
dateFormat='yyyy-MM-dd hh:mm' dateFormat='yyyy-MM-dd'
showTimeSelect showTimeSelect
selected={ selected={
documents.payment_date documents.date
? new Date( ? new Date(dayjs(documents.date).format('YYYY-MM-DD hh:mm'))
dayjs(documents.payment_date).format(
'YYYY-MM-DD hh:mm',
),
)
: null : null
} }
disabled disabled
/> />
) : ( ) : (
<p>No PaymentDate</p> <p>No Date</p>
)} )}
</FormField> </FormField>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Payment Type</p>
<p>{documents?.payment_type ?? 'No data'}</p>
</div>
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Amount</p> <p className={'block font-bold mb-2'}>Amount</p>
<p>{documents?.amount || 'No data'}</p> <p>{documents?.Amount || 'No data'}</p>
</div> </div>
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>ShelfNumber</p> <p className={'block font-bold mb-2'}>Project Code</p>
<p>{documents?.project_code}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Document Status</p>
<p>{documents?.document_status ?? 'No data'}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Shelf Number</p>
<p>{documents?.shelf_number}</p> <p>{documents?.shelf_number}</p>
</div> </div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>ApprovedBy</p>
<p>{documents?.approved_by}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>organizations</p>
<p>{documents?.organizations?.name ?? 'No data'}</p>
</div>
<> <>
<p className={'block font-bold mb-2'}>Payments Document</p> <p className={'block font-bold mb-2'}>Payments Document</p>
<CardBox <CardBox

View File

@ -53,8 +53,6 @@ const EditField_site_payment_requisitions = () => {
departure_date: new Date(), departure_date: new Date(),
arrival_place: '',
return_date: new Date(), return_date: new Date(),
requisition_date: new Date(), requisition_date: new Date(),
@ -140,7 +138,7 @@ const EditField_site_payment_requisitions = () => {
component={SelectField} component={SelectField}
options={initialValues.organization} options={initialValues.organization}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
)} )}
@ -187,10 +185,6 @@ const EditField_site_payment_requisitions = () => {
/> />
</FormField> </FormField>
<FormField label='ArrivalPlace'>
<Field name='arrival_place' placeholder='ArrivalPlace' />
</FormField>
<FormField label='ReturnDate'> <FormField label='ReturnDate'>
<DatePicker <DatePicker
dateFormat='yyyy-MM-dd hh:mm' dateFormat='yyyy-MM-dd hh:mm'
@ -294,7 +288,7 @@ const EditField_site_payment_requisitions = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -53,8 +53,6 @@ const EditField_site_payment_requisitionsPage = () => {
departure_date: new Date(), departure_date: new Date(),
arrival_place: '',
return_date: new Date(), return_date: new Date(),
requisition_date: new Date(), requisition_date: new Date(),
@ -138,7 +136,7 @@ const EditField_site_payment_requisitionsPage = () => {
component={SelectField} component={SelectField}
options={initialValues.organization} options={initialValues.organization}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
)} )}
@ -185,10 +183,6 @@ const EditField_site_payment_requisitionsPage = () => {
/> />
</FormField> </FormField>
<FormField label='ArrivalPlace'>
<Field name='arrival_place' placeholder='ArrivalPlace' />
</FormField>
<FormField label='ReturnDate'> <FormField label='ReturnDate'>
<DatePicker <DatePicker
dateFormat='yyyy-MM-dd hh:mm' dateFormat='yyyy-MM-dd hh:mm'
@ -292,7 +286,7 @@ const EditField_site_payment_requisitionsPage = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -35,6 +35,7 @@ const Field_site_payment_requisitionsTablesPage = () => {
{ label: 'Department', title: 'department' }, { label: 'Department', title: 'department' },
{ label: 'EmployeeName', title: 'employee_name' }, { label: 'EmployeeName', title: 'employee_name' },
{ label: 'DeparturePlace', title: 'departure_place' }, { label: 'DeparturePlace', title: 'departure_place' },
{ label: 'ArrivalPlace', title: 'arrival_place' },
{ label: 'Requester', title: 'requester' }, { label: 'Requester', title: 'requester' },
{ label: 'Approver', title: 'approver' }, { label: 'Approver', title: 'approver' },
@ -154,16 +155,6 @@ const Field_site_payment_requisitionsTablesPage = () => {
<div className='md:inline-flex items-center ms-auto'> <div className='md:inline-flex items-center ms-auto'>
<div id='delete-rows-button'></div> <div id='delete-rows-button'></div>
</div> </div>
<div className='md:inline-flex items-center ms-auto'>
<Link
href={
'/field_site_payment_requisitions/field_site_payment_requisitions-table'
}
>
Switch to Table
</Link>
</div>
</CardBox> </CardBox>
<CardBox className='mb-6' hasTable> <CardBox className='mb-6' hasTable>

View File

@ -95,14 +95,15 @@ const Field_site_payment_requisitionsNew = () => {
onSubmit={(values) => handleSubmit(values)} onSubmit={(values) => handleSubmit(values)}
> >
<Form> <Form>
<FormField label='Organization' labelFor='organization'>
<Field <Field
name='organization' name='organization'
id='organization' id='organization'
component={SelectField} component={SelectField}
options={[]} options={[]}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'}
></Field> ></Field>
</FormField>
<FormField label='Department'> <FormField label='Department'>
<Field name='department' placeholder='Department' /> <Field name='department' placeholder='Department' />

View File

@ -35,6 +35,7 @@ const Field_site_payment_requisitionsTablesPage = () => {
{ label: 'Department', title: 'department' }, { label: 'Department', title: 'department' },
{ label: 'EmployeeName', title: 'employee_name' }, { label: 'EmployeeName', title: 'employee_name' },
{ label: 'DeparturePlace', title: 'departure_place' }, { label: 'DeparturePlace', title: 'departure_place' },
{ label: 'ArrivalPlace', title: 'arrival_place' },
{ label: 'Requester', title: 'requester' }, { label: 'Requester', title: 'requester' },
{ label: 'Approver', title: 'approver' }, { label: 'Approver', title: 'approver' },
@ -159,7 +160,7 @@ const Field_site_payment_requisitionsTablesPage = () => {
'/field_site_payment_requisitions/field_site_payment_requisitions-list' '/field_site_payment_requisitions/field_site_payment_requisitions-list'
} }
> >
Back to <span className='capitalize'></span> Back to <span className='capitalize'>table</span>
</Link> </Link>
</div> </div>
</CardBox> </CardBox>

View File

@ -65,8 +65,7 @@ const Field_site_payment_requisitionsView = () => {
<p className={'block font-bold mb-2'}>Organization</p> <p className={'block font-bold mb-2'}>Organization</p>
<p> <p>
{field_site_payment_requisitions?.organization?.name ?? {field_site_payment_requisitions?.organization?.id ?? 'No data'}
'No data'}
</p> </p>
</div> </div>
)} )}
@ -113,11 +112,6 @@ const Field_site_payment_requisitionsView = () => {
)} )}
</FormField> </FormField>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>ArrivalPlace</p>
<p>{field_site_payment_requisitions?.arrival_place}</p>
</div>
<FormField label='ReturnDate'> <FormField label='ReturnDate'>
{field_site_payment_requisitions.return_date ? ( {field_site_payment_requisitions.return_date ? (
<DatePicker <DatePicker
@ -212,8 +206,7 @@ const Field_site_payment_requisitionsView = () => {
<p className={'block font-bold mb-2'}>organizations</p> <p className={'block font-bold mb-2'}>organizations</p>
<p> <p>
{field_site_payment_requisitions?.organizations?.name ?? {field_site_payment_requisitions?.organizations?.id ?? 'No data'}
'No data'}
</p> </p>
</div> </div>

View File

@ -126,23 +126,23 @@ const OrganizationsView = () => {
<table> <table>
<thead> <thead>
<tr> <tr>
<th>DocumentNumber</th> <th>Nameofemployee Organization</th>
<th>DocumentType</th> <th>Document Number</th>
<th>PreparedBy</th> <th>Description</th>
<th>Status</th> <th>Date</th>
<th>CashBalance</th> <th>Payment Type</th>
<th>PaymentDate</th>
<th>Amount</th> <th>Amount</th>
<th>ShelfNumber</th> <th>Project Code</th>
<th>ApprovedBy</th> <th>Document Status</th>
<th>Shelf Number</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -157,31 +157,31 @@ const OrganizationsView = () => {
) )
} }
> >
<td data-label='nameofemployee_organization'>
{item.nameofemployee_organization}
</td>
<td data-label='document_number'> <td data-label='document_number'>
{item.document_number} {item.document_number}
</td> </td>
<td data-label='document_type'> <td data-label='description'>{item.description}</td>
{item.document_type}
<td data-label='date'>
{dataFormatter.dateFormatter(item.date)}
</td> </td>
<td data-label='prepared_by'>{item.prepared_by}</td> <td data-label='payment_type'>{item.payment_type}</td>
<td data-label='status'>{item.status}</td> <td data-label='Amount'>{item.Amount}</td>
<td data-label='cash_balance'> <td data-label='project_code'>{item.project_code}</td>
{dataFormatter.booleanFormatter(item.cash_balance)}
<td data-label='document_status'>
{item.document_status}
</td> </td>
<td data-label='payment_date'>
{dataFormatter.dateTimeFormatter(item.payment_date)}
</td>
<td data-label='amount'>{item.amount}</td>
<td data-label='shelf_number'>{item.shelf_number}</td> <td data-label='shelf_number'>{item.shelf_number}</td>
<td data-label='approved_by'>{item.approved_by}</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
@ -213,8 +213,6 @@ const OrganizationsView = () => {
<th>DepartureDate</th> <th>DepartureDate</th>
<th>ArrivalPlace</th>
<th>ReturnDate</th> <th>ReturnDate</th>
<th>RequisitionDate</th> <th>RequisitionDate</th>
@ -263,10 +261,6 @@ const OrganizationsView = () => {
)} )}
</td> </td>
<td data-label='arrival_place'>
{item.arrival_place}
</td>
<td data-label='return_date'> <td data-label='return_date'>
{dataFormatter.dateTimeFormatter( {dataFormatter.dateTimeFormatter(
item.return_date, item.return_date,
@ -327,8 +321,6 @@ const OrganizationsView = () => {
<th>DepartureDate</th> <th>DepartureDate</th>
<th>ArrivalPlace</th>
<th>ReturnDate</th> <th>ReturnDate</th>
<th>RequisitionDate</th> <th>RequisitionDate</th>
@ -377,10 +369,6 @@ const OrganizationsView = () => {
)} )}
</td> </td>
<td data-label='arrival_place'>
{item.arrival_place}
</td>
<td data-label='return_date'> <td data-label='return_date'>
{dataFormatter.dateTimeFormatter( {dataFormatter.dateTimeFormatter(
item.return_date, item.return_date,
@ -558,6 +546,72 @@ const OrganizationsView = () => {
</CardBox> </CardBox>
</> </>
<>
<p className={'block font-bold mb-2'}>Departments organizations</p>
<CardBox
className='mb-6 border border-gray-300 rounded overflow-hidden'
hasTable
>
<div className='overflow-x-auto'>
<table>
<thead>
<tr></tr>
</thead>
<tbody>
{organizations.departments_organizations &&
Array.isArray(organizations.departments_organizations) &&
organizations.departments_organizations.map(
(item: any) => (
<tr
key={item.id}
onClick={() =>
router.push(
`/departments/departments-view/?id=${item.id}`,
)
}
></tr>
),
)}
</tbody>
</table>
</div>
{!organizations?.departments_organizations?.length && (
<div className={'text-center py-4'}>No data</div>
)}
</CardBox>
</>
<>
<p className={'block font-bold mb-2'}>Places organizations</p>
<CardBox
className='mb-6 border border-gray-300 rounded overflow-hidden'
hasTable
>
<div className='overflow-x-auto'>
<table>
<thead>
<tr></tr>
</thead>
<tbody>
{organizations.places_organizations &&
Array.isArray(organizations.places_organizations) &&
organizations.places_organizations.map((item: any) => (
<tr
key={item.id}
onClick={() =>
router.push(`/places/places-view/?id=${item.id}`)
}
></tr>
))}
</tbody>
</table>
</div>
{!organizations?.places_organizations?.length && (
<div className={'text-center py-4'}>No data</div>
)}
</CardBox>
</>
<BaseDivider /> <BaseDivider />
<BaseButton <BaseButton

View File

@ -108,7 +108,7 @@ const EditPayments = () => {
component={SelectField} component={SelectField}
options={initialValues.document} options={initialValues.document}
itemRef={'documents'} itemRef={'documents'}
showField={'document_number'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
@ -148,7 +148,7 @@ const EditPayments = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -106,7 +106,7 @@ const EditPaymentsPage = () => {
component={SelectField} component={SelectField}
options={initialValues.document} options={initialValues.document}
itemRef={'documents'} itemRef={'documents'}
showField={'document_number'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
@ -146,7 +146,7 @@ const EditPaymentsPage = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -61,7 +61,7 @@ const PaymentsView = () => {
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Document</p> <p className={'block font-bold mb-2'}>Document</p>
<p>{payments?.document?.document_number ?? 'No data'}</p> <p>{payments?.document?.id ?? 'No data'}</p>
</div> </div>
<FormField label='PaymentDate'> <FormField label='PaymentDate'>
@ -94,7 +94,7 @@ const PaymentsView = () => {
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>organizations</p> <p className={'block font-bold mb-2'}>organizations</p>
<p>{payments?.organizations?.name ?? 'No data'}</p> <p>{payments?.organizations?.id ?? 'No data'}</p>
</div> </div>
<BaseDivider /> <BaseDivider />

View File

@ -0,0 +1,135 @@
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js';
import Head from 'next/head';
import React, { ReactElement, useEffect, useState } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import dayjs from 'dayjs';
import CardBox from '../../components/CardBox';
import LayoutAuthenticated from '../../layouts/Authenticated';
import SectionMain from '../../components/SectionMain';
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
import { getPageTitle } from '../../config';
import { Field, Form, Formik } from 'formik';
import FormField from '../../components/FormField';
import BaseDivider from '../../components/BaseDivider';
import BaseButtons from '../../components/BaseButtons';
import BaseButton from '../../components/BaseButton';
import FormCheckRadio from '../../components/FormCheckRadio';
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
import FormFilePicker from '../../components/FormFilePicker';
import FormImagePicker from '../../components/FormImagePicker';
import { SelectField } from '../../components/SelectField';
import { SelectFieldMany } from '../../components/SelectFieldMany';
import { SwitchField } from '../../components/SwitchField';
import { RichTextField } from '../../components/RichTextField';
import { update, fetch } from '../../stores/places/placesSlice';
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
import { useRouter } from 'next/router';
import { saveFile } from '../../helpers/fileSaver';
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from '../../components/ImageField';
import { hasPermission } from '../../helpers/userPermissions';
const EditPlaces = () => {
const router = useRouter();
const dispatch = useAppDispatch();
const initVals = {
organizations: null,
};
const [initialValues, setInitialValues] = useState(initVals);
const { places } = useAppSelector((state) => state.places);
const { currentUser } = useAppSelector((state) => state.auth);
const { placesId } = router.query;
useEffect(() => {
dispatch(fetch({ id: placesId }));
}, [placesId]);
useEffect(() => {
if (typeof places === 'object') {
setInitialValues(places);
}
}, [places]);
useEffect(() => {
if (typeof places === 'object') {
const newInitialVal = { ...initVals };
Object.keys(initVals).forEach((el) => (newInitialVal[el] = places[el]));
setInitialValues(newInitialVal);
}
}, [places]);
const handleSubmit = async (data) => {
await dispatch(update({ id: placesId, data }));
await router.push('/places/places-list');
};
return (
<>
<Head>
<title>{getPageTitle('Edit places')}</title>
</Head>
<SectionMain>
<SectionTitleLineWithButton
icon={mdiChartTimelineVariant}
title={'Edit places'}
main
>
{''}
</SectionTitleLineWithButton>
<CardBox>
<Formik
enableReinitialize
initialValues={initialValues}
onSubmit={(values) => handleSubmit(values)}
>
<Form>
<FormField label='organizations' labelFor='organizations'>
<Field
name='organizations'
id='organizations'
component={SelectField}
options={initialValues.organizations}
itemRef={'organizations'}
showField={'id'}
></Field>
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />
<BaseButton type='reset' color='info' outline label='Reset' />
<BaseButton
type='reset'
color='danger'
outline
label='Cancel'
onClick={() => router.push('/places/places-list')}
/>
</BaseButtons>
</Form>
</Formik>
</CardBox>
</SectionMain>
</>
);
};
EditPlaces.getLayout = function getLayout(page: ReactElement) {
return (
<LayoutAuthenticated permission={'UPDATE_PLACES'}>
{page}
</LayoutAuthenticated>
);
};
export default EditPlaces;

View File

@ -0,0 +1,133 @@
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js';
import Head from 'next/head';
import React, { ReactElement, useEffect, useState } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import dayjs from 'dayjs';
import CardBox from '../../components/CardBox';
import LayoutAuthenticated from '../../layouts/Authenticated';
import SectionMain from '../../components/SectionMain';
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
import { getPageTitle } from '../../config';
import { Field, Form, Formik } from 'formik';
import FormField from '../../components/FormField';
import BaseDivider from '../../components/BaseDivider';
import BaseButtons from '../../components/BaseButtons';
import BaseButton from '../../components/BaseButton';
import FormCheckRadio from '../../components/FormCheckRadio';
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
import FormFilePicker from '../../components/FormFilePicker';
import FormImagePicker from '../../components/FormImagePicker';
import { SelectField } from '../../components/SelectField';
import { SelectFieldMany } from '../../components/SelectFieldMany';
import { SwitchField } from '../../components/SwitchField';
import { RichTextField } from '../../components/RichTextField';
import { update, fetch } from '../../stores/places/placesSlice';
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
import { useRouter } from 'next/router';
import { saveFile } from '../../helpers/fileSaver';
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from '../../components/ImageField';
import { hasPermission } from '../../helpers/userPermissions';
const EditPlacesPage = () => {
const router = useRouter();
const dispatch = useAppDispatch();
const initVals = {
organizations: null,
};
const [initialValues, setInitialValues] = useState(initVals);
const { places } = useAppSelector((state) => state.places);
const { currentUser } = useAppSelector((state) => state.auth);
const { id } = router.query;
useEffect(() => {
dispatch(fetch({ id: id }));
}, [id]);
useEffect(() => {
if (typeof places === 'object') {
setInitialValues(places);
}
}, [places]);
useEffect(() => {
if (typeof places === 'object') {
const newInitialVal = { ...initVals };
Object.keys(initVals).forEach((el) => (newInitialVal[el] = places[el]));
setInitialValues(newInitialVal);
}
}, [places]);
const handleSubmit = async (data) => {
await dispatch(update({ id: id, data }));
await router.push('/places/places-list');
};
return (
<>
<Head>
<title>{getPageTitle('Edit places')}</title>
</Head>
<SectionMain>
<SectionTitleLineWithButton
icon={mdiChartTimelineVariant}
title={'Edit places'}
main
>
{''}
</SectionTitleLineWithButton>
<CardBox>
<Formik
enableReinitialize
initialValues={initialValues}
onSubmit={(values) => handleSubmit(values)}
>
<Form>
<FormField label='organizations' labelFor='organizations'>
<Field
name='organizations'
id='organizations'
component={SelectField}
options={initialValues.organizations}
itemRef={'organizations'}
showField={'id'}
></Field>
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />
<BaseButton type='reset' color='info' outline label='Reset' />
<BaseButton
type='reset'
color='danger'
outline
label='Cancel'
onClick={() => router.push('/places/places-list')}
/>
</BaseButtons>
</Form>
</Formik>
</CardBox>
</SectionMain>
</>
);
};
EditPlacesPage.getLayout = function getLayout(page: ReactElement) {
return (
<LayoutAuthenticated permission={'UPDATE_PLACES'}>
{page}
</LayoutAuthenticated>
);
};
export default EditPlacesPage;

View File

@ -0,0 +1,86 @@
import React, { ReactElement, useEffect } from 'react';
import Head from 'next/head';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import dayjs from 'dayjs';
import { useAppDispatch, useAppSelector } from '../../stores/hooks';
import { useRouter } from 'next/router';
import { fetch } from '../../stores/places/placesSlice';
import { saveFile } from '../../helpers/fileSaver';
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from '../../components/ImageField';
import LayoutAuthenticated from '../../layouts/Authenticated';
import { getPageTitle } from '../../config';
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
import SectionMain from '../../components/SectionMain';
import CardBox from '../../components/CardBox';
import BaseButton from '../../components/BaseButton';
import BaseDivider from '../../components/BaseDivider';
import { mdiChartTimelineVariant } from '@mdi/js';
import { SwitchField } from '../../components/SwitchField';
import FormField from '../../components/FormField';
import { hasPermission } from '../../helpers/userPermissions';
const PlacesView = () => {
const router = useRouter();
const dispatch = useAppDispatch();
const { places } = useAppSelector((state) => state.places);
const { currentUser } = useAppSelector((state) => state.auth);
const { id } = router.query;
function removeLastCharacter(str) {
console.log(str, `str`);
return str.slice(0, -1);
}
useEffect(() => {
dispatch(fetch({ id }));
}, [dispatch, id]);
return (
<>
<Head>
<title>{getPageTitle('View places')}</title>
</Head>
<SectionMain>
<SectionTitleLineWithButton
icon={mdiChartTimelineVariant}
title={removeLastCharacter('View places')}
main
>
<BaseButton
color='info'
label='Edit'
href={`/places/places-edit/?id=${id}`}
/>
</SectionTitleLineWithButton>
<CardBox>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>organizations</p>
<p>{places?.organizations?.id ?? 'No data'}</p>
</div>
<BaseDivider />
<BaseButton
color='info'
label='Back'
onClick={() => router.push('/places/places-list')}
/>
</CardBox>
</SectionMain>
</>
);
};
PlacesView.getLayout = function getLayout(page: ReactElement) {
return (
<LayoutAuthenticated permission={'READ_PLACES'}>{page}</LayoutAuthenticated>
);
};
export default PlacesView;

View File

@ -129,7 +129,7 @@ const EditProjects = () => {
component={SelectField} component={SelectField}
options={initialValues.organization} options={initialValues.organization}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
)} )}
@ -141,7 +141,7 @@ const EditProjects = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -127,7 +127,7 @@ const EditProjectsPage = () => {
component={SelectField} component={SelectField}
options={initialValues.organization} options={initialValues.organization}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>
)} )}
@ -139,7 +139,7 @@ const EditProjectsPage = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -77,93 +77,16 @@ const ProjectsView = () => {
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Organization</p> <p className={'block font-bold mb-2'}>Organization</p>
<p>{projects?.organization?.name ?? 'No data'}</p> <p>{projects?.organization?.id ?? 'No data'}</p>
</div> </div>
)} )}
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>organizations</p> <p className={'block font-bold mb-2'}>organizations</p>
<p>{projects?.organizations?.name ?? 'No data'}</p> <p>{projects?.organizations?.id ?? 'No data'}</p>
</div> </div>
<>
<p className={'block font-bold mb-2'}>Documents Project</p>
<CardBox
className='mb-6 border border-gray-300 rounded overflow-hidden'
hasTable
>
<div className='overflow-x-auto'>
<table>
<thead>
<tr>
<th>DocumentNumber</th>
<th>DocumentType</th>
<th>PreparedBy</th>
<th>Status</th>
<th>CashBalance</th>
<th>PaymentDate</th>
<th>Amount</th>
<th>ShelfNumber</th>
<th>ApprovedBy</th>
</tr>
</thead>
<tbody>
{projects.documents_project &&
Array.isArray(projects.documents_project) &&
projects.documents_project.map((item: any) => (
<tr
key={item.id}
onClick={() =>
router.push(
`/documents/documents-view/?id=${item.id}`,
)
}
>
<td data-label='document_number'>
{item.document_number}
</td>
<td data-label='document_type'>
{item.document_type}
</td>
<td data-label='prepared_by'>{item.prepared_by}</td>
<td data-label='status'>{item.status}</td>
<td data-label='cash_balance'>
{dataFormatter.booleanFormatter(item.cash_balance)}
</td>
<td data-label='payment_date'>
{dataFormatter.dateTimeFormatter(item.payment_date)}
</td>
<td data-label='amount'>{item.amount}</td>
<td data-label='shelf_number'>{item.shelf_number}</td>
<td data-label='approved_by'>{item.approved_by}</td>
</tr>
))}
</tbody>
</table>
</div>
{!projects?.documents_project?.length && (
<div className={'text-center py-4'}>No data</div>
)}
</CardBox>
</>
<> <>
<p className={'block font-bold mb-2'}> <p className={'block font-bold mb-2'}>
Field_site_payment_requisitions Project Field_site_payment_requisitions Project
@ -184,8 +107,6 @@ const ProjectsView = () => {
<th>DepartureDate</th> <th>DepartureDate</th>
<th>ArrivalPlace</th>
<th>ReturnDate</th> <th>ReturnDate</th>
<th>RequisitionDate</th> <th>RequisitionDate</th>
@ -234,10 +155,6 @@ const ProjectsView = () => {
)} )}
</td> </td>
<td data-label='arrival_place'>
{item.arrival_place}
</td>
<td data-label='return_date'> <td data-label='return_date'>
{dataFormatter.dateTimeFormatter( {dataFormatter.dateTimeFormatter(
item.return_date, item.return_date,

View File

@ -183,7 +183,7 @@ const EditUsers = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -181,7 +181,7 @@ const EditUsersPage = () => {
component={SelectField} component={SelectField}
options={initialValues.organizations} options={initialValues.organizations}
itemRef={'organizations'} itemRef={'organizations'}
showField={'name'} showField={'id'}
></Field> ></Field>
</FormField> </FormField>

View File

@ -145,7 +145,7 @@ const UsersView = () => {
<div className={'mb-4'}> <div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Organizations</p> <p className={'block font-bold mb-2'}>Organizations</p>
<p>{users?.organizations?.name ?? 'No data'}</p> <p>{users?.organizations?.id ?? 'No data'}</p>
</div> </div>
<BaseDivider /> <BaseDivider />

View File

@ -77,7 +77,7 @@ export default function WebSite() {
<FeaturesSection <FeaturesSection
projectName={'Nimona E-filling System'} projectName={'Nimona E-filling System'}
image={['Dashboard showcasing CRM features']} image={['Dashboard showcasing CRM features']}
withBg={0} withBg={1}
features={features_points} features={features_points}
mainText={`Unlock Efficiency with Gojo CRM Features`} mainText={`Unlock Efficiency with Gojo CRM Features`}
subTitle={`Explore the powerful features of ${projectName} designed to streamline your law firm's operations and enhance productivity.`} subTitle={`Explore the powerful features of ${projectName} designed to streamline your law firm's operations and enhance productivity.`}

View File

@ -115,7 +115,7 @@ export default function WebSite() {
<FeaturesSection <FeaturesSection
projectName={'Nimona E-filling System'} projectName={'Nimona E-filling System'}
image={['Feature-rich CRM dashboard view']} image={['Feature-rich CRM dashboard view']}
withBg={1} withBg={0}
features={features_points} features={features_points}
mainText={`Discover the Power of Gojo CRM`} mainText={`Discover the Power of Gojo CRM`}
subTitle={`Explore the robust features of ${projectName} that are designed to elevate your law firm's efficiency and client management capabilities.`} subTitle={`Explore the robust features of ${projectName} that are designed to elevate your law firm's efficiency and client management capabilities.`}

View File

@ -11,6 +11,8 @@ import paymentsSlice from './payments/paymentsSlice';
import projectsSlice from './projects/projectsSlice'; import projectsSlice from './projects/projectsSlice';
import rolesSlice from './roles/rolesSlice'; import rolesSlice from './roles/rolesSlice';
import permissionsSlice from './permissions/permissionsSlice'; import permissionsSlice from './permissions/permissionsSlice';
import departmentsSlice from './departments/departmentsSlice';
import placesSlice from './places/placesSlice';
import organizationsSlice from './organizations/organizationsSlice'; import organizationsSlice from './organizations/organizationsSlice';
export const store = configureStore({ export const store = configureStore({
@ -27,6 +29,8 @@ export const store = configureStore({
projects: projectsSlice, projects: projectsSlice,
roles: rolesSlice, roles: rolesSlice,
permissions: permissionsSlice, permissions: permissionsSlice,
departments: departmentsSlice,
places: placesSlice,
organizations: organizationsSlice, organizations: organizationsSlice,
}, },
}); });