code cleanup

deepsource-autofix-76c6eb20
Dan Gowans 2024-06-25 15:18:40 -04:00
parent b2550ca549
commit 577141be61
6 changed files with 60 additions and 48 deletions

View File

@ -19,7 +19,7 @@ describe('Admin - Fee Management', () => {
cy.injectAxe();
cy.checkA11y();
cy.fixture('fee.json').then((fee) => {
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory);
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory ?? '');
cy.get(".modal button[type='submit']").click();
cy.wait(ajaxDelayMillis);
cy.get('.container--feeCategory .panel-heading .title').should('contain.text', fee.feeCategory);
@ -31,11 +31,11 @@ describe('Admin - Fee Management', () => {
cy.injectAxe();
cy.checkA11y();
cy.fixture('fee.json').then((fee) => {
cy.get(".modal input[name='feeName']").type(fee.feeName);
cy.get(".modal textarea[name='feeDescription']").type(fee.feeDescription);
cy.get(".modal input[name='feeName']").type(fee.feeName ?? '');
cy.get(".modal textarea[name='feeDescription']").type(fee.feeDescription ?? '');
cy.get(".modal input[name='feeAmount']")
.clear()
.type(fee.feeAmount.toString());
.type(fee.feeAmount?.toString() ?? '');
cy.get(".modal input[name='taxAmount']").should('be.disabled');
cy.get(".modal input[name='taxPercentage']")
.invoke('val')
@ -46,7 +46,7 @@ describe('Admin - Fee Management', () => {
cy.get(".modal select[name='includeQuantity']").select('1');
cy.get(".modal input[name='quantityUnit']")
.should('not.be.disabled')
.type(fee.quantityUnit);
.type(fee.quantityUnit ?? '');
cy.get(".modal button[type='submit']").click();
cy.wait(ajaxDelayMillis);
cy.get('.container--fee a').should('contain.text', fee.feeName);

View File

@ -27,7 +27,7 @@ describe('Admin - Fee Management', () => {
cy.checkA11y()
cy.fixture('fee.json').then((fee: Fee) => {
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory!)
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory ?? '')
cy.get(".modal button[type='submit']").click()
@ -49,13 +49,15 @@ describe('Admin - Fee Management', () => {
cy.checkA11y()
cy.fixture('fee.json').then((fee: Fee) => {
cy.get(".modal input[name='feeName']").type(fee.feeName!)
cy.get(".modal input[name='feeName']").type(fee.feeName ?? '')
cy.get(".modal textarea[name='feeDescription']").type(fee.feeDescription!)
cy.get(".modal textarea[name='feeDescription']").type(
fee.feeDescription ?? ''
)
cy.get(".modal input[name='feeAmount']")
.clear()
.type(fee.feeAmount!.toString())
.type(fee.feeAmount?.toString() ?? '')
cy.get(".modal input[name='taxAmount']").should('be.disabled')
@ -74,7 +76,7 @@ describe('Admin - Fee Management', () => {
cy.get(".modal input[name='quantityUnit']")
.should('not.be.disabled')
.type(fee.quantityUnit!)
.type(fee.quantityUnit ?? '')
cy.get(".modal button[type='submit']").click()

View File

@ -1098,11 +1098,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
delete exports.lotOccupancyFees;
const lotOccupancyFeesContainerElement = document.querySelector('#container--lotOccupancyFees');
function getFeeGrandTotal() {
var _a, _b, _c;
let feeGrandTotal = 0;
for (const lotOccupancyFee of lotOccupancyFees) {
feeGrandTotal +=
(lotOccupancyFee.feeAmount + lotOccupancyFee.taxAmount) *
lotOccupancyFee.quantity;
(((_a = lotOccupancyFee.feeAmount) !== null && _a !== void 0 ? _a : 0) + ((_b = lotOccupancyFee.taxAmount) !== null && _b !== void 0 ? _b : 0)) *
((_c = lotOccupancyFee.quantity) !== null && _c !== void 0 ? _c : 0);
}
return feeGrandTotal;
}
@ -1186,7 +1187,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
}
function renderLotOccupancyFees() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
if (lotOccupancyFees.length === 0) {
lotOccupancyFeesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no fees associated with this record.</p>
@ -1241,11 +1242,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
<td class="has-text-right">${(_e = lotOccupancyFee.quantity) === null || _e === void 0 ? void 0 : _e.toString()}</td>
<td>=</td>`}
<td class="has-text-right">
$${(lotOccupancyFee.feeAmount * lotOccupancyFee.quantity).toFixed(2)}
$${(((_f = lotOccupancyFee.feeAmount) !== null && _f !== void 0 ? _f : 0) * ((_g = lotOccupancyFee.quantity) !== null && _g !== void 0 ? _g : 0)).toFixed(2)}
</td>
<td class="is-hidden-print">
<div class="buttons are-small is-flex-wrap-nowrap is-justify-content-end">
${((_f = lotOccupancyFee.includeQuantity) !== null && _f !== void 0 ? _f : false)
${((_h = lotOccupancyFee.includeQuantity) !== null && _h !== void 0 ? _h : false)
? `<button class="button is-primary button--editQuantity">
<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
<span>Edit</span>
@ -1256,14 +1257,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
</button>
</div>
</td>`;
(_g = tableRowElement
.querySelector('.button--editQuantity')) === null || _g === void 0 ? void 0 : _g.addEventListener('click', editLotOccupancyFeeQuantity);
(_h = tableRowElement
.querySelector('.button--delete')) === null || _h === void 0 ? void 0 : _h.addEventListener('click', deleteLotOccupancyFee);
(_j = lotOccupancyFeesContainerElement
.querySelector('tbody')) === null || _j === void 0 ? void 0 : _j.append(tableRowElement);
feeAmountTotal += lotOccupancyFee.feeAmount * lotOccupancyFee.quantity;
taxAmountTotal += lotOccupancyFee.taxAmount * lotOccupancyFee.quantity;
(_j = tableRowElement
.querySelector('.button--editQuantity')) === null || _j === void 0 ? void 0 : _j.addEventListener('click', editLotOccupancyFeeQuantity);
(_k = tableRowElement
.querySelector('.button--delete')) === null || _k === void 0 ? void 0 : _k.addEventListener('click', deleteLotOccupancyFee);
(_l = lotOccupancyFeesContainerElement
.querySelector('tbody')) === null || _l === void 0 ? void 0 : _l.append(tableRowElement);
feeAmountTotal +=
((_m = lotOccupancyFee.feeAmount) !== null && _m !== void 0 ? _m : 0) * ((_o = lotOccupancyFee.quantity) !== null && _o !== void 0 ? _o : 0);
taxAmountTotal +=
((_p = lotOccupancyFee.taxAmount) !== null && _p !== void 0 ? _p : 0) * ((_q = lotOccupancyFee.quantity) !== null && _q !== void 0 ? _q : 0);
}
;
lotOccupancyFeesContainerElement.querySelector('#lotOccupancyFees--feeAmountTotal').textContent = '$' + feeAmountTotal.toFixed(2);

View File

@ -6,11 +6,12 @@ let lotOccupancyFees = exports.lotOccupancyFees;
delete exports.lotOccupancyFees;
const lotOccupancyFeesContainerElement = document.querySelector('#container--lotOccupancyFees');
function getFeeGrandTotal() {
var _a, _b, _c;
let feeGrandTotal = 0;
for (const lotOccupancyFee of lotOccupancyFees) {
feeGrandTotal +=
(lotOccupancyFee.feeAmount + lotOccupancyFee.taxAmount) *
lotOccupancyFee.quantity;
(((_a = lotOccupancyFee.feeAmount) !== null && _a !== void 0 ? _a : 0) + ((_b = lotOccupancyFee.taxAmount) !== null && _b !== void 0 ? _b : 0)) *
((_c = lotOccupancyFee.quantity) !== null && _c !== void 0 ? _c : 0);
}
return feeGrandTotal;
}
@ -94,7 +95,7 @@ function deleteLotOccupancyFee(clickEvent) {
});
}
function renderLotOccupancyFees() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
if (lotOccupancyFees.length === 0) {
lotOccupancyFeesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no fees associated with this record.</p>
@ -149,11 +150,11 @@ function renderLotOccupancyFees() {
<td class="has-text-right">${(_e = lotOccupancyFee.quantity) === null || _e === void 0 ? void 0 : _e.toString()}</td>
<td>=</td>`}
<td class="has-text-right">
$${(lotOccupancyFee.feeAmount * lotOccupancyFee.quantity).toFixed(2)}
$${(((_f = lotOccupancyFee.feeAmount) !== null && _f !== void 0 ? _f : 0) * ((_g = lotOccupancyFee.quantity) !== null && _g !== void 0 ? _g : 0)).toFixed(2)}
</td>
<td class="is-hidden-print">
<div class="buttons are-small is-flex-wrap-nowrap is-justify-content-end">
${((_f = lotOccupancyFee.includeQuantity) !== null && _f !== void 0 ? _f : false)
${((_h = lotOccupancyFee.includeQuantity) !== null && _h !== void 0 ? _h : false)
? `<button class="button is-primary button--editQuantity">
<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
<span>Edit</span>
@ -164,14 +165,16 @@ function renderLotOccupancyFees() {
</button>
</div>
</td>`;
(_g = tableRowElement
.querySelector('.button--editQuantity')) === null || _g === void 0 ? void 0 : _g.addEventListener('click', editLotOccupancyFeeQuantity);
(_h = tableRowElement
.querySelector('.button--delete')) === null || _h === void 0 ? void 0 : _h.addEventListener('click', deleteLotOccupancyFee);
(_j = lotOccupancyFeesContainerElement
.querySelector('tbody')) === null || _j === void 0 ? void 0 : _j.append(tableRowElement);
feeAmountTotal += lotOccupancyFee.feeAmount * lotOccupancyFee.quantity;
taxAmountTotal += lotOccupancyFee.taxAmount * lotOccupancyFee.quantity;
(_j = tableRowElement
.querySelector('.button--editQuantity')) === null || _j === void 0 ? void 0 : _j.addEventListener('click', editLotOccupancyFeeQuantity);
(_k = tableRowElement
.querySelector('.button--delete')) === null || _k === void 0 ? void 0 : _k.addEventListener('click', deleteLotOccupancyFee);
(_l = lotOccupancyFeesContainerElement
.querySelector('tbody')) === null || _l === void 0 ? void 0 : _l.append(tableRowElement);
feeAmountTotal +=
((_m = lotOccupancyFee.feeAmount) !== null && _m !== void 0 ? _m : 0) * ((_o = lotOccupancyFee.quantity) !== null && _o !== void 0 ? _o : 0);
taxAmountTotal +=
((_p = lotOccupancyFee.taxAmount) !== null && _p !== void 0 ? _p : 0) * ((_q = lotOccupancyFee.quantity) !== null && _q !== void 0 ? _q : 0);
}
;
lotOccupancyFeesContainerElement.querySelector('#lotOccupancyFees--feeAmountTotal').textContent = '$' + feeAmountTotal.toFixed(2);

View File

@ -28,8 +28,8 @@ function getFeeGrandTotal(): number {
for (const lotOccupancyFee of lotOccupancyFees) {
feeGrandTotal +=
(lotOccupancyFee.feeAmount! + lotOccupancyFee.taxAmount!) *
lotOccupancyFee.quantity!
((lotOccupancyFee.feeAmount ?? 0) + (lotOccupancyFee.taxAmount ?? 0)) *
(lotOccupancyFee.quantity ?? 0)
}
return feeGrandTotal
@ -41,9 +41,10 @@ function editLotOccupancyFeeQuantity(clickEvent: Event): void {
.feeId ?? '',
10
)
const fee = lotOccupancyFees.find((possibleFee) => {
return possibleFee.feeId === feeId
})!
}) as recordTypes.LotOccupancyFee
let updateCloseModalFunction: () => void
@ -56,11 +57,11 @@ function editLotOccupancyFeeQuantity(clickEvent: Event): void {
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
lotOccupancyFees?: recordTypes.LotOccupancyFee[]
lotOccupancyFees: recordTypes.LotOccupancyFee[]
}
if (responseJSON.success) {
lotOccupancyFees = responseJSON.lotOccupancyFees!
lotOccupancyFees = responseJSON.lotOccupancyFees
renderLotOccupancyFees()
updateCloseModalFunction()
} else {
@ -226,7 +227,7 @@ function renderLotOccupancyFees(): void {
<td>=</td>`
}
<td class="has-text-right">
$${(lotOccupancyFee.feeAmount! * lotOccupancyFee.quantity!).toFixed(2)}
$${((lotOccupancyFee.feeAmount ?? 0) * (lotOccupancyFee.quantity ?? 0)).toFixed(2)}
</td>
<td class="is-hidden-print">
<div class="buttons are-small is-flex-wrap-nowrap is-justify-content-end">
@ -256,8 +257,11 @@ function renderLotOccupancyFees(): void {
.querySelector('tbody')
?.append(tableRowElement)
feeAmountTotal += lotOccupancyFee.feeAmount! * lotOccupancyFee.quantity!
taxAmountTotal += lotOccupancyFee.taxAmount! * lotOccupancyFee.quantity!
feeAmountTotal +=
(lotOccupancyFee.feeAmount ?? 0) * (lotOccupancyFee.quantity ?? 0)
taxAmountTotal +=
(lotOccupancyFee.taxAmount ?? 0) * (lotOccupancyFee.quantity ?? 0)
}
;(
@ -373,11 +377,11 @@ addFeeButtonElement.addEventListener('click', () => {
const feeCategory = feeCategories.find((currentFeeCategory) => {
return currentFeeCategory.feeCategoryId === feeCategoryId
})!
}) as recordTypes.FeeCategory
const fee = feeCategory.fees.find((currentFee) => {
return currentFee.feeId === feeId
})!
}) as recordTypes.Fee
if (fee.includeQuantity ?? false) {
doSetQuantityAndAddFee(fee)
@ -532,7 +536,7 @@ function editLotOccupancyTransaction(clickEvent: Event): void {
const transaction = lotOccupancyTransactions.find((possibleTransaction) => {
return possibleTransaction.transactionIndex === transactionIndex
})!
}) as recordTypes.LotOccupancyTransaction
let editCloseModalFunction: () => void

File diff suppressed because one or more lines are too long