Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIM-178: Do not count terminated leases as active #197

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
SA_PASSWORD: Passw0rd!
ACCEPT_EULA: Y
ports:
- "1433:1433"
runs-on: ubuntu-latest
- '1433:1433'
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
terminationDate: Lease['terminationDate']
}

function trimRow(obj: any): any {

Check warning on line 21 in src/services/lease-service/adapters/xpand/tenant-lease-adapter.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

Check warning on line 21 in src/services/lease-service/adapters/xpand/tenant-lease-adapter.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
return Object.fromEntries(
Object.entries(obj).map(([key, value]) => [
key,
Expand All @@ -40,7 +40,7 @@
}

const getParkingSpaceWaitingList = (
rows: Array<any>

Check warning on line 43 in src/services/lease-service/adapters/xpand/tenant-lease-adapter.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
): WaitingList | undefined => {
const parkingSpaceQueueTime =
rows
Expand All @@ -57,7 +57,7 @@
}

const transformFromDbContact = (
rows: Array<any>,

Check warning on line 60 in src/services/lease-service/adapters/xpand/tenant-lease-adapter.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
phoneNumbers: any,
leases: any
): Contact => {
Expand Down Expand Up @@ -531,15 +531,13 @@
}

const isLeaseActive = (lease: Lease | PartialLease): boolean => {
const { leaseStartDate, lastDebitDate, terminationDate } = lease
const currentDate = new Date()
const leaseStartDate = new Date(lease.leaseStartDate)
const lastDebitDate = lease.lastDebitDate
? new Date(lease.lastDebitDate)
: null

return (
leaseStartDate < currentDate &&
(!lastDebitDate || currentDate < lastDebitDate)
(!lastDebitDate || currentDate < lastDebitDate) &&
(!terminationDate || currentDate < terminationDate)
)
}

Expand Down
7 changes: 7 additions & 0 deletions src/services/lease-service/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,12 @@ describe('lease-service', () => {

expect(tenantLeaseAdapter.isLeaseActive(lease)).toBe(false)
})

it('should return false if terminationDate is in the past', () => {
const lease = leaseMock[0]
lease.terminationDate = new Date(Date.now() - 1000 * 60 * 60 * 24)

expect(tenantLeaseAdapter.isLeaseActive(lease)).toBe(false)
})
})
})
Loading