Attendance and Employee Attendance done!!
Journal Done!! But there is issue of validation in purchase due to lack of proper journals when getting data from the frontend. The proposed solution is to create different schemas for various vouchers and then reexport and import them in a master schema for persisting Also, change "Supplier" to vendor in Purchase, etc. Also, convert all date field to date from datetime Rename "Salary Deduction" to "Employee Benefits" across the board
This commit is contained in:
@ -9,7 +9,7 @@ const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/api/voucher';
|
||||
const url = '/api';
|
||||
const serviceName = 'VoucherService';
|
||||
|
||||
@Injectable({
|
||||
@ -20,22 +20,23 @@ export class VoucherService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
get(id: string): Observable<Voucher> {
|
||||
const options = {params: new HttpParams()};
|
||||
return <Observable<Voucher>>this.http.get<Voucher>(`${url}/${id}`, options)
|
||||
get(id: string, type: string): Observable<Voucher> {
|
||||
const endpoint = type.replace(/ /g, '-').toLowerCase();
|
||||
return <Observable<Voucher>>this.http.get<Voucher>(`${url}/${endpoint}/${id}`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
catchError(this.log.handleError(serviceName, 'get'))
|
||||
);
|
||||
}
|
||||
|
||||
getOfType(type: string, account?: string): Observable<Voucher> {
|
||||
const options = {params: new HttpParams().set('t', type)};
|
||||
const endpoint = type.replace(/ /g, '-').toLowerCase();
|
||||
const options = {};
|
||||
if (account !== undefined && account !== null) {
|
||||
options.params = options.params.set('a', account);
|
||||
options['params'] = new HttpParams().set('a', account);
|
||||
}
|
||||
return <Observable<Voucher>>this.http.get<Voucher>(url, options)
|
||||
return <Observable<Voucher>>this.http.get<Voucher>(`${url}/${endpoint}`, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
catchError(this.log.handleError(serviceName, 'getOfType'))
|
||||
);
|
||||
}
|
||||
|
||||
@ -63,18 +64,17 @@ export class VoucherService {
|
||||
}
|
||||
|
||||
save(voucher: Voucher): Observable<Voucher> {
|
||||
const options = {
|
||||
params: new HttpParams().set('t', voucher.type)
|
||||
};
|
||||
const endpoint = voucher.type.replace(/ /g, '-').toLowerCase();
|
||||
|
||||
const fd = new FormData();
|
||||
voucher.files.filter(x => !x.id).forEach((file, index) => {
|
||||
fd.append('f' + index, this.dataURLtoBlob(file.resized));
|
||||
fd.append('t' + index, this.dataURLtoBlob(file.thumbnail));
|
||||
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('model', JSON.stringify(voucher));
|
||||
const saveUrl: string = (voucher.id === undefined || voucher.id === null) ? url : `${url}/${voucher.id}`;
|
||||
return <Observable<Voucher>>this.http.post<Voucher>(saveUrl, fd, options)
|
||||
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)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user