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:
@ -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>
|
||||
|
||||
@ -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'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ export class Voucher {
|
||||
posted: boolean;
|
||||
narration: string;
|
||||
incentive?: number;
|
||||
vendor?: Account;
|
||||
journals: Journal[];
|
||||
inventories: Inventory[];
|
||||
employeeBenefits: EmployeeBenefit[];
|
||||
|
||||
Reference in New Issue
Block a user