Updated via schema editor on 2025-06-19 01:30
This commit is contained in:
parent
a74660b879
commit
da7c3a9bf4
File diff suppressed because one or more lines are too long
@ -18,6 +18,7 @@ module.exports = class UnitsDBApi {
|
|||||||
unit_number: data.unit_number || null,
|
unit_number: data.unit_number || null,
|
||||||
balance: data.balance || null,
|
balance: data.balance || null,
|
||||||
unit_factor: data.unit_factor || null,
|
unit_factor: data.unit_factor || null,
|
||||||
|
cond_fee: data.cond_fee || null,
|
||||||
importHash: data.importHash || null,
|
importHash: data.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -43,6 +44,7 @@ module.exports = class UnitsDBApi {
|
|||||||
unit_number: item.unit_number || null,
|
unit_number: item.unit_number || null,
|
||||||
balance: item.balance || null,
|
balance: item.balance || null,
|
||||||
unit_factor: item.unit_factor || null,
|
unit_factor: item.unit_factor || null,
|
||||||
|
cond_fee: item.cond_fee || null,
|
||||||
importHash: item.importHash || null,
|
importHash: item.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -73,6 +75,8 @@ module.exports = class UnitsDBApi {
|
|||||||
if (data.unit_factor !== undefined)
|
if (data.unit_factor !== undefined)
|
||||||
updatePayload.unit_factor = data.unit_factor;
|
updatePayload.unit_factor = data.unit_factor;
|
||||||
|
|
||||||
|
if (data.cond_fee !== undefined) updatePayload.cond_fee = data.cond_fee;
|
||||||
|
|
||||||
updatePayload.updatedById = currentUser.id;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await units.update(updatePayload, { transaction });
|
await units.update(updatePayload, { transaction });
|
||||||
@ -262,6 +266,30 @@ module.exports = class UnitsDBApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.cond_feeRange) {
|
||||||
|
const [start, end] = filter.cond_feeRange;
|
||||||
|
|
||||||
|
if (start !== undefined && start !== null && start !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
cond_fee: {
|
||||||
|
...where.cond_fee,
|
||||||
|
[Op.gte]: start,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end !== undefined && end !== null && end !== '') {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
cond_fee: {
|
||||||
|
...where.cond_fee,
|
||||||
|
[Op.lte]: end,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (filter.active !== undefined) {
|
if (filter.active !== undefined) {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
|
|||||||
47
backend/src/db/migrations/1750296611399.js
Normal file
47
backend/src/db/migrations/1750296611399.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
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(
|
||||||
|
'units',
|
||||||
|
'cond_fee',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
{ 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('units', 'cond_fee', { transaction });
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -26,6 +26,10 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
type: DataTypes.INTEGER,
|
type: DataTypes.INTEGER,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cond_fee: {
|
||||||
|
type: DataTypes.DECIMAL,
|
||||||
|
},
|
||||||
|
|
||||||
importHash: {
|
importHash: {
|
||||||
type: DataTypes.STRING(255),
|
type: DataTypes.STRING(255),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
|
|||||||
@ -95,7 +95,7 @@ const MaintenanceRequestsData = [
|
|||||||
|
|
||||||
description: 'Broken window in living room',
|
description: 'Broken window in living room',
|
||||||
|
|
||||||
status: 'in_progress',
|
status: 'pending',
|
||||||
|
|
||||||
request_date: new Date('2023-09-25T14:30:00Z'),
|
request_date: new Date('2023-09-25T14:30:00Z'),
|
||||||
},
|
},
|
||||||
@ -172,6 +172,8 @@ const UnitsData = [
|
|||||||
balance: 250,
|
balance: 250,
|
||||||
|
|
||||||
unit_factor: 3,
|
unit_factor: 3,
|
||||||
|
|
||||||
|
cond_fee: 53.45,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -181,7 +183,9 @@ const UnitsData = [
|
|||||||
|
|
||||||
balance: 0,
|
balance: 0,
|
||||||
|
|
||||||
unit_factor: 7,
|
unit_factor: 4,
|
||||||
|
|
||||||
|
cond_fee: 82.56,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -191,7 +195,9 @@ const UnitsData = [
|
|||||||
|
|
||||||
balance: 150,
|
balance: 150,
|
||||||
|
|
||||||
unit_factor: 8,
|
unit_factor: 3,
|
||||||
|
|
||||||
|
cond_fee: 49.53,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -201,7 +207,9 @@ const UnitsData = [
|
|||||||
|
|
||||||
balance: 0,
|
balance: 0,
|
||||||
|
|
||||||
unit_factor: 6,
|
unit_factor: 5,
|
||||||
|
|
||||||
|
cond_fee: 95.34,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,9 @@ router.use(checkCrudPermissions('units'));
|
|||||||
* balance:
|
* balance:
|
||||||
* type: integer
|
* type: integer
|
||||||
* format: int64
|
* format: int64
|
||||||
|
* cond_fee:
|
||||||
|
* type: integer
|
||||||
|
* format: int64
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -307,7 +310,13 @@ router.get(
|
|||||||
const currentUser = req.currentUser;
|
const currentUser = req.currentUser;
|
||||||
const payload = await UnitsDBApi.findAll(req.query, { currentUser });
|
const payload = await UnitsDBApi.findAll(req.query, { currentUser });
|
||||||
if (filetype && filetype === 'csv') {
|
if (filetype && filetype === 'csv') {
|
||||||
const fields = ['id', 'unit_number', 'unit_factor', 'balance'];
|
const fields = [
|
||||||
|
'id',
|
||||||
|
'unit_number',
|
||||||
|
'unit_factor',
|
||||||
|
'balance',
|
||||||
|
'cond_fee',
|
||||||
|
];
|
||||||
const opts = { fields };
|
const opts = { fields };
|
||||||
try {
|
try {
|
||||||
const csv = parse(payload.rows, opts);
|
const csv = parse(payload.rows, opts);
|
||||||
|
|||||||
@ -54,7 +54,7 @@ module.exports = class SearchService {
|
|||||||
const columnsInt = {
|
const columnsInt = {
|
||||||
budgets: ['year', 'total_budget', 'expenses'],
|
budgets: ['year', 'total_budget', 'expenses'],
|
||||||
|
|
||||||
units: ['balance', 'unit_factor'],
|
units: ['balance', 'unit_factor', 'cond_fee'],
|
||||||
};
|
};
|
||||||
|
|
||||||
let allFoundRecords = [];
|
let allFoundRecords = [];
|
||||||
|
|||||||
@ -117,6 +117,17 @@ const CardUnits = ({
|
|||||||
</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'>
|
||||||
|
Cond Fee
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.cond_fee}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -72,6 +72,11 @@ const ListUnits = ({
|
|||||||
<p className={'text-xs text-gray-500 '}>Unit Factor</p>
|
<p className={'text-xs text-gray-500 '}>Unit Factor</p>
|
||||||
<p className={'line-clamp-2'}>{item.unit_factor}</p>
|
<p className={'line-clamp-2'}>{item.unit_factor}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Cond Fee</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.cond_fee}</p>
|
||||||
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
|
|||||||
@ -98,6 +98,20 @@ export const loadColumns = async (
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'cond_fee',
|
||||||
|
headerName: 'Cond Fee',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'actions',
|
field: 'actions',
|
||||||
type: 'actions',
|
type: 'actions',
|
||||||
|
|||||||
@ -43,6 +43,8 @@ const EditUnits = () => {
|
|||||||
balance: '',
|
balance: '',
|
||||||
|
|
||||||
unit_factor: '',
|
unit_factor: '',
|
||||||
|
|
||||||
|
cond_fee: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -122,6 +124,10 @@ const EditUnits = () => {
|
|||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Cond Fee'>
|
||||||
|
<Field type='number' name='cond_fee' placeholder='Cond Fee' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -43,6 +43,8 @@ const EditUnitsPage = () => {
|
|||||||
balance: '',
|
balance: '',
|
||||||
|
|
||||||
unit_factor: '',
|
unit_factor: '',
|
||||||
|
|
||||||
|
cond_fee: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -120,6 +122,10 @@ const EditUnitsPage = () => {
|
|||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Cond Fee'>
|
||||||
|
<Field type='number' name='cond_fee' placeholder='Cond Fee' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -32,6 +32,7 @@ const UnitsTablesPage = () => {
|
|||||||
{ label: 'UnitNumber', title: 'unit_number' },
|
{ label: 'UnitNumber', title: 'unit_number' },
|
||||||
{ label: 'Unit Factor', title: 'unit_factor', number: 'true' },
|
{ label: 'Unit Factor', title: 'unit_factor', number: 'true' },
|
||||||
{ label: 'Balance', title: 'balance', number: 'true' },
|
{ label: 'Balance', title: 'balance', number: 'true' },
|
||||||
|
{ label: 'Cond Fee', title: 'cond_fee', number: 'true' },
|
||||||
|
|
||||||
{ label: 'Owner', title: 'owner' },
|
{ label: 'Owner', title: 'owner' },
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -40,6 +40,8 @@ const initialValues = {
|
|||||||
balance: '',
|
balance: '',
|
||||||
|
|
||||||
unit_factor: '',
|
unit_factor: '',
|
||||||
|
|
||||||
|
cond_fee: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const UnitsNew = () => {
|
const UnitsNew = () => {
|
||||||
@ -95,6 +97,10 @@ const UnitsNew = () => {
|
|||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Cond Fee'>
|
||||||
|
<Field type='number' name='cond_fee' placeholder='Cond Fee' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -32,6 +32,7 @@ const UnitsTablesPage = () => {
|
|||||||
{ label: 'UnitNumber', title: 'unit_number' },
|
{ label: 'UnitNumber', title: 'unit_number' },
|
||||||
{ label: 'Unit Factor', title: 'unit_factor', number: 'true' },
|
{ label: 'Unit Factor', title: 'unit_factor', number: 'true' },
|
||||||
{ label: 'Balance', title: 'balance', number: 'true' },
|
{ label: 'Balance', title: 'balance', number: 'true' },
|
||||||
|
{ label: 'Cond Fee', title: 'cond_fee', number: 'true' },
|
||||||
|
|
||||||
{ label: 'Owner', title: 'owner' },
|
{ label: 'Owner', title: 'owner' },
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -75,6 +75,11 @@ const UnitsView = () => {
|
|||||||
<p>{units?.unit_factor || 'No data'}</p>
|
<p>{units?.unit_factor || 'No data'}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Cond Fee</p>
|
||||||
|
<p>{units?.cond_fee || 'No data'}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<>
|
<>
|
||||||
<p className={'block font-bold mb-2'}>Maintenance_requests Unit</p>
|
<p className={'block font-bold mb-2'}>Maintenance_requests Unit</p>
|
||||||
<CardBox
|
<CardBox
|
||||||
|
|||||||
@ -153,6 +153,8 @@ const UsersView = () => {
|
|||||||
<th>Balance</th>
|
<th>Balance</th>
|
||||||
|
|
||||||
<th>Unit Factor</th>
|
<th>Unit Factor</th>
|
||||||
|
|
||||||
|
<th>Cond Fee</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -170,6 +172,8 @@ const UsersView = () => {
|
|||||||
<td data-label='balance'>{item.balance}</td>
|
<td data-label='balance'>{item.balance}</td>
|
||||||
|
|
||||||
<td data-label='unit_factor'>{item.unit_factor}</td>
|
<td data-label='unit_factor'>{item.unit_factor}</td>
|
||||||
|
|
||||||
|
<td data-label='cond_fee'>{item.cond_fee}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user