Incentive Done!!

Employee Benefit Done!!
This commit is contained in:
tanshu
2020-05-23 09:45:02 +05:30
parent 814d289758
commit e3286c87ba
20 changed files with 515 additions and 415 deletions

View File

@ -41,8 +41,8 @@ export class VoucherService {
}
getIncentive(date: string): Observable<Voucher> {
const options = {params: new HttpParams().set('t', 'Incentive').set('d', date)};
return <Observable<Voucher>>this.http.get<Voucher>(url, options)
const options = {params: new HttpParams().set('d', date)};
return <Observable<Voucher>>this.http.get<Voucher>(`${url}/incentive`, options)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);

View File

@ -2,6 +2,7 @@ import {Account} from './account';
import {User} from './user';
import {CostCentre} from './cost-centre';
import {Product} from './product';
import {Employee} from "../employee/employee";
export class Voucher {
id: string;
@ -45,7 +46,7 @@ export class EmployeeBenefit {
pfEmployee: number;
esiEmployer: number;
pfEmployer: number;
journal: Journal; // Should be employee as we need designation
employee: Employee;
}
export class Incentive {

View File

@ -15,9 +15,9 @@ export class EmployeeBenefitsResolver implements Resolve<Voucher> {
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Voucher> {
const id = route.paramMap.get('id');
if (id === null) {
return this.ser.getOfType('Salary Deduction');
return this.ser.getOfType('Employee Benefit');
} else {
return this.ser.get(id, 'Employee-Benefits');
return this.ser.get(id, 'Employee Benefit');
}
}
}

View File

@ -11,7 +11,7 @@ const employeeBenefitsRoutes: Routes = [
component: EmployeeBenefitsComponent,
canActivate: [AuthGuard],
data: {
permission: 'Salary Deduction'
permission: 'employee-benefit'
},
resolve: {
voucher: EmployeeBenefitsResolver
@ -23,7 +23,7 @@ const employeeBenefitsRoutes: Routes = [
component: EmployeeBenefitsComponent,
canActivate: [AuthGuard],
data: {
permission: 'Salary Deduction'
permission: 'employee-benefit'
},
resolve: {
voucher: EmployeeBenefitsResolver

View File

@ -37,19 +37,19 @@
<!-- Name Column -->
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.journal.account.name}}</mat-cell>
<mat-cell *matCellDef="let row">{{row.employee.name}}</mat-cell>
</ng-container>
<!-- Designation Column -->
<ng-container matColumnDef="designation">
<mat-header-cell *matHeaderCellDef>Designation</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.journal.account.designation}}</mat-cell>
<mat-cell *matCellDef="let row">{{row.employee.designation}}</mat-cell>
</ng-container>
<!-- Department Column -->
<ng-container matColumnDef="department">
<mat-header-cell *matHeaderCellDef>Department</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.journal.account.costCentre.name}}</mat-cell>
<mat-cell *matCellDef="let row">{{row.employee.costCentre.name}}</mat-cell>
</ng-container>
<!-- GrossSalary Column -->

View File

@ -6,7 +6,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {BehaviorSubject, Observable, of as observableOf} from 'rxjs';
import {EmployeeBenefitsDataSource} from './employee-benefits-datasource';
import {VoucherService} from '../core/voucher.service';
import {EmployeeBenefit, Journal, Voucher} from '../core/voucher';
import {EmployeeBenefit, Voucher} from '../core/voucher';
import * as moment from 'moment';
import {AuthService} from '../auth/auth.service';
import {ConfirmDialogComponent} from '../shared/confirm-dialog/confirm-dialog.component';
@ -106,7 +106,7 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit {
}
addRow() {
const oldFiltered = this.voucher.employeeBenefits.filter((x) => x.journal.account.id === this.employee.id);
const oldFiltered = this.voucher.employeeBenefits.filter((x) => x.employee.id === this.employee.id);
if (oldFiltered.length) {
this.toaster.show('Danger', 'Employee has already been added');
return;
@ -121,7 +121,7 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit {
const pf = this.getPf(grossSalary, daysWorked, daysInMonth);
this.voucher.employeeBenefits.push({
journal: new Journal({account: new Account(this.employee)}),
employee: this.employee,
grossSalary: grossSalary,
daysWorked: daysWorked,
esiEmployee: esi.ee,

View File

@ -10,7 +10,7 @@ const employeeFunctionsRoutes: Routes = [
component: EmployeeFunctionsComponent,
canActivate: [AuthGuard],
data: {
permission: 'Salary Deduction'
permission: 'employee-benefit'
},
runGuardsAndResolvers: 'always'
}

View File

@ -11,7 +11,7 @@ const incentiveRoutes: Routes = [
component: IncentiveComponent,
canActivate: [AuthGuard],
data: {
permission: 'Incentive'
permission: 'incentive'
},
resolve: {
voucher: IncentiveResolver
@ -23,7 +23,7 @@ const incentiveRoutes: Routes = [
component: IncentiveComponent,
canActivate: [AuthGuard],
data: {
permission: 'Incentive'
permission: 'incentive'
},
resolve: {
voucher: IncentiveResolver

View File

@ -51,7 +51,7 @@
<button matPrefix (click)="less(row, i)">
<mat-icon>remove</mat-icon>
</button>
<input matInput formControlName="points" autocomplete="off">
<input matInput formControlName="points" autocomplete="off" (change)="change(row, i)">
<button matSuffix color="warn" (click)="more(row, i)">
<mat-icon>add</mat-icon>
</button>

View File

@ -109,6 +109,11 @@ export class IncentiveComponent implements OnInit {
}
}
change(row: Incentive, i: number) {
row.points = +(this.form.get('incentives').get('' + i).get('points').value);
this.form.get('incentives').get('' + i).setValue({'points': '' + row.points});
}
more(row: Incentive, i: number) {
row.points += 1;
this.form.get('incentives').get('' + i).setValue({'points': '' + row.points});
@ -160,7 +165,6 @@ export class IncentiveComponent implements OnInit {
this.voucher.incentives.forEach((item, index) => {
item.points = array.controls[index].value.points;
});
this.voucher.narration = formModel.narration;
return this.voucher;
}