include lotOccupancyFeeCount
parent
7467fd9609
commit
e40b86f15e
|
|
@ -19,18 +19,25 @@ export function getFees(feeCategoryId, additionalFilters, connectedDatabase) {
|
||||||
sqlParameters.push(additionalFilters.lotTypeId);
|
sqlParameters.push(additionalFilters.lotTypeId);
|
||||||
}
|
}
|
||||||
const fees = database
|
const fees = database
|
||||||
.prepare('select f.feeId, f.feeName, f.feeDescription,' +
|
.prepare(`select f.feeId, f.feeName, f.feeDescription,
|
||||||
' f.occupancyTypeId, o.occupancyType,' +
|
f.occupancyTypeId, o.occupancyType,
|
||||||
' f.lotTypeId, l.lotType,' +
|
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.taxAmount, f.taxPercentage,
|
||||||
' f.includeQuantity, f.quantityUnit,' +
|
f.includeQuantity, f.quantityUnit,
|
||||||
' f.isRequired, f.orderNumber' +
|
f.isRequired, f.orderNumber,
|
||||||
' from Fees f' +
|
ifnull(lo.lotOccupancyFeeCount, 0) as lotOccupancyFeeCount
|
||||||
' left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId' +
|
from Fees f
|
||||||
' left join LotTypes l on f.lotTypeId = l.lotTypeId' +
|
left join (
|
||||||
sqlWhereClause +
|
select feeId, count(lotOccupancyId) as lotOccupancyFeeCount
|
||||||
' order by f.orderNumber, f.feeName')
|
from LotOccupancyFees
|
||||||
|
where recordDelete_timeMillis is null
|
||||||
|
group by feeId
|
||||||
|
) lo on f.feeId = lo.feeId
|
||||||
|
left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId
|
||||||
|
left join LotTypes l on f.lotTypeId = l.lotTypeId
|
||||||
|
${sqlWhereClause}
|
||||||
|
order by f.orderNumber, f.feeName`)
|
||||||
.all(sqlParameters);
|
.all(sqlParameters);
|
||||||
if (updateOrderNumbers) {
|
if (updateOrderNumbers) {
|
||||||
let expectedOrderNumber = 0;
|
let expectedOrderNumber = 0;
|
||||||
|
|
|
||||||
|
|
@ -44,20 +44,27 @@ export function getFees(
|
||||||
sqlParameters.push(additionalFilters.lotTypeId)
|
sqlParameters.push(additionalFilters.lotTypeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fees = database
|
const fees: recordTypes.Fee[] = database
|
||||||
.prepare(
|
.prepare(
|
||||||
'select f.feeId, f.feeName, f.feeDescription,' +
|
`select f.feeId, f.feeName, f.feeDescription,
|
||||||
' f.occupancyTypeId, o.occupancyType,' +
|
f.occupancyTypeId, o.occupancyType,
|
||||||
' f.lotTypeId, l.lotType,' +
|
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.taxAmount, f.taxPercentage,
|
||||||
' f.includeQuantity, f.quantityUnit,' +
|
f.includeQuantity, f.quantityUnit,
|
||||||
' f.isRequired, f.orderNumber' +
|
f.isRequired, f.orderNumber,
|
||||||
' from Fees f' +
|
ifnull(lo.lotOccupancyFeeCount, 0) as lotOccupancyFeeCount
|
||||||
' left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId' +
|
from Fees f
|
||||||
' left join LotTypes l on f.lotTypeId = l.lotTypeId' +
|
left join (
|
||||||
sqlWhereClause +
|
select feeId, count(lotOccupancyId) as lotOccupancyFeeCount
|
||||||
' order by f.orderNumber, f.feeName'
|
from LotOccupancyFees
|
||||||
|
where recordDelete_timeMillis is null
|
||||||
|
group by feeId
|
||||||
|
) lo on f.feeId = lo.feeId
|
||||||
|
left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId
|
||||||
|
left join LotTypes l on f.lotTypeId = l.lotTypeId
|
||||||
|
${sqlWhereClause}
|
||||||
|
order by f.orderNumber, f.feeName`
|
||||||
)
|
)
|
||||||
.all(sqlParameters)
|
.all(sqlParameters)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,7 @@ export interface Fee extends Record {
|
||||||
taxPercentage?: number;
|
taxPercentage?: number;
|
||||||
isRequired?: boolean;
|
isRequired?: boolean;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
|
lotOccupancyFeeCount?: number;
|
||||||
}
|
}
|
||||||
export interface LotOccupancyFee extends Fee, Record {
|
export interface LotOccupancyFee extends Fee, Record {
|
||||||
lotOccupancyId?: number;
|
lotOccupancyId?: number;
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,8 @@ export interface Fee extends Record {
|
||||||
isRequired?: boolean
|
isRequired?: boolean
|
||||||
|
|
||||||
orderNumber?: number
|
orderNumber?: number
|
||||||
|
|
||||||
|
lotOccupancyFeeCount?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LotOccupancyFee extends Fee, Record {
|
export interface LotOccupancyFee extends Fee, Record {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue