Skip to content

Commit

Permalink
Merge branch 'ORV2-3221-2' of https://github.com/bcgov/onroutebc into…
Browse files Browse the repository at this point in the history
… ORV2-3221-2
  • Loading branch information
bcgov-brwang committed Jan 8, 2025
2 parents b23e1c9 + c9a3574 commit 7255868
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
22 changes: 22 additions & 0 deletions database/mssql/scripts/sampledata/dbo.ORBC_FEATURE_FLAG.Table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,28 @@ VALUES
N'dbo',
GETUTCDATE()
);
INSERT INTO
[dbo].[ORBC_FEATURE_FLAG] (
[FEATURE_ID],
[FEATURE_KEY],
[FEATURE_VALUE],
[CONCURRENCY_CONTROL_NUMBER],
[DB_CREATE_USERID],
[DB_CREATE_TIMESTAMP],
[DB_LAST_UPDATE_USERID],
[DB_LAST_UPDATE_TIMESTAMP]
)
VALUES
(
'13',
'CVCLIENT-PAY-IN-PERSON',
'DISABLED',
NULL,
N'dbo',
GETUTCDATE(),
N'dbo',
GETUTCDATE()
);

SET
IDENTITY_INSERT [dbo].[ORBC_FEATURE_FLAG] OFF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const ChoosePaymentMethod = ({
/>
))}
{showPayInPersonInfo &&
featureFlags?.["STAFF-CAN-PAY"] === "ENABLED" ? (
featureFlags?.["CVCLIENT-PAY-IN-PERSON"] === "ENABLED" ? (
<CVPayInPersonInfo />
) : null}
</RadioGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ import { SpecialAuth } from 'src/modules/special-auth/entities/special-auth.enti
]),
],
controllers: [PaymentController],
providers: [PaymentService, TransactionProfile, PaymentReportService, SpecialAuthService],
providers: [
PaymentService,
TransactionProfile,
PaymentReportService,
SpecialAuthService,
],
exports: [PaymentService],
})
export class PaymentModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,8 @@ export class PaymentService {
return fee;
}


/**
*
*
* This function is deprecated and will be removed once the validation endpoints are established.
*/
@LogAsyncMethodExecution()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
validateEmailandFaxList,
} from '../../../common/helper/notification.helper';
import { getPermitTemplateName } from '../../../common/helper/template.helper';
import { Nullable } from '../../../common/types/common';

@Injectable()
export class PermitReceiptDocumentService {
Expand Down Expand Up @@ -67,10 +68,6 @@ export class PermitReceiptDocumentService {
const permitQB = this.permitRepository.createQueryBuilder('permit');
permitQB
.select('transaction.transactionId', 'transactionId')
.addSelect(
'COUNT(permit.permitId) OVER (PARTITION BY transaction.transactionId)',
'permitCountPerTransactionId',
)
.distinct(true)
.leftJoin('permit.company', 'company')
.innerJoin('permit.permitTransactions', 'permitTransactions')
Expand All @@ -90,7 +87,6 @@ export class PermitReceiptDocumentService {

const transactions = await permitQB.getRawMany<{
transactionId: string;
permitCountPerTransactionId: number;
}>();

const transactionPermitList: {
Expand All @@ -105,9 +101,10 @@ export class PermitReceiptDocumentService {
transaction.transactionId,
);

if (
fetchedApplications?.length === transaction.permitCountPerTransactionId
) {
const unIssuedApplications = fetchedApplications.filter(
(application) => !application.permitNumber,
);
if (!unIssuedApplications?.length) {
transactionPermitList.push({
transactionId: transaction.transactionId,
permits: fetchedApplications,
Expand All @@ -125,12 +122,14 @@ export class PermitReceiptDocumentService {
* @param applicationIds Array of application IDs to filter the permits. If empty, will search by transactionId.
* @param companyId The ID of the company to which the permits may belong, optional.
* @param transactionId A specific transaction ID to find the related permit, optional. If provided, applicationIds should be empty.
* @param issued A boolean to filter results to return only issued permits.
* @returns A promise that resolves with an array of permits matching the criteria.
*/
private async findManyWithSuccessfulTransaction(
permitIds: string[],
companyId?: number,
transactionId?: string,
issued?: Nullable<boolean>,
): Promise<Permit[]> {
if (
(!permitIds?.length && !transactionId) ||
Expand All @@ -152,8 +151,10 @@ export class PermitReceiptDocumentService {
'applicationOwner.userContact',
'applicationOwnerContact',
)
.where('receipt.receiptNumber IS NOT NULL')
.where('permit.permitNumber IS NOT NULL');
.where('receipt.receiptNumber IS NOT NULL');
if (issued) {
permitQB.andWhere('permit.permitNumber IS NOT NULL');
}

if (permitIds?.length) {
permitQB.andWhere('permit.permitId IN (:...permitIds)', {
Expand Down Expand Up @@ -233,6 +234,8 @@ export class PermitReceiptDocumentService {
const fetchedPermits = await this.findManyWithSuccessfulTransaction(
permitIds,
companyId,
null,
true,
);

if (!fetchedPermits?.length) {
Expand Down

0 comments on commit 7255868

Please sign in to comment.