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:
@ -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'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user