Skip to content

Commit c2ca61e

Browse files
authored
Merge pull request #2526 from alberto-art3ch/enhancement/manual_journal_entry_with_asset_external_owner
WEB-220: Extend Manual Journal entry to support Asset Externalization
2 parents 0a3cf24 + 2f575aa commit c2ca61e

22 files changed

+114
-19
lines changed

src/app/accounting/accounting-routing.module.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { ProvisioningJournalEntriesResolver } from './provisioning-entries/view-
6262
import { ViewJournalEntryTransactionComponent } from 'app/shared/accounting/view-journal-entry-transaction/view-journal-entry-transaction.component';
6363
import { JournalEntryTransactionResolver } from './common-resolvers/journal-entry-transaction.resolver';
6464
import { ExternalAssetOwnerJournalEntryResolver } from 'app/loans/common-resolvers/external-asset-owner-journal-entry.resolver';
65+
import { ExternalAssetConfigurationResolver } from './common-resolvers/external-asset-configuration.resolver';
6566

6667
/** Accounting Routes */
6768
const routes: Routes = [
@@ -105,7 +106,8 @@ const routes: Routes = [
105106
offices: OfficesResolver,
106107
currencies: CurrenciesResolver,
107108
paymentTypes: PaymentTypesResolver,
108-
glAccounts: GlAccountsResolver
109+
glAccounts: GlAccountsResolver,
110+
globalConfig: ExternalAssetConfigurationResolver
109111
}
110112
},
111113
{
@@ -419,7 +421,8 @@ const routes: Routes = [
419421
ProvisioningEntryEntriesResolver,
420422
LoanProductsResolver,
421423
ProvisioningCategoriesResolver,
422-
ProvisioningJournalEntriesResolver
424+
ProvisioningJournalEntriesResolver,
425+
ExternalAssetConfigurationResolver
423426
]
424427
})
425428
export class AccountingRoutingModule {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/** Angular Imports */
2+
import { Injectable } from '@angular/core';
3+
4+
/** rxjs Imports */
5+
import { Observable } from 'rxjs';
6+
7+
/** Custom Services */
8+
import { SystemService } from 'app/system/system.service';
9+
10+
/**
11+
* Offices data resolver.
12+
*/
13+
@Injectable()
14+
export class ExternalAssetConfigurationResolver {
15+
/**
16+
* @param {AccountingService} accountingService Accounting service.
17+
*/
18+
constructor(private systemService: SystemService) {}
19+
20+
/**
21+
* Returns the offices data.
22+
* @returns {Observable<any>}
23+
*/
24+
resolve(): Observable<any> {
25+
return this.systemService.getConfigurationByName(SystemService.CONFIG_ASSET_EXTERNALIZATION);
26+
}
27+
}

src/app/accounting/create-journal-entry/create-journal-entry.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</mat-error>
1717
</mat-form-field>
1818

19-
<mat-form-field class="flex-48">
19+
<mat-form-field class="flex-24">
2020
<mat-label>{{ 'labels.inputs.Currency' | translate }}</mat-label>
2121
<mat-select required formControlName="currencyCode">
2222
<mat-option *ngFor="let currency of currencyData" [value]="currency.code">
@@ -29,6 +29,11 @@
2929
</mat-error>
3030
</mat-form-field>
3131

32+
<mat-form-field class="flex-24" *ngIf="assetExternalizationEnabled">
33+
<mat-label>{{ 'labels.inputs.External Asset Owner' | translate }}</mat-label>
34+
<input matInput formControlName="externalAssetOwner" />
35+
</mat-form-field>
36+
3237
<div
3338
class="flex-fill layout-row-wrap responsive-column"
3439
formArrayName="debits"

src/app/accounting/create-journal-entry/create-journal-entry.component.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
/** Angular Imports */
22
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
3-
import {
4-
UntypedFormGroup,
5-
UntypedFormBuilder,
6-
Validators,
7-
UntypedFormArray,
8-
ReactiveFormsModule
9-
} from '@angular/forms';
10-
import { Router, ActivatedRoute, RouterLink } from '@angular/router';
3+
import { UntypedFormGroup, UntypedFormBuilder, Validators, UntypedFormArray, UntypedFormControl } from '@angular/forms';
4+
import { Router, ActivatedRoute } from '@angular/router';
115
import { MatDialog } from '@angular/material/dialog';
126

137
/** Custom Services */
@@ -54,6 +48,9 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
5448
paymentTypeData: any;
5549
/** Gl Account data. */
5650
glAccountData: any;
51+
/** Asset Externalization */
52+
assetExternalizationConfig: any;
53+
assetExternalizationEnabled = false;
5754

5855
/* Reference of create journal form */
5956
@ViewChild('createJournalFormRef') createJournalFormRef: ElementRef<any>;
@@ -81,12 +78,16 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
8178
private configurationWizardService: ConfigurationWizardService,
8279
private popoverService: PopoverService
8380
) {
84-
this.route.data.subscribe((data: { offices: any; currencies: any; paymentTypes: any; glAccounts: any }) => {
85-
this.officeData = data.offices;
86-
this.currencyData = data.currencies.selectedCurrencyOptions;
87-
this.paymentTypeData = data.paymentTypes;
88-
this.glAccountData = data.glAccounts;
89-
});
81+
this.assetExternalizationEnabled = false;
82+
this.route.data.subscribe(
83+
(data: { offices: any; currencies: any; paymentTypes: any; glAccounts: any; globalConfig: any }) => {
84+
this.officeData = data.offices;
85+
this.currencyData = data.currencies.selectedCurrencyOptions;
86+
this.paymentTypeData = data.paymentTypes;
87+
this.glAccountData = data.glAccounts;
88+
this.assetExternalizationConfig = data.globalConfig;
89+
}
90+
);
9091
}
9192

9293
/**
@@ -192,6 +193,9 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
192193
this.settingsService.dateFormat
193194
);
194195
}
196+
if (!journalEntry['externalAssetOwner']) {
197+
delete journalEntry['externalAssetOwner'];
198+
}
195199
this.accountingService.createJournalEntry(journalEntry).subscribe((response) => {
196200
this.router.navigate(
197201
[
@@ -228,6 +232,10 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
228232
this.showPopover(this.templateCreateJournalFormRef, this.createJournalFormRef.nativeElement, 'top', true);
229233
});
230234
}
235+
this.assetExternalizationEnabled = this.assetExternalizationConfig.enabled;
236+
if (this.assetExternalizationEnabled) {
237+
this.journalEntryForm.addControl('externalAssetOwner', new UntypedFormControl());
238+
}
231239
}
232240

233241
/**

src/app/shared/accounting/view-journal-entry-transaction/view-journal-entry-transaction.component.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</div>
1616

1717
<div class="container m-b-20" *ngIf="isViewTransaction()">
18-
<mat-card class="mat-elevation-z8" *ngIf="dataSource">
18+
<mat-card class="mat-elevation-z8" ngClass="{{ journalEntryColor() }}" *ngIf="dataSource">
1919
<mat-card-content>
2020
<div class="layout-row-wrap">
2121
<div class="flex-25 header">
@@ -49,6 +49,22 @@
4949
<div class="flex-25">
5050
{{ dataSource.data[0].submittedOnDate | datetimeFormat }}
5151
</div>
52+
53+
<div class="flex-25 header">
54+
{{ 'labels.inputs.Manual Journal Entry' | translate }}
55+
</div>
56+
57+
<div class="flex-25">
58+
{{ dataSource.data[0].manualEntry | yesNo }}
59+
</div>
60+
61+
<div class="flex-25 header" *ngIf="dataSource.data[0].externalAssetOwner">
62+
{{ 'labels.inputs.External Asset Owner' | translate }}
63+
</div>
64+
65+
<div class="flex-25" *ngIf="dataSource.data[0].externalAssetOwner">
66+
{{ dataSource.data[0].externalAssetOwner }}
67+
</div>
5268
</div>
5369
</mat-card-content>
5470
</mat-card>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
@use 'assets/styles/helper';
2+
@use 'assets/styles/colours' as *;
3+
14
table {
25
width: 100%;
36

47
.select-row:hover {
58
cursor: pointer;
69
}
710
}
11+
12+
.manual-entry {
13+
background-color: $manual-entry;
14+
}

src/app/shared/accounting/view-journal-entry-transaction/view-journal-entry-transaction.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { DateFormatPipe } from '../../../pipes/date-format.pipe';
2525
import { DatetimeFormatPipe } from '../../../pipes/datetime-format.pipe';
2626
import { FormatNumberPipe } from '../../../pipes/format-number.pipe';
2727
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
28+
import { YesnoPipe } from '@pipes/yesno.pipe';
2829

2930
@Component({
3031
selector: 'mifosx-view-journal-entry-transaction',
@@ -47,7 +48,8 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
4748
MatRow,
4849
DateFormatPipe,
4950
DatetimeFormatPipe,
50-
FormatNumberPipe
51+
FormatNumberPipe,
52+
YesnoPipe
5153
]
5254
})
5355
export class ViewJournalEntryTransactionComponent implements OnInit {
@@ -76,6 +78,8 @@ export class ViewJournalEntryTransactionComponent implements OnInit {
7678

7779
isJournalEntryLoaded = false;
7880

81+
isManualJournalEntry = false;
82+
7983
/**
8084
* @param {AccountingService} accountingService Accounting Service.
8185
* @param {ActivatedRoute} route Activated Route.
@@ -102,6 +106,7 @@ export class ViewJournalEntryTransactionComponent implements OnInit {
102106
if (data.transaction.pageItems.length > 0) {
103107
this.isJournalEntryLoaded = true;
104108
this.transactionId = data.transaction.pageItems[0].transactionId;
109+
this.isManualJournalEntry = data.transaction.pageItems[0].manualEntry;
105110
}
106111
} else if (this.isViewTransfer()) {
107112
this.journalEntriesData = data.transferJournalEntryData.journalEntryData.content;
@@ -185,4 +190,11 @@ export class ViewJournalEntryTransactionComponent implements OnInit {
185190
goBack(): void {
186191
this.location.back();
187192
}
193+
194+
journalEntryColor(): string {
195+
if (this.isManualJournalEntry) {
196+
return 'manual-entry';
197+
}
198+
return '';
199+
}
188200
}

src/app/system/system.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { RunJobWithParamPayloadType } from './manage-jobs/scheduler-jobs/custom-
1313
providedIn: 'root'
1414
})
1515
export class SystemService {
16+
public static CONFIG_ASSET_EXTERNALIZATION = 'asset-externalization-of-non-active-loans';
17+
1618
emptyPayload: any = {};
1719

1820
/**

src/assets/styles/_colours.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ $subStatus-contract-termination: #b3b3b3;
8484

8585
$error-log: #ffa726;
8686

87+
$manual-entry: #d7e3ff;
88+
8789
.column-mandatory {
8890
color: $status-active;
8991
text-align: center;

src/assets/translations/cs-CS.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,7 @@
18841884
"Mandatory": "Povinné",
18851885
"Mandatory Guarantee(%)": "Povinná záruka (%)",
18861886
"Manual Entries Allowed": "Ruční vkládání povoleno",
1887+
"Manual Journal Entry": "Ruční zápis do deníku",
18871888
"Mapper Key": "Mapper Key",
18881889
"Mapper Value": "Hodnota mapovače",
18891890
"Mapping id": "ID mapování",

0 commit comments

Comments
 (0)