implemented a Maker-Checker workflow for Products, with approval-based updates and product locking to prevent concurrent edits
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Resolve } from '@angular/router';
|
||||
import { Observable, forkJoin, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { ProductsService } from 'app/products/products.service';
|
||||
|
||||
/**
|
||||
* Merges pending edits across all product types sharing the m_savings_product_temp backing table -
|
||||
* Savings, Current Account, Share, Fixed Deposit, and Recurring Deposit products - into one list for
|
||||
* the Pending Product Edits screen.
|
||||
*/
|
||||
@Injectable()
|
||||
export class GetPendingSavingsProducts implements Resolve<any> {
|
||||
private productsService = inject(ProductsService);
|
||||
|
||||
resolve(): Observable<any> {
|
||||
return forkJoin({
|
||||
savings: this.productsService.getPendingSavingsProductEdits().pipe(catchError(() => of([]))),
|
||||
current: this.productsService.getPendingCurrentProductEdits().pipe(catchError(() => of([]))),
|
||||
share: this.productsService.getPendingShareProductEdits().pipe(catchError(() => of([]))),
|
||||
fd: this.productsService.getPendingFixedDepositProductEdits().pipe(catchError(() => of([]))),
|
||||
rd: this.productsService.getPendingRecurringDepositProductEdits().pipe(catchError(() => of([])))
|
||||
}).pipe(
|
||||
map((results) => [
|
||||
...(results.savings || []).map((e: any) => ({ ...e, productType: 'SAVINGS' })),
|
||||
...(results.current || []).map((e: any) => ({ ...e, productType: 'CURRENT' })),
|
||||
...(results.share || []).map((e: any) => ({ ...e, productType: 'SHARE' })),
|
||||
...(results.fd || []).map((e: any) => ({ ...e, productType: 'FD' })),
|
||||
...(results.rd || []).map((e: any) => ({ ...e, productType: 'RD' }))
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user