Issue Done!!

Payment and Receipt Done!!
This commit is contained in:
tanshu
2020-05-22 01:15:25 +05:30
parent 98edca5f60
commit c0ddfc95c4
27 changed files with 944 additions and 503 deletions

View File

@ -11,6 +11,8 @@ export class Voucher {
narration: string;
incentive?: number;
vendor?: Account;
source?: CostCentre;
destination?: CostCentre;
journals: Journal[];
inventories: Inventory[];
employeeBenefits: EmployeeBenefit[];

View File

@ -13,14 +13,14 @@
<mat-datepicker #date></mat-datepicker>
</mat-form-field>
<mat-form-field fxFlex="40">
<mat-select formControlName="sourceCostCentre">
<mat-select formControlName="source">
<mat-option *ngFor="let costCentre of costCentres" [value]="costCentre.id">
{{ costCentre.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="40">
<mat-select formControlName="destinationCostCentre">
<mat-select formControlName="destination">
<mat-option *ngFor="let costCentre of costCentres" [value]="costCentre.id">
{{ costCentre.name }}
</mat-option>

View File

@ -7,7 +7,7 @@ import {BehaviorSubject, Observable, of as observableOf} from 'rxjs';
import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators';
import {IssueDataSource} from './issue-datasource';
import {VoucherService} from '../core/voucher.service';
import {Batch, Inventory, Journal, Voucher} from '../core/voucher';
import {Batch, Inventory, Voucher} from '../core/voucher';
import * as moment from 'moment';
import {AuthService} from '../auth/auth.service';
import {ConfirmDialogComponent} from '../shared/confirm-dialog/confirm-dialog.component';
@ -17,7 +17,7 @@ import {BatchService} from '../core/batch.service';
import {IssueGridService} from './issue-grid.service';
import {CostCentre} from '../core/cost-centre';
import {IssueGridDataSource} from './issue-grid-datasource';
import {Hotkey, HotkeysService} from "angular2-hotkeys";
import {Hotkey, HotkeysService} from 'angular2-hotkeys';
@Component({
selector: 'app-issue',
@ -32,8 +32,6 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
dataSource: IssueDataSource;
gridDataSource: IssueGridDataSource;
form: FormGroup;
sourceJournal: Journal;
destinationJournal: Journal;
voucher: Voucher;
costCentres: CostCentre[];
batch: Batch;
@ -74,8 +72,9 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
return false; // Prevent bubbling
}, ['INPUT', 'SELECT', 'TEXTAREA']));
this.hotkeys.add(new Hotkey('ctrl+s', (event: KeyboardEvent): boolean => {
if (this.canSave())
if (this.canSave()) {
this.save();
}
return false; // Prevent bubbling
}, ['INPUT', 'SELECT', 'TEXTAREA']));
}
@ -90,13 +89,11 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
loadVoucher(voucher: Voucher) {
this.voucher = voucher;
this.sourceJournal = this.voucher.journals.filter(x => x.debit === -1)[0];
this.destinationJournal = this.voucher.journals.filter(x => x.debit === 1)[0];
this.form.setValue({
date: moment(this.voucher.date, 'DD-MMM-YYYY').toDate(),
sourceCostCentre: this.sourceJournal.costCentre.id,
destinationCostCentre: this.destinationJournal.costCentre.id,
amount: this.sourceJournal.amount,
source: this.voucher.source.id,
destination: this.voucher.destination.id,
amount: Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0)),
addRow: {
batch: '',
quantity: ''
@ -116,10 +113,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
addRow() {
const formValue = this.form.get('addRow').value;
const quantity = +(formValue.quantity);
const isConsumption = this.voucher.journals
.filter(
x => x.debit === -1
)[0].costCentre.id === '7b845f95-dfef-fa4a-897c-f0baf15284a3';
const isConsumption = this.form.value.source === '7b845f95-dfef-fa4a-897c-f0baf15284a3';
if (this.batch === null || quantity <= 0) {
return;
}
@ -169,8 +163,6 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
updateView() {
this.inventoryObservable.next(this.voucher.inventories);
const amount = Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0));
this.sourceJournal.amount = amount;
this.destinationJournal.amount = amount;
this.form.get('amount').setValue(amount);
}
@ -201,8 +193,8 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
createForm() {
this.form = this.fb.group({
date: '',
sourceCostCentre: '',
destinationCostCentre: '',
source: '',
destination: '',
amount: {value: '', disabled: true},
addRow: this.fb.group({
batch: '',
@ -243,8 +235,8 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
getVoucher(): Voucher {
const formModel = this.form.value;
this.voucher.date = moment(formModel.date).format('DD-MMM-YYYY');
this.sourceJournal.costCentre.id = formModel.sourceCostCentre;
this.destinationJournal.costCentre.id = formModel.destinationCostCentre;
this.voucher.source.id = formModel.source;
this.voucher.destination.id = formModel.destination;
this.voucher.narration = formModel.narration;
return this.voucher;
}