Skip to content

Commit

Permalink
22994 - Handling NSF Statements (#2986)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-barraza committed Aug 28, 2024
1 parent 268f905 commit 24412dc
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 56 deletions.
4 changes: 2 additions & 2 deletions auth-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth-web",
"version": "2.6.76",
"version": "2.6.77",
"appName": "Auth Web",
"sbcName": "SBC Common Components",
"private": true,
Expand Down
10 changes: 5 additions & 5 deletions auth-web/src/components/auth/account-freeze/AccountOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
</v-col>
</v-row>
<v-row
v-for="invoice in invoices"
:key="invoice.id"
v-for="statement in statements"
:key="statement.id"
>
<v-col class="pt-0">
<div class="link">
{{ formatDateRange(invoice.fromDate, invoice.toDate) }}
{{ formatDateRange(statement.fromDate, statement.toDate) }}
</div>
</v-col>
</v-row>
Expand Down Expand Up @@ -95,7 +95,7 @@ export default defineComponent({
const suspendedDate = (currentOrganization.value?.suspendedOn) ? formatDate(new Date(currentOrganization.value.suspendedOn)) : ''
const state = reactive({
invoices: [],
statements: [],
totalAmountDue: 0
})
Expand All @@ -105,7 +105,7 @@ export default defineComponent({
onMounted(async () => {
const failedInvoices: FailedInvoice = await calculateFailedInvoices()
state.invoices = failedInvoices?.invoices || []
state.statements = failedInvoices?.statements || []
state.totalAmountDue = failedInvoices?.totalAmountToPay || 0
})
Expand Down
15 changes: 4 additions & 11 deletions auth-web/src/models/invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LineItem } from '.'
import { LineItem } from './line-item'
import { Statement } from './statement'

export interface InvoiceList {
consInvNumber?: string
Expand Down Expand Up @@ -44,22 +45,14 @@ export interface FailedInvoice {
totalTransactionAmount?: number
totalAmountToPay?: number
invoices?: InvoiceList[]
}

export interface FailedEFTInvoice {
invoices: InvoiceList[]
totalAmountDue: number
statements?: Statement[]
}

export interface NonSufficientFundsInvoiceListResponse {
invoices: InvoiceList[]
statements: Statement[]
total: number
totalAmount: number
totalAmountRemaining: number
nsfAmount: number
}

export interface EFTInvoiceListResponse {
invoices: InvoiceList[]
totalAmountDue: number
}
9 changes: 9 additions & 0 deletions auth-web/src/models/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export interface StatementListItem {
paymentMethods?: string[]
}

export interface Statement {
id?: number
isInterimStatement?: boolean
frequency: string
fromDate: string
toDate: string
paymentMethods: string[]
}

export interface StatementSettings {
currentFrequency?: StatementListItem
frequencies: Frequencies[]
Expand Down
4 changes: 0 additions & 4 deletions auth-web/src/services/payment.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ export default class PaymentService {
return axios.get(`${ConfigHelper.getPayAPIURL()}/accounts/${accountId}/nsf`)
}

static getEFTInvoices (accountId: string | number): AxiosPromise<any> {
return axios.get(`${ConfigHelper.getPayAPIURL()}/accounts/${accountId}/eft`)
}

static downloadNSFInvoicesPDF (accountId: string | number): AxiosPromise<any> {
const url = `${ConfigHelper.getPayAPIURL()}/accounts/${accountId}/nsf/statement`
const headers = { 'Accept': 'application/pdf' }
Expand Down
26 changes: 3 additions & 23 deletions auth-web/src/stores/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import {
} from '@/models/Organization'
import { BcolAccountDetails, BcolProfile } from '@/models/bcol'
import { CreateRequestBody as CreateInvitationRequestBody, Invitation } from '@/models/Invitation'
import { EFTInvoiceListResponse, FailedEFTInvoice, FailedInvoice, NonSufficientFundsInvoiceListResponse } from '@/models/invoice'
import { EftRefundRequest, RefundRequest } from './../models/refund'
import { FailedInvoice, NonSufficientFundsInvoiceListResponse } from '@/models/invoice'
import { Products, ProductsRequestBody } from '@/models/Staff'
import { StatementFilterParams, StatementNotificationSettings, StatementSettings, StatementsSummary } from '@/models/statement'
import { computed, reactive, toRefs } from '@vue/composition-api'
Expand Down Expand Up @@ -766,16 +766,6 @@ export const useOrgStore = defineStore('org', () => {
}
}

async function getEFTInvoices (): Promise<EFTInvoiceListResponse> {
try {
const response = await PaymentService.getEFTInvoices(state.currentOrganization.id)
return response?.data || {}
} catch (error) {
// eslint-disable-next-line no-console
console.error('get EFT invoices operation failed! - ', error)
}
}

async function downloadNSFInvoicesPDF (): Promise<any> {
try {
const response = await PaymentService.downloadNSFInvoicesPDF(state.currentOrganization.id)
Expand All @@ -789,29 +779,20 @@ export const useOrgStore = defineStore('org', () => {
async function calculateFailedInvoices (): Promise<FailedInvoice> {
const nsfInvoices = await getNSFInvoices()
const invoices = nsfInvoices?.invoices || []
const statements = nsfInvoices?.statements || []
const totalAmount = nsfInvoices?.totalAmount || 0
const totalAmountRemaining = nsfInvoices?.totalAmountRemaining || 0
const nsfAmount = nsfInvoices?.nsfAmount || 0

return {
invoices: invoices,
statements: statements,
nsfFee: nsfAmount,
totalAmountToPay: totalAmountRemaining,
totalTransactionAmount: totalAmount
}
}

async function calculateFailedEFTInvoices (): Promise<FailedEFTInvoice> {
const fetchInvoices = await getEFTInvoices()
const invoices = fetchInvoices?.invoices || []
const totalAmountDue = fetchInvoices?.totalAmountDue || 0

return {
invoices: invoices,
totalAmountDue: totalAmountDue
}
}

async function resetAccountSetupProgress (): Promise<void> {
setGrantAccess(false)
setCurrentOrganization(undefined)
Expand Down Expand Up @@ -1146,7 +1127,6 @@ export const useOrgStore = defineStore('org', () => {
updateStatementNotifications,
getOrgPayments,
calculateFailedInvoices,
calculateFailedEFTInvoices,
resetAccountSetupProgress,
resetAccountWhileSwitchingPremium,
createOutstandingAccountPayment,
Expand Down
19 changes: 9 additions & 10 deletions auth-web/src/views/auth/account-freeze/AccountHoldView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
Overdue Statements
</p>
<p
v-for="invoice in invoices"
:key="invoice.id"
v-for="statement in statements"
:key="statement.id"
class="mb-2 link"
>
{{ formatDateRange(invoice.fromDate, invoice.toDate) }}
{{ formatDateRange(statement.fromDate, statement.toDate) }}
</p>
</div>
<div
Expand All @@ -59,7 +59,7 @@
<script lang="ts">
import { computed, defineComponent, onMounted, reactive, toRefs } from '@vue/composition-api'
import CommonUtils from '@/util/common-util'
import { FailedEFTInvoice } from '@/models/invoice'
import { FailedInvoice } from '@/models/invoice'
import moment from 'moment'
import sanitizeHtml from 'sanitize-html'
import { useOrgStore } from '@/stores/org'
Expand All @@ -76,13 +76,12 @@ export default defineComponent({
const orgStore = useOrgStore()
const currentOrganization = computed(() => orgStore.currentOrganization)
const getAccountAdministrator = orgStore.getAccountAdministrator
const calculateFailedInvoices: any = orgStore.calculateFailedEFTInvoices
console.log(currentOrganization.value.id)
const calculateFailedInvoices: any = orgStore.calculateFailedInvoices
const formatDate = CommonUtils.formatDisplayDate
const formatDateRange = CommonUtils.formatDateRange
const state = reactive({
invoices: [],
statements: [],
suspendedDate: (currentOrganization.value?.suspendedOn) ? formatDate(moment(currentOrganization.value.suspendedOn)) : '',
accountAdministratorEmail: ''
})
Expand All @@ -97,9 +96,9 @@ export default defineComponent({
})
onMounted(async () => {
setAdminContact()
const failedInvoices: FailedEFTInvoice = await calculateFailedInvoices()
state.invoices = failedInvoices?.invoices || []
await setAdminContact()
const failedInvoices: FailedInvoice = await calculateFailedInvoices()
state.statements = failedInvoices?.statements || []
})
return {
Expand Down

0 comments on commit 24412dc

Please sign in to comment.