You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemm_srca/Mohem/src/app/payslip/home/home.component.ts

195 lines
5.1 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import {PayslipService} from '../service/payslip.service'
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
})
export class HomeComponent implements OnInit {
selEmp: string;
respID: number;
selMenu: MenuResponse;
GetPayslipList:any='';
GetSummaryOfPaymentList:any='';
GetPaymentInformationList:any='';
showPaySlip:any=[];
ActionContextID:any;
public static ACTION_CONTEXT_ID = "passActionContectID";
GetEarningsList: any='';
GetDeductionsList: any='';
earingTotal: any;
deductionTotal: any;
constructor(
public payslipService:PayslipService,
public ts: TranslatorService,
public common: CommonService,
public sharedData: SharedDataService,
) {}
ngOnInit() {
console.log("test");
this.selEmp = this.common.sharedService.getSharedData(
MenuResponse.SHARED_SEL_EMP,
false
);
console.log(" this.selEmp" + this.selEmp);
this.respID = this.common.sharedService.getSharedData(
MenuResponse.SHARED_SEL_RESP_ID,
false
);
console.log(" this.respID" + this.respID);
this.selMenu = new MenuResponse();
this.selMenu = this.common.sharedService.getSharedData(
MenuResponse.SHARED_DATA,
false
);
console.log(" this.selMenu" + this.selMenu);
this.getPayslip();
}
getPayslip(){
const request = {
P_SELECTED_EMPLOYEE_NUMBER: this.selEmp,//'125346',//this.selEmp,
P_MENU_TYPE: this.selMenu.List_Menu.MENU_TYPE,// 'E',//this.selMenu.List_Menu.MENU_TYPE,
P_SELECTED_RESP_ID:this.respID//"-999" //this.respID,
// P_PAGE_NUM: this.P_PAGE_NUM,
// P_PAGE_LIMIT: this.P_PAGE_LIMIT
};
this.payslipService.getPayslip(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handleRespondGetPayslipResult(result);
}
);
}
handleRespondGetPayslipResult(result){
if (result.GetPayslipList != null) {
this.GetPayslipList = result.GetPayslipList;
}
}
// showPaymentInfo
showInfo(event){
console.log(event.detail.value);
const index = parseInt(event.detail.value);
this.showPaySlip =this.GetPayslipList[index];
this.ActionContextID=this.GetPayslipList[index].ACTION_CONTEXT_ID;
this.common.sharedService.setSharedData(this.ActionContextID,HomeComponent.ACTION_CONTEXT_ID);
this.getSummeryOfPayment(this.ActionContextID);
this.getPaymentInfo(this.ActionContextID);
this.getDeduction(this.ActionContextID);
this.getEarings(this.ActionContextID);
}
getSummeryOfPayment(ActionContextID){
const request = {
P_ACTION_CONTEXT_ID: ActionContextID,
};
this.payslipService.getSummeryOFPayment(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handleSummeryOfPaymentResult(result);
}
);
}
handleSummeryOfPaymentResult(result){
if (result.GetSummaryOfPaymentList != null) {
this.GetSummaryOfPaymentList = result.GetSummaryOfPaymentList[0];
this.earingTotal = this.GetSummaryOfPaymentList.TOTAL_EARNINGS_AMOUNT;
this.deductionTotal = this.GetSummaryOfPaymentList.TOTAL_DEDUCTIONS_AMOUNT;
}
}
getPaymentInfo(ActionContextID){
const request = {
P_ACTION_CONTEXT_ID: ActionContextID,
};
this.payslipService.getPaymentInfo(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handleGetPaymentInfoResult(result);
}
);
}
handleGetPaymentInfoResult(result){
if (result.GetPaymentInformationList != null) {
this.GetPaymentInformationList = result.GetPaymentInformationList[0];
}
}
openEarings(){
this.common.openEarningsPage();
}
openDeductions(){
this.common.openDeductionsPage();
}
getEarings(ActionContextID){
const request = {
P_ACTION_CONTEXT_ID: ActionContextID,
P_PAGE_NUM: 1,
P_PAGE_LIMIT: 1000
};
this.payslipService.getEarings(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handleGetEaringsResult(result);
}
);
}
handleGetEaringsResult(result){
if (result.GetEarningsList != null) {
this.GetEarningsList = result.GetEarningsList;
}
}
getDeduction(ActionContextID){
const request = {
P_ACTION_CONTEXT_ID: ActionContextID,
P_PAGE_NUM: 1,
P_PAGE_LIMIT: 1000
};
this.payslipService.getDeduction(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handleGetDeductionResult(result);
}
);
}
handleGetDeductionResult(result){
if (result.GetDeductionsList != null) {
this.GetDeductionsList = result.GetDeductionsList;
}
}
}