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

@ -3,7 +3,7 @@
<mat-menu #voucherMenu="matMenu">
<a mat-menu-item routerLink="/journal">Journal</a>
<a mat-menu-item routerLink="/purchase">Purchase</a>
<a mat-menu-item routerLink="/return">Purchase Return</a>
<a mat-menu-item routerLink="/purchase-return">Purchase Return</a>
<a mat-menu-item routerLink="/payment">Payment</a>
<a mat-menu-item routerLink="/receipt">Receipt</a>
<a mat-menu-item routerLink="/issue">Issue</a>

View File

@ -63,9 +63,16 @@ export class VoucherService {
);
}
save(voucher: Voucher): Observable<Voucher> {
saveOrUpdate(voucher: Voucher): Observable<Voucher> {
const endpoint = voucher.type.replace(/ /g, '-').toLowerCase();
if (!voucher.id) {
return this.save(voucher, endpoint);
} else {
return this.update(voucher, endpoint);
}
}
save(voucher: Voucher, endpoint: string): Observable<Voucher> {
const fd = new FormData();
voucher.files.filter(x => !x.id).forEach((file) => {
fd.append('i' , this.dataURLtoBlob(file.resized));
@ -73,10 +80,23 @@ export class VoucherService {
});
voucher.files = voucher.files.filter(x => x.id);
fd.append('data', JSON.stringify(voucher));
const saveUrl: string = (voucher.id === undefined || voucher.id === null) ? `${url}/${endpoint}` : `${url}/${endpoint}/${voucher.id}`;
return <Observable<Voucher>>this.http.post<Voucher>(saveUrl, fd)
return <Observable<Voucher>>this.http.post<Voucher>(`${url}/${endpoint}`, fd)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
catchError(this.log.handleError(serviceName, 'save'))
);
}
update(voucher: Voucher, endpoint: string): Observable<Voucher> {
const fd = new FormData();
voucher.files.filter(x => !x.id).forEach((file) => {
fd.append('i' , this.dataURLtoBlob(file.resized));
fd.append('t' , this.dataURLtoBlob(file.thumbnail));
});
voucher.files = voucher.files.filter(x => x.id);
fd.append('data', JSON.stringify(voucher));
return <Observable<Voucher>>this.http.put<Voucher>(`${url}/${endpoint}/${voucher.id}`, fd)
.pipe(
catchError(this.log.handleError(serviceName, 'update'))
);
}

View File

@ -10,6 +10,7 @@ export class Voucher {
posted: boolean;
narration: string;
incentive?: number;
vendor?: Account;
journals: Journal[];
inventories: Inventory[];
employeeBenefits: EmployeeBenefit[];