Renamed "Salary Deduction" to "Employee Benefit"

Journal, Purchase and Purchase Return vouchers done!!

Changed the column type of "date" columns from "datetime" to better fit the data.
This commit is contained in:
tanshu
2020-05-21 13:11:47 +05:30
parent a0f27fe364
commit 98edca5f60
35 changed files with 977 additions and 894 deletions

View File

@ -8,7 +8,7 @@ import {PurchaseDataSource} from './purchase-datasource';
import {Account} from '../core/account';
import {VoucherService} from '../core/voucher.service';
import {AccountService} from '../core/account.service';
import {DbFile, Inventory, Journal, Voucher} from '../core/voucher';
import {DbFile, 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';
@ -18,7 +18,7 @@ import {PurchaseDialogComponent} from './purchase-dialog.component';
import {ImageDialogComponent} from '../shared/image-dialog/image-dialog.component';
import {ProductService} from '../product/product.service';
import {Product} from '../core/product';
import {Hotkey, HotkeysService} from "angular2-hotkeys";
import {Hotkey, HotkeysService} from 'angular2-hotkeys';
@Component({
selector: 'app-purchase',
@ -32,9 +32,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
public inventoryObservable = new BehaviorSubject<Inventory[]>([]);
dataSource: PurchaseDataSource;
form: FormGroup;
purchaseJournal: Journal;
voucher: Voucher;
account: Account;
product: Product;
accBal: any;
@ -72,13 +70,15 @@ export class PurchaseComponent 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']));
this.hotkeys.add(new Hotkey('ctrl+p', (event: KeyboardEvent): boolean => {
if (this.voucher.id && !this.voucher.posted && this.auth.user.perms.indexOf('Post Vouchers') !== -1)
if (this.voucher.id && !this.voucher.posted && this.auth.user.perms.indexOf('Post Vouchers') !== -1) {
this.post();
}
return false; // Prevent bubbling
}, ['INPUT', 'SELECT', 'TEXTAREA']));
}
@ -93,11 +93,10 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
loadVoucher(voucher) {
this.voucher = voucher;
this.purchaseJournal = this.voucher.journals.filter(x => x.debit === -1)[0];
this.form.setValue({
date: moment(this.voucher.date, 'DD-MMM-YYYY').toDate(),
account: this.purchaseJournal.account,
amount: this.purchaseJournal.amount,
account: this.voucher.vendor,
amount: Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0)),
addRow: {
product: '',
quantity: '',
@ -161,8 +160,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
updateView() {
this.inventoryObservable.next(this.voucher.inventories);
this.purchaseJournal.amount = Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0));
this.form.get('amount').setValue(this.purchaseJournal.amount);
this.form.get('amount').setValue(Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0)));
}
editRow(row: Inventory) {
@ -230,7 +228,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
}
save() {
this.ser.save(this.getVoucher())
this.ser.saveOrUpdate(this.getVoucher())
.subscribe(
(result) => {
this.loadVoucher(result);
@ -246,7 +244,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
getVoucher(): Voucher {
const formModel = this.form.value;
this.voucher.date = moment(formModel.date).format('DD-MMM-YYYY');
this.purchaseJournal.account = formModel.account;
this.voucher.vendor = formModel.account;
this.voucher.narration = formModel.narration;
return this.voucher;
}
@ -306,7 +304,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
}
accountSelected(event: MatAutocompleteSelectedEvent): void {
this.account = event.option.value;
this.form.get('account').setValue(event.option.value);
}
displayProductName(product?: Product): string | undefined {