Transactions tab standarization
This commit is contained in:
committed by
Jose Alberto Hernandez
parent
dab5ceec9d
commit
54dc91e0e2
+9
-1
@@ -1,6 +1,14 @@
|
||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
||||
<!--
|
||||
<button mat-raised-button color="primary" *mifosxHasPermission="'UPDATE_LOANPRODUCT'" (click)="copyProduct()">
|
||||
<fa-icon icon="copy" class="m-r-10"></fa-icon>{{'labels.buttons.Create' | translate}} {{'labels.text.Copy' | translate}}
|
||||
</button>
|
||||
-->
|
||||
<button mat-raised-button color="primary" *mifosxHasPermission="'UPDATE_LOANPRODUCT'" (click)="exportDefinition()">
|
||||
<fa-icon icon="download" class="m-r-10"></fa-icon>{{'labels.buttons.Export' | translate}}
|
||||
</button>
|
||||
<button mat-raised-button color="primary" [routerLink]="['../edit']" *mifosxHasPermission="'UPDATE_LOANPRODUCT'">
|
||||
<fa-icon icon="edit" class="m-r-10"></fa-icon>Edit
|
||||
<fa-icon icon="edit" class="m-r-10"></fa-icon>{{'labels.buttons.Edit' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
+98
-2
@@ -1,6 +1,13 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { LoanProduct } from '../../models/loan-product.model';
|
||||
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
|
||||
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ProductsService } from 'app/products/products.service';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-general-tab',
|
||||
@@ -12,7 +19,12 @@ export class GeneralTabComponent implements OnInit {
|
||||
loanProduct: LoanProduct;
|
||||
useDueForRepaymentsConfigurations = false;
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private productsService: ProductsService,
|
||||
private settingsService: SettingsService,
|
||||
private translateService: TranslateService) {
|
||||
this.route.data.subscribe((data: { loanProduct: any }) => {
|
||||
this.loanProduct = data.loanProduct;
|
||||
this.useDueForRepaymentsConfigurations = (!this.loanProduct.dueDaysForRepaymentEvent && !this.loanProduct.overDueDaysForRepaymentEvent);
|
||||
@@ -23,4 +35,88 @@ export class GeneralTabComponent implements OnInit {
|
||||
this.loanProduct.allowAttributeConfiguration = Object.values(this.loanProduct.allowAttributeOverrides).some((attribute: boolean) => attribute);
|
||||
}
|
||||
|
||||
exportDefinition(): void {
|
||||
const product = this.loanProduct;
|
||||
delete product['id'];
|
||||
const fileName: string = product.name.replace(' ', '_') + '.json';
|
||||
const link = document.createElement('a');
|
||||
link.setAttribute('href', 'data:text/plain;charset=utf-u,' + encodeURIComponent(JSON.stringify(product, null, 2)));
|
||||
link.setAttribute('download', fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
copyProduct(): void {
|
||||
const productNameTmp = `${this.loanProduct.name.replace(' ', '_')}_${this.translateService.instant('labels.text.Copy')}`;
|
||||
const productCopy = JSON.parse(JSON.stringify(this.loanProduct));
|
||||
|
||||
const formfields: FormfieldBase[] = [
|
||||
new InputBase({
|
||||
controlName: 'name',
|
||||
label: this.translateService.instant('labels.inputs.Name'),
|
||||
value: productNameTmp,
|
||||
type: 'text',
|
||||
required: true,
|
||||
order: 2
|
||||
}),
|
||||
new InputBase({
|
||||
controlName: 'shortName',
|
||||
label: this.translateService.instant('labels.inputs.Short Name'),
|
||||
value: '',
|
||||
type: 'text',
|
||||
required: true,
|
||||
order: 2
|
||||
}),
|
||||
];
|
||||
const data = {
|
||||
title: `${this.translateService.instant('labels.buttons.Create')} ${this.translateService.instant('labels.inputs.Loan Product')}`,
|
||||
layout: { addButtonText: this.translateService.instant('labels.buttons.Create') },
|
||||
formfields: formfields
|
||||
};
|
||||
const createProductDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||
createProductDialogRef.afterClosed().subscribe((productResponse: any) => {
|
||||
if (productResponse.data) {
|
||||
|
||||
productCopy['name'] = productResponse.data.value['name'];
|
||||
productCopy['shortName'] = productResponse.data.value['shortName'];
|
||||
productCopy['delinquencyBucketId'] = productCopy['delinquencyBucket'] ? productCopy['delinquencyBucket']['id'] : null;
|
||||
productCopy['currencyCode'] = productCopy['currency'] ? productCopy['currency']['code'] : null;
|
||||
productCopy['interestRatePerPeriod'] = productCopy['annualInterestRate'];
|
||||
productCopy['transactionProcessingStrategyCode'] = productCopy['transactionProcessingStrategyName'];
|
||||
productCopy['allowPartialPeriodInterestCalcualtion'] = productCopy['allowPartialPeriodInterestCalculation'];
|
||||
productCopy['locale'] = this.settingsService.language.code;
|
||||
|
||||
let valueTmp: any = productCopy['daysInMonthType']['value'];
|
||||
productCopy['daysInMonthType'] = valueTmp;
|
||||
valueTmp = productCopy['daysInYearType']['value'];
|
||||
productCopy['daysInYearType'] = valueTmp;
|
||||
valueTmp = productCopy['amortizationType']['id'];
|
||||
productCopy['amortizationType'] = valueTmp;
|
||||
|
||||
delete productCopy['id'];
|
||||
delete productCopy['advancedPaymentAllocationTransactionTypes'];
|
||||
delete productCopy['advancedPaymentAllocationTypes'];
|
||||
delete productCopy['creditAllocationTransactionTypes'];
|
||||
delete productCopy['creditAllocationAllocationTypes'];
|
||||
delete productCopy['delinquencyBucketOptions'];
|
||||
delete productCopy['allowAttributeConfiguration'];
|
||||
delete productCopy['status'];
|
||||
delete productCopy['delinquencyBucket'];
|
||||
delete productCopy['currency'];
|
||||
delete productCopy['isRatesEnabled'];
|
||||
delete productCopy['annualInterestRate'];
|
||||
delete productCopy['transactionProcessingStrategyName'];
|
||||
delete productCopy['allowPartialPeriodInterestCalculation'];
|
||||
delete productCopy['advancedPaymentAllocationFutureInstallmentAllocationRules'];
|
||||
|
||||
this.productsService.createLoanProduct(productCopy)
|
||||
.subscribe((response: any) => {
|
||||
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user