Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Jun 25, 2024
1 parent b2550ca commit 577141b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 48 deletions.
10 changes: 5 additions & 5 deletions cypress/e2e/01-admin/feeManagement.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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')
Expand All @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions cypress/e2e/01-admin/feeManagement.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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')

Expand All @@ -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()

Expand Down
29 changes: 16 additions & 13 deletions public-typescript/lotOccupancyEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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);
Expand Down
29 changes: 16 additions & 13 deletions public-typescript/lotOccupancyEdit/lotOccupancyEditFees.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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);
Expand Down
26 changes: 15 additions & 11 deletions public-typescript/lotOccupancyEdit/lotOccupancyEditFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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 {
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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)
}

;(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -532,7 +536,7 @@ function editLotOccupancyTransaction(clickEvent: Event): void {

const transaction = lotOccupancyTransactions.find((possibleTransaction) => {
return possibleTransaction.transactionIndex === transactionIndex
})!
}) as recordTypes.LotOccupancyTransaction

let editCloseModalFunction: () => void

Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/lotOccupancyEdit.min.js

Large diffs are not rendered by default.

0 comments on commit 577141b

Please sign in to comment.