diff --git a/handlers/lotOccupancies-post/doSearchLotOccupancies.js b/handlers/lotOccupancies-post/doSearchLotOccupancies.js index a990ea1e..ced835e7 100644 --- a/handlers/lotOccupancies-post/doSearchLotOccupancies.js +++ b/handlers/lotOccupancies-post/doSearchLotOccupancies.js @@ -3,7 +3,9 @@ export async function handler(request, response) { const result = await getLotOccupancies(request.body, { limit: request.body.limit, offset: request.body.offset, - includeOccupants: true + includeOccupants: true, + includeFees: true, + includeTransactions: true }); response.json({ count: result.count, diff --git a/handlers/lotOccupancies-post/doSearchLotOccupancies.ts b/handlers/lotOccupancies-post/doSearchLotOccupancies.ts index 15494c17..06c903c9 100644 --- a/handlers/lotOccupancies-post/doSearchLotOccupancies.ts +++ b/handlers/lotOccupancies-post/doSearchLotOccupancies.ts @@ -9,7 +9,9 @@ export async function handler( const result = await getLotOccupancies(request.body, { limit: request.body.limit, offset: request.body.offset, - includeOccupants: true + includeOccupants: true, + includeFees: true, + includeTransactions: true }) response.json({ diff --git a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js index 8384cd73..00fd4596 100644 --- a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js +++ b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js @@ -10,7 +10,9 @@ export async function handler(request, response) { }, { limit: -1, offset: 0, - includeOccupants: true + includeOccupants: true, + includeFees: false, + includeTransactions: false }); response.json({ success, diff --git a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts index fce33b81..f11c1525 100644 --- a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts +++ b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts @@ -22,7 +22,9 @@ export async function handler( { limit: -1, offset: 0, - includeOccupants: true + includeOccupants: true, + includeFees: false, + includeTransactions: false } ) diff --git a/helpers/lotOccupancyDB/getFees.js b/helpers/lotOccupancyDB/getFees.js index 3883caaa..bc40a867 100644 --- a/helpers/lotOccupancyDB/getFees.js +++ b/helpers/lotOccupancyDB/getFees.js @@ -18,7 +18,8 @@ export async function getFees(feeCategoryId, additionalFilters, connectedDatabas .prepare(`select f.feeId, f.feeName, f.feeDescription, f.occupancyTypeId, o.occupancyType, f.lotTypeId, l.lotType, - ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction, + ifnull(f.feeAmount, 0) as feeAmount, + f.feeFunction, f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber, diff --git a/helpers/lotOccupancyDB/getFees.ts b/helpers/lotOccupancyDB/getFees.ts index de67997f..7e0680b8 100644 --- a/helpers/lotOccupancyDB/getFees.ts +++ b/helpers/lotOccupancyDB/getFees.ts @@ -44,7 +44,8 @@ export async function getFees( `select f.feeId, f.feeName, f.feeDescription, f.occupancyTypeId, o.occupancyType, f.lotTypeId, l.lotType, - ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction, + ifnull(f.feeAmount, 0) as feeAmount, + f.feeFunction, f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber, diff --git a/helpers/lotOccupancyDB/getLot.js b/helpers/lotOccupancyDB/getLot.js index 2a36fc37..c7b6efdc 100644 --- a/helpers/lotOccupancyDB/getLot.js +++ b/helpers/lotOccupancyDB/getLot.js @@ -18,6 +18,8 @@ async function _getLot(sql, lotIdOrLotName) { lotId: lot.lotId }, { includeOccupants: true, + includeFees: false, + includeTransactions: false, limit: -1, offset: 0 }, database); diff --git a/helpers/lotOccupancyDB/getLot.ts b/helpers/lotOccupancyDB/getLot.ts index 2ea4023a..d2a031d4 100644 --- a/helpers/lotOccupancyDB/getLot.ts +++ b/helpers/lotOccupancyDB/getLot.ts @@ -32,6 +32,8 @@ async function _getLot( }, { includeOccupants: true, + includeFees: false, + includeTransactions: false, limit: -1, offset: 0 }, diff --git a/helpers/lotOccupancyDB/getLotOccupancies.d.ts b/helpers/lotOccupancyDB/getLotOccupancies.d.ts index 43660d41..bf117c42 100644 --- a/helpers/lotOccupancyDB/getLotOccupancies.d.ts +++ b/helpers/lotOccupancyDB/getLotOccupancies.d.ts @@ -18,6 +18,8 @@ interface GetLotOccupanciesOptions { limit: -1 | number; offset: number; includeOccupants: boolean; + includeFees: boolean; + includeTransactions: boolean; } export declare function getLotOccupancies(filters: GetLotOccupanciesFilters, options: GetLotOccupanciesOptions, connectedDatabase?: PoolConnection): Promise<{ count: number; diff --git a/helpers/lotOccupancyDB/getLotOccupancies.js b/helpers/lotOccupancyDB/getLotOccupancies.js index f45c3c29..a53b89ba 100644 --- a/helpers/lotOccupancyDB/getLotOccupancies.js +++ b/helpers/lotOccupancyDB/getLotOccupancies.js @@ -4,6 +4,8 @@ import * as configFunctions from '../functions.config.js'; import { getOccupancyTypeById } from '../functions.cache.js'; import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'; import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../functions.sqlFilters.js'; +import getLotOccupancyFees from './getLotOccupancyFees.js'; +import getLotOccupancyTransactions from './getLotOccupancyTransactions.js'; function buildWhereClause(filters) { let sqlWhereClause = ' where o.recordDelete_timeMillis is null'; const sqlParameters = []; @@ -103,6 +105,13 @@ export async function getLotOccupancies(filters, options, connectedDatabase) { ? configFunctions.getProperty('settings.lotOccupancy.prints')[0] : occupancyType.occupancyTypePrints[0]; } + if (options.includeFees) { + lotOccupancy.lotOccupancyFees = await getLotOccupancyFees(lotOccupancy.lotOccupancyId, database); + } + if (options.includeTransactions) { + lotOccupancy.lotOccupancyTransactions = + await getLotOccupancyTransactions(lotOccupancy.lotOccupancyId, database); + } if (options.includeOccupants) { lotOccupancy.lotOccupancyOccupants = await getLotOccupancyOccupants(lotOccupancy.lotOccupancyId, database); } diff --git a/helpers/lotOccupancyDB/getLotOccupancies.ts b/helpers/lotOccupancyDB/getLotOccupancies.ts index ed789cbe..a7b7a35a 100644 --- a/helpers/lotOccupancyDB/getLotOccupancies.ts +++ b/helpers/lotOccupancyDB/getLotOccupancies.ts @@ -19,6 +19,8 @@ import { getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../functions.sqlFilters.js' +import getLotOccupancyFees from './getLotOccupancyFees.js' +import getLotOccupancyTransactions from './getLotOccupancyTransactions.js' interface GetLotOccupanciesFilters { lotId?: number | string @@ -39,6 +41,8 @@ interface GetLotOccupanciesOptions { limit: -1 | number offset: number includeOccupants: boolean + includeFees: boolean + includeTransactions: boolean } function buildWhereClause(filters: GetLotOccupanciesFilters): { @@ -192,6 +196,21 @@ export async function getLotOccupancies( : occupancyType.occupancyTypePrints![0] } + if (options.includeFees) { + lotOccupancy.lotOccupancyFees = await getLotOccupancyFees( + lotOccupancy.lotOccupancyId!, + database + ) + } + + if (options.includeTransactions) { + lotOccupancy.lotOccupancyTransactions = + await getLotOccupancyTransactions( + lotOccupancy.lotOccupancyId!, + database + ) + } + if (options.includeOccupants) { lotOccupancy.lotOccupancyOccupants = await getLotOccupancyOccupants( lotOccupancy.lotOccupancyId!, diff --git a/public-typescript/lotOccupancySearch.js b/public-typescript/lotOccupancySearch.js index 2d140ec3..054ed93c 100644 --- a/public-typescript/lotOccupancySearch.js +++ b/public-typescript/lotOccupancySearch.js @@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const limit = Number.parseInt(document.querySelector('#searchFilter--limit').value, 10); const offsetElement = document.querySelector('#searchFilter--offset'); function renderLotOccupancies(responseJSON) { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; if (responseJSON.lotOccupancies.length === 0) { searchResultsContainerElement.innerHTML = `