1import{a as we}from"./chunk-I6QFWMCH.js";import{a as ti,b as ii}from"./chunk-DWHLWXZ3.js";import{a as ai}from"./chunk-365QIPN4.js";import{a as at}from"./chunk-AS6BC4OJ.js";import{a as Zt}from"./chunk-YKGUSPLS.js";import"./chunk-Y6I7GTPN.js";import{a as ei}from"./chunk-QKHIHIK2.js";import{a as Xt}from"./chunk-B77MZDE7.js";import{a as Wt}from"./chunk-CBC34OC2.js";import"./chunk-2QEZHR3Q.js";import"./chunk-LUOCW6HQ.js";import{a as Qt}from"./chunk-GRCKWKXN.js";import"./chunk-3XTQ6TTI.js";import{a as Yt}from"./chunk-JYH4CEVU.js";import"./chunk-HXAL5LGP.js";import{a as oe,b as X}from"./chunk-OHZXVWME.js";import"./chunk-YXJBJXEH.js";import"./chunk-K6SPPEPZ.js";import{a as Jt}from"./chunk-X3RSROO6.js";import{a as Kt}from"./chunk-P6BYWFI2.js";import{a as qt}from"./chunk-QDCFFCPG.js";import{a as Xe}from"./chunk-LOSZH6LX.js";import{a as Ee}from"./chunk-QYBXKO73.js";import{a as Ne}from"./chunk-SC7OIAJ7.js";import{b as xt,c as Mt,d as zt,e as Ut,f as it}from"./chunk-OT7D67RG.js";import{a as Ht}from"./chunk-FTHQQTSG.js";import{a as $t}from"./chunk-VEH24MDR.js";import"./chunk-L22N5WJT.js";import{a as Vt}from"./chunk-WG7WEUJG.js";import{a as jt,c as ye}from"./chunk-VGGK7HQB.js";import"./chunk-J6WHBBPP.js";import{a as Ot}from"./chunk-MKF6QG6V.js";import"./chunk-HOI7JMLX.js";import{a as Gt}from"./chunk-B3XBM5MD.js";import{b as Le}from"./chunk-XGLRQSSV.js";import"./chunk-DAOPRFTB.js";import"./chunk-4OCSXWTB.js";import{c as Bt}from"./chunk-MVFZ4W5S.js";import"./chunk-NL46MEWC.js";import{a as be,b as Ce}from"./chunk-QPO6AB24.js";import"./chunk-T2LKHT2R.js";import{a as qe}from"./chunk-AV7BHVMF.js";import"./chunk-ECX4OUPM.js";import"./chunk-D5ZZMR3T.js";import"./chunk-LB7GZ4RS.js";import{a as Ft}from"./chunk-MN2O4OIW.js";import{a as Ye,k as _e,l as de,m as H}from"./chunk-XJIYDCB7.js";import"./chunk-OOAKO2NW.js";import"./chunk-CW3A6GGH.js";import"./chunk-LLNDO5TI.js";import"./chunk-LK2H5GWW.js";import"./chunk-LLNUHMNV.js";import"./chunk-QUSGVUOF.js";import"./chunk-CJPLD6EO.js";import"./chunk-PDZ2GFID.js";import{a as wt}from"./chunk-O7GVHEWQ.js";import"./chunk-4W4OTVCU.js";import"./chunk-UBZHVILN.js";import"./chunk-WECRXZVT.js";import"./chunk-SXSN5XUL.js";import"./chunk-XGQFJQG5.js";import"./chunk-7MFB5OWF.js";import{a as Nt}from"./chunk-TH4X4PKG.js";import"./chunk-C6BZFLMK.js";import"./chunk-IDHC3I6D.js";import"./chunk-TVZI3GRT.js";import{a as Re}from"./chunk-EMD5D3CD.js";import{f as Pt}from"./chunk-P7NG7HPQ.js";import"./chunk-CZPI7VJ5.js";import{j as It}from"./chunk-4VN4MCU7.js";import{a as Je}from"./chunk-7GVDXUAU.js";import"./chunk-4J4X5EMA.js";import"./chunk-ECECGNR4.js";import"./chunk-2IWGUN3K.js";import{a as Et}from"./chunk-NCZHNS3C.js";import"./chunk-GO7UHMBF.js";import{c as vt}from"./chunk-5DDWRNUO.js";import{a as bt,ca as _t,da as O,p as Ct,q as At,r as Rt,s as Ae,va as ce}from"./chunk-6ZVTRFTL.js";import"./chunk-P76QNSQL.js";import{A as He,d as Pe,h as Me,n as ze,s as Ue}from"./chunk-Z34FZIQM.js";import"./chunk-SM5FSVVY.js";import"./chunk-TDDXVLK3.js";import{Aa as Se,Ab as Q,Ba as d,Ca as $e,Ea as ae,Ec as kt,Fa as We,Gb as De,Ja as Y,La as tt,Qa as G,Va as re,Xa as Ke,Ya as D,cb as q,fb as Be,gb as w,jb as Te,kc as Z,ob as Tt,pc as le,sc as yt,tb as S,ua as gt,uc as J,vc as W,xb as Dt,ya as St}from"./chunk-XVA3MWZK.js";import{f as ft}from"./chunk-IJOWPJZI.js";import{d as Lt,e as se}from"./chunk-U32DLQYF.js";import{Aa as lt,Ac as ve,Bc as x,Cc as xe,Fc as et,Ga as ct,Kb as V,Lb as j,Mc as R,Nc as _,Qb as g,Rb as u,Rc as ut,Sb as T,Tb as F,U as he,_b as ne,bb as v,cc as A,cd as pt,e as nt,ec as N,ha as C,ic as ue,jc as te,kc as ie,mb as dt,oa as z,oc as ke,pa as U,rb as B,tc as pe,uc as mt,vc as ht,w as $,wb as K,xb as Ge,yc as fe,zc as ge}from"./chunk-FCFRADKE.js";import{a as l,b as ee,h as me,j as k}from"./chunk-XHGXIXF6.js";var Ve=me(Re());function ui(c,P){if(c&1){let t=ne();u(0,"div",1)(1,"app-common-data-grid",2),R(2,"mciTranslate"),A("gridReady",function(e){z(t);let a=N();return U(a.onLaborGridReady(e))})("onRowSelect",function(){z(t);let e=N();return U(e.rowSelected())}),T()()}if(c&2){let t=N();v(),g("fileName",x(_(2,19,"L.Labor_Allocated")))("columnDefinition",t.colDefsLabor)("detailGrid",!0)("getRowIdCB",t.getRowIdCallBack)("gridData",t.laborData)("gridHeight",t.laborCount*t.gridRowHeight+t.gridBufferSpace)("gridName",t.laborData[0]==null||t.laborData[0].resource==null?null:t.laborData[0].resource.name)("isSliderGrid",!0)("masterDetail",!0)("menuEventCB",t.menuEventCallBack)("pageSize",t.laborCount)("showAddButton",!1)("showGridAcceptButton",!1)("showGridDeleteButton",!1)("showGridSettings",!1)("showGridStatusButton",!1)("showPaginator",!1)("showSelectedRowCount",!1)}}var ri=(()=>{class c{constructor(){this.mathService=C(Et),this.modalService=C(kt),this.viewRef=C(dt),this.dateTimeService=C(ce),this.mciTranslateService=C(Lt),this.compareService=C(Nt),this.uiUtilitiesService=C(Pt),this.mciGridService=C(wt),this.exceptionIconService=C(jt),this.laborCount=0,this.gridBufferSpace=64,this.gridRowHeight=40,this.laborData=[],this.colDefsLabor=[],this.canViewGLAccount=!1,this.customFields=[],this.menuEventCallBack=t=>
1{this.parentParams.resourceClicked(t.actionType,t.rowData)}}agInit(t){this.eventsSubscription=t.clickEvents.subscribe(()=>this.refresh()),this.parentParams=t,this.permissions=this.parentParams?.getPermissions(),this.canViewGLAccount=this.parentParams?.getCanViewGLAccount?.()??!1,this.dataItem=t.data,this.masterGridApi=t.api,this.rowId=t.node.id,this.getData(),this.configurePopupOptions(),this.setColumnDefs()}configurePopupOptions(){let t=[{action:d.VIEW,canAct:this.permissions?.canView},{action:d.EDIT,canAct:this.permissions?.canEdit},{action:d.DELETE,canAct:this.permissions?.canDelete}];this.popupOptions=t.filter(i=>i.canAct).map(i=>i.action)}setColumnDefs(){let t=[{headerName:G.CONTEXTMENU,context:{isMenuEvent:!0},cellRenderer:"materialGridMenu",cellRendererParams:{buttons:this.popupOptions,filterButtons:(e,a)=>{let r=e?.state?.id;return r===w.ALLOCATED||r===w.REVOKED?e?.isnegativeallocation?a?.filter(s=>s!==d.EDIT):a:r!==w.ALLOCATED&&r!==w.VOIDED&&r!==w.REJECTED?a?.filter(s=>s!==d.DELETE&&s!==d.ACCEPT&&s!==d.EDIT):a?.filter(s=>s!==d.ACCEPT)}}},{headerName:this.mciTranslateService.getTranslation(G.EXCEPTION),field:"exceptions",cellRenderer:"exceptionIconCell",context:{excludeExcelExport:!1,isAutoSize:!0},cellRendererParams:e=>({iconClickEvent:a=>{this.onExceptionIconClick(a,e.data)}})},{field:"state",headerName:this.mciTranslateService.getTranslation("L.State"),cellRenderer:"globalStatesCellRenderer"},{field:"agreement.name",headerName:this.mciTranslateService.getTranslation("L.Agreement"),valueFormatter:e=>e.value??O},{field:"skill.name",headerName:this.mciTranslateService.getTranslation("L.Skill"),valueFormatter:e=>e.value??O},{field:"costobject.ordertype.name",headerName:this.mciTranslateService.getTranslation("L.Order_Type"),filter:"agTextColumnFilter",valueGetter:e=>this.uiUtilitiesService.getOrderTypeTranslation(e.data?.costobject?.ordertype?.name)},{field:"costobject.purchaseorder.name",headerName:this.mciTranslateService.getTranslation("L.Purchase_Order"),filter:"agTextColumnFilter"},{field:"costobject.purchaseorderline.name",headerName:this.mciTranslateService.getTranslation("L.PO_Line"),filter:"agTextColumnFilter"},{field:"costobject.labelname",headerName:this.mciTranslateService.getTranslation("L.Cost_Object_Type"),filter:"agTextColumnFilter"},{field:"costobject.name",headerName:this.mciTranslateService.getTranslation("L.Cost_Object"),filter:"agTextColumnFilter"},{field:"costobject.operation.name",headerName:this.mciTranslateService.getTranslation("L.Operation_Or_Activity"),filter:"agTextColumnFilter"},{field:"costobject.suboperation.name",headerName:this.mciTranslateService.getTranslation("L.Sub_Operation_Or_Element"),filter:"agTextColumnFilter"},{field:"area.labelname",headerName:this.mciTranslateService.getTranslation("L.Area_ID"),filter:"agTextColumnFilter",context:{isAutoSize:!0}},{field:"glaccount.name",headerName:this.mciTranslateService.getTranslation("L.GL_Account"),cellRenderer:e=>e.value??O,filter:"agTextColumnFilter",hide:!this.canViewGLAccount}],i=[l({field:"hours.st",headerName:this.mciTranslateService.getTranslation("L.ST"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.st??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.ot",headerName:this.mciTranslateService.getTranslation("L.OT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.ot??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.dt",headerName:this.mciTranslateService.getTranslation("L.DT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.dt??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r4",headerName:this.mciTranslateService.getTranslation("L.R4"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r4??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r5",headerName:this.mciTranslateService.getTranslation("L.R5"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r5??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r6",headerName:this.mciTranslateService.getTranslation("L.R6"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r6??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r7",headerName:this.mciTranslateService.getTranslation("L.R7"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r7??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r8",headerName:this.mciTranslateService.getTranslation("L.R8"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r8??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r9",headerName:this.mciTranslateService.getTranslation("L.R9"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r9??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r10",headerName:this.mciTranslateService.getTranslation("L.R10"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r10??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r11",headerName:this.mciTranslateService.getTranslation("L.R11"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r11??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r12",headerName:this.mciTranslateService.getTranslation("L.R12"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r12??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r13",headerName:this.mciTranslateService.getTranslation("L.R13"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r13??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r14",headerName:this.mciTranslateService.getTranslation("L.R14"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r14??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r15",headerName:this.mciTranslateService.getTranslation("L.R15"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r15??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"othercharges",headerName:this.mciTranslateService.getTranslation("L.Other_Charge"),cellRenderer:e=>{let a=this.mathService.formatNumber(e.value);return this.mciGridService.cellWithSuffix(a,e?.data?.currency?.code)},valueGetter:e=>this.mathService.roundDisplay(e?.data?.othercharges??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),{field:"isnonbillable",headerName:this.mciTranslateService.getTranslation("L.Non_Billable"),cellRenderer:"gridSwitch",headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",cellRendererParams:{canActivate:this.permissions?.canActivate,canDeactivate:this.permissions?.canDeactivate},context:{isMenuEvent:!0,isAutoSize:!0},resizable:!1},{field:"isfixedfee",headerName:this.mciTranslateService.getTranslation("L.Lump_Sum"),cellRenderer:"gridSwitch",headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",cellRendererParams:{canActivate:this.permissions?.canActivate,canDeactivate:this.permissions?.canDeactivate},context:{isMenuEvent:!0,isAutoSize:!0},resizable:!1},{field:"issubcontractor",headerName:this.mciTranslateService.getTranslation("L.Sub_Contractor"),cellRenderer:"gridSwitch",headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",cellRendererParams:{canActivate:this.permissions?.canActivate,canDeactivate:this.permissions?.canDeactivate},context:{isMenuEvent:!0,isAutoSize:!0},resizable:!1},l({field:"hours.total",headerName:this.mciTranslateService.getTranslation("L.Total_Hours"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.total??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),{headerName:this.mciTranslateService.getTranslation("L.Attachment"),headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",field:"attachmentscount",cellRenderer:"materialGridIcon",cellRendererParams:e=>e?.data?{icon:"attach_file",isDisplayValue:!0,propertyName:"attachmentscount",displayValueCb:a=>Ve.default.isEmpty(a?.data?.attachments)?0:a?.data?.attachments?.length,disabled:Ve.default.isEmpty(e?.data?.attachments),clickEvent:a=>{let r=Ve.default.isEmpty(a?.attachments)?[]:a?.attachments;if(r?.length){let s={id:a?.id,attachmentData:r},n=Ve.default.clone(this.permissions);n.canDelete=!1,this.modalService.openAttachmentModal(this.viewRef,s,this.mciTranslateService.getTranslation("L.Labor_Override_Request"),d.VIEW,n)}}}:{},comparator:this.compareService.attachmentComparator,context:{isAutoSize:!0},resizable:!1},{field:"comment",cellRenderer:"commentCell",headerName:this.mciTranslateService.getTranslation(G.COMMENT)},{field:"timesheetreference",headerName:this.mciTranslateService.getTranslation("L.Timesheet_Num"),context:{displayFieldName:""},filterParams:{valueGetter:e=>e.data?.timesheetreference?.split(",")}},{field:"revoketimesheetref",headerName:this.mciTranslateService.getTranslation("L.Revoked_Timesheet_Num"),context:{displayFieldName:""},filterParams:{valueGetter:e=>e.data?.revoketimesheetref?.split(",")}},{field:"lastedited.date",headerName:this.mciTranslateService.getTranslation("L.Last_Edited"),type:"rightAligned",filter:"agDateColumnFilter",valueGetter:e=>this.dateTimeService.toLocalizedDateHourMinFormat(e.data.lastedited?.date),filterParams:{comparator:this.dateTimeService.localizedDateHourMinFilterComparator},comparator:this.dateTimeService.localizedDateHourMinComparator,context:{isAutoSize:!0}},{field:"lastedited.user",headerName:this.mciTranslateService.getTranslation("L.Edited_By")}];this.customFields=this.mciGridService.prepareDynamicCustomFieldColumnDefs(this.laborData,"name","name","type"),this.colDefsLabor=[...t,...this.customFields,...i]}
1onExceptionIconClick(t,i){switch(t){case S.PAY_FORMULA_MISSING:case S.SCHEDULE_MISSING:case S.RUNNER:case S.REVOKED:case S.RISK_ATTRIBUTE_EXPIRED:case S.OVERRIDE_APPROVE:case S.OVERRIDE_REJECT:case S.OVERRIDE_REQUEST:case S.OVERRIDE_DECLINE:{let e={exceptionIcon:t,extraData:{resourceId:i?.resource?.id,timesheetDate:i.workdate,organizationId:i.organization.id,timesheetId:i.timesheetid,timesheetRef:i.timesheetreference&&i.timesheetreference.trim()!==""?i.timesheetreference:i.revoketimesheetref}};this.exceptionIconService.onExceptionIconClick(e);break}default:break}}getData(){this.dataItem&&(this.dataItem?.childData.filter(t=>{t.attachments=this.uiUtilitiesService.formatStringWithMultipleArray(t.attachments),t.attachmentscount=t.attachments?.length??0,t.exceptions&&typeof t.exceptions=="object"&&(t.exceptions={hasrateadjustment:!!t.exceptions.hasrateadjustment,isrevoked:!!t.exceptions.isrevoked})}),this.laborData=this.dataItem?.childData,this.laborCount=this.laborData?.length)}refresh(){return this.selectCorrectCells(this.laborData,this.parentParams.node.parent.data.laborChildRowsSelected,this.gridApiLabor),!1}onLaborGridReady(t){this.gridApiLabor=t.api;let i={id:this.rowId,api:this.gridApiLabor};this.masterGridApi.addDetailGridInfo(this.rowId,i),this.mciGridService.determineRateColumnVisibility(this.colDefsLabor,this.laborData,this.gridApiLabor),this.selectCorrectCells(this.laborData,this.parentParams.node.parent.data.laborChildRowsSelected,this.gridApiLabor)}selectCorrectCells(t,i,e){this.parentParams.node.parent.isSelected()&&t?.length>0&&i?e?.forEachNode(a=>{a.setSelected(i.filter(r=>r?.id===a?.data?.id).length>0)}):i?.length||e?.forEachNode(a=>{a.setSelected(!1)}),e?.refreshCells()}getRowIdCallBack(t){return t.data.id=t.data?.allocations?.replaceAll('"',"").split(",")[0],t.data.id}ngOnDestroy(){this.eventsSubscription.unsubscribe(),this.masterGridApi?.removeDetailGridInfo(this.rowId)}rowSelected(){this.parentParams.node.parent.data.laborChildRowsSelected=this.gridApiLabor?this.gridApiLabor.getSelectedRows():[];let t=this.parentParams.node.parent.data.laborChildRowsSelected.length;this.parentParams.node.parent.data.rowsSelected=t,t===0?this.parentParams.node.parent.setSelected(!1):this.parentParams.node.parent.setSelected(!0),this.parentParams.childrenSelected(),this.masterGridApi?.refreshCells()}static{this.\u0275fac=function(i){return new(i||c)}}static{this.\u0275cmp=B({type:c,selectors:[["app-labor-allocated-detail-grid"]],decls:2,vars:1,consts:[["id","grid-detail-section",1,"mci-ui-nested-table-container"],[1,"mci-ui-nested-table"],[3,"gridReady","onRowSelect","columnDefinition","detailGrid","getRowIdCB","gridData","gridHeight","gridName","isSliderGrid","masterDetail","menuEventCB","pageSize","showAddButton","showGridAcceptButton","showGridDeleteButton","showGridSettings","showGridStatusButton","showPaginator","showSelectedRowCount","fileName"]],template:function(i,e){i&1&&(u(0,"div",0),V(1,ui,3,21,"div",1),T()),i&2&&(v(),j(e.laborCount?1:-1))},dependencies:[H,se],encapsulation:2})}}return c})();var Qe=me(Re());function fi(c,P){if(c&1&&(F(0,"drawer-header-dynamic-content",0),R(1,"localizedDate")),c&2){let t=N();g("subTitle2",xe("| ",_(1,3,t.rowData==null?null:t.rowData.workdate)))("globalStateCode",t.rowData==null||t.rowData.summarystatus==null?null:t.rowData.summarystatus.code)}}var si=(()=>{class c extends qe{constructor(){super(...arguments),this.allocationService=C(X),this.gridData=[],this.hasOtherStates=!1,this.customFields=[],this.isTimesheetDateGreaterToday=!1,this.canViewAcceptance=!0,this.canViewGLAccount=!1,this.canViewRates=!1,this.activityCodesEnabled=!1}onSave(){throw new Error("Method not implemented.")}getTranslations(){this.entity=this.mciTranslateService.getTranslation("L.Allocation"),this.entityPlural=this.mciTranslateService.getTranslation("L.Allocations")}ngOnInit(){this.mciTranslateService.onLangChange.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(()=>{this.getTranslations(),this.setColumnDefs(),this.gridApi?.refreshHeader()}),this.getTranslations(),this.initializeForm(),this.drawerService.formConfig$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>
1{if(t!=null){let{rowData:i,actionType:e,permissions:a,extraData:r}=t;this.rowData=i,this.actionType=e,this.permissions=a,this.canViewAcceptance=r?.canViewAcceptance??!0,this.isTimesheetDateGreaterToday=!(new Date(this.rowData?.workdate)>new Date&&!r?.allowLaborFutureDates),this.recordName=`${this.rowData?.resource?.name} (${this.rowData?.resource?.laborid})`,this.canViewGLAccount=r?.canViewGLAccount??!1,this.activityCodesEnabled=r?.activityCodesEnabled??!1,this.canViewRates=r?.canViewRates??!1,this.drawerService.drawer$.value.form?this.form=this.drawerService.drawer$.value.form:this.initializeForm(),this.getAllocatedResource(i)}}),this.drawerService.drawerFooterAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{if(t!=null)switch(t){case this.ACTIONS.CLOSE:case this.ACTIONS.CANCEL:this.onFormClose();break;case this.ACTIONS.ACCEPT:this.onAccept();break}})}initializeForm(){this.form=this.formBuilder.group({group:"",organization:""})}onGridReady(t){this.gridApi=t.api,this.setColumnDefs()}getAllocatedResource(t){let i={OrganizationId:t.organization?.id,TimesheetDate:this.dateTimeService.toISODateFormat(t.workdate),ResourceId:t.resource?.id};this.allocationService.getLaborAllocatedResource(i).subscribe(e=>{e[0]?.data?.length&&(e[0]?.data.forEach(a=>{this.hasOtherStates||(this.hasOtherStates=a?.state?.code!==at.ALLOCATED&&a?.state?.code!==at.PARTIALLY_ALLOCATED)}),this.prepareAllocationData(e[0]?.data),this.setColumnDefs(),this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi),this.updateFooterButton())})}prepareAllocationData(t){this.customFields=this.mciGridService.prepareDynamicCustomFieldColumnDefs(t,"name","name","format"),this.gridData=t}setColumnDefs(){let t=[{field:"state",headerName:this.mciTranslateService.getTranslation("L.State"),cellRenderer:"globalStatesCellRenderer"},{field:"agreement.name",headerName:this.mciTranslateService.getTranslation("L.Agreement"),filter:"agTextColumnFilter"},{field:"skill.name",headerName:this.mciTranslateService.getTranslation("L.Skill"),cellEditor:"materialInputEditor",filter:"agTextColumnFilter"},{field:"costobject.ordertype.name",headerName:this.mciTranslateService.getTranslation("L.Order_Type"),filter:"agTextColumnFilter",valueGetter:e=>this.uiUtilitiesService.getOrderTypeTranslation(e.data?.costobject.ordertype.name)},{field:"costobject.purchaseorder.name",headerName:this.mciTranslateService.getTranslation("L.Purchase_Order"),filter:"agTextColumnFilter"},{field:"costobject.purchaseorderline.name",headerName:this.mciTranslateService.getTranslation("L.Purchase_Order_Line"),filter:"agTextColumnFilter"},{field:"costobject.labelname",headerName:this.mciTranslateService.getTranslation("L.Cost_Object_Type"),filter:"agTextColumnFilter"},{field:"costobject.name",headerName:this.mciTranslateService.getTranslation("L.Cost_Object"),filter:"agTextColumnFilter"},{field:"costobject.operation.name",headerName:this.mciTranslateService.getTranslation("L.Operation_Or_Activity"),filter:"agTextColumnFilter"},{field:"costobject.suboperation.name",headerName:this.mciTranslateService.getTranslation("L.Sub_Operation_Or_Element"),filter:"agTextColumnFilter"},{field:"area.name",headerName:this.mciTranslateService.getTranslation("L.Area_ID"),filter:"agTextColumnFilter",context:{isAutoSize:!0}},{field:"glaccount.code",headerName:this.mciTranslateService.getTranslation("L.GL_Account"),filter:"agTextColumnFilter",cellRenderer:e=>e.value||O,sortable:!0,context:{isAutoSize:!0},hide:!this.canViewGLAccount},{field:"activitycode.name",headerName:this.mciTranslateService.getTranslation("L.Activity_Code"),filter:"agTextColumnFilter",cellRenderer:e=>e.value||O,sortable:!0,context:{isAutoSize:!0},hide:!this.activityCodesEnabled}],i=[l({field:"hours.st",headerName:this.mciTranslateService.getTranslation("L.ST"),cellEditor:"materialInputEditor",cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.st??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.ot",headerName:this.mciTranslateService.getTranslation("L.OT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.ot??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.dt",headerName:this.mciTranslateService.getTranslation("L.DT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.dt??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r4",headerName:this.mciTranslateService.getTranslation("L.R4"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r4??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r5",headerName:this.mciTranslateService.getTranslation("L.R5"),editable:this.permissions?.canEdit,cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r5??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r6",headerName:this.mciTranslateService.getTranslation("L.R6"),editable:this.permissions?.canEdit,cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r6??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r7",headerName:this.mciTranslateService.getTranslation("L.R7"),editable:this.permissions?.canEdit,cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r7??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r8",headerName:this.mciTranslateService.getTranslation("L.R8"),editable:this.permissions?.canEdit,cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r8??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r9",headerName:this.mciTranslateService.getTranslation("L.R9"),editable:this.permissions?.canEdit,cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r9??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r10",headerName:this.mciTranslateService.getTranslation("L.R10"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r10??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r11",headerName:this.mciTranslateService.getTranslation("L.R11"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r11??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r12",headerName:this.mciTranslateService.getTranslation("L.R12"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r12??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r13",headerName:this.mciTranslateService.getTranslation("L.R13"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r13??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r14",headerName:this.mciTranslateService.getTranslation("L.R14"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r14??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r15",headerName:this.mciTranslateService.getTranslation("L.R15"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.hours?.r15??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"othercharges",headerName:this.mciTranslateService.getTranslation("L.Other_Charge"),cellRenderer:e=>{let a=this.mathService.formatNumber(e.value),r=e?.data?.currency?.code;return this.mciGridService.cellWithSuffix(a,r)},valueGetter:e=>this.mathService.roundDisplay(e?.data?.othercharges??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),{field:"isnonbillable",headerName:this.mciTranslateService.getTranslation("L.Non_Billable"),cellRenderer:"gridSwitch",headerClass:Z.CENTER_HEADER,cellClass:Z.CENTER_CELL,cellRendererParams:{canActivate:this.permissions?.canActivate,canDeactivate:this.permissions?.canDeactivate},context:{isMenuEvent:!0,isAutoSize:!0},resizable:!1},{field:"isfixedfee",headerName:this.mciTranslateService.getTranslation("L.Lump_Sum"),cellRenderer:"gridSwitch",headerClass:Z.CENTER_HEADER,cellClass:Z.CENTER_CELL,cellRendererParams:{canActivate:this.permissions?.canActivate,canDeactivate:this.permissions?.canDeactivate},context:{isMenuEvent:!0,isAutoSize:!0},resizable:!1},{field:"issubcontractor",headerName:this.mciTranslateService.getTranslation("L.Sub_Contractor"),cellRenderer:"gridSwitch",headerClass:Z.CENTER_HEADER,cellClass:Z.CENTER_CELL,cellRendererParams:{canActivate:this.permissions?.canActivate,canDeactivate:this.permissions?.canDeactivate},context:{isMenuEvent:!0,isAutoSize:!0},resizable:!1},{field:"comment",cellRenderer:"commentCell",headerName:this.mciTranslateService.getTranslation(G.COMMENT)},{field:"attachmentmetadata",headerName:this.mciTranslateService.getTranslation("L.Attachment"),headerClass:Z.CENTER_HEADER,cellClass:Z.CENTER_CELL,cellRenderer:"materialGridIcon",cellRendererParams:{icon:"attach_file",isDisplayValue:!0,displayValueCb:e=>Qe.default.isEmpty(e?.data?.attachments)?0:JSON.parse(e?.data?.attachments).length,clickEvent:e=>{let a=Qe.default.isEmpty(e?.attachments)?[]:JSON.parse(e?.attachments);if(a){let r={id:e.resource.id,attachmentData:a},s=Qe.default.clone(this.permissions);s.canDelete=!1,this.modalService.openAttachmentModal(this.viewRef,r,this.mciTranslateService.getTranslation("L.Labor_Allocation"),this.actionType,s,!0)}}},context:{isAutoSize:!0},resizable:!1},{field:"timesheetreference",headerName:this.mciTranslateService.getTranslation("L.Timesheet_Ref"),filter:"agTextColumnFilter",type:"rightAligned"},{field:"revoketimesheetref",headerName:this.mciTranslateService.getTranslation("L.Revoked_Timesheet_Num"),type:"rightAligned",cellRenderer:e=>e?.data?.revoketimesheetref,filterParams:{valueGetter:e=>e.data?.revoketimesheetref}}];this.columnDefs=[...t,...this.customFields,...i]}onAccept(){this.allocationService.onAcceptance([this.rowData],Ye.accepted,"summarystatus","resource",We.LABOR,"summarystatus","resourcegroup",!0)}updateFooterButton(){let t=this.canViewAcceptance&&this.actionType!==d.ADD&&this.isTimesheetDateGreaterToday&&(this.rowData?.summarystatus?.code===oe.ALLOCATED||this.rowData?.summarystatus?.code===oe.AUTHORIZED_UNACCEPTED),i=[{action:d.CLOSE,style:t?W.SECONDARY:W.PRIMARY,position:J.RIGHT,visible:this.actionType!==d.ADD},{action:d.ACCEPT,style:W.PRIMARY,position:J.RIGHT,visible:t,disabled:this.rowData?.state?.id!==w.ALLOCATED&&this.rowData?.state?.id!==w.AUTHORIZED_UNACCEPTED||this.rowData?.exceptions?.isbadgeerror}];this.uiUtilitiesService.updateDrawerFooterButtons(i,this.form)}getStringRender(t){return t!==""?t:O}static{this.\u0275fac=(()=>{let t;return function(e){return(t||(t=ct(c)))(e||c)}})()}static{this.\u0275cmp=B({type:c,selectors:[["app-labor-allocated-form"]],features:[K],decls:12,vars:20,consts:[[3,"globalStateCode","subTitle2"],[3,"formGroup"],[3,"disableRates","organizationId","resourceId","workDate"],[1,"row"],[1,"col-12"],[1,"mci-ui-card-flat-border","remove-horizontal-margin"],[3,"gridReady","columnDefinition","showCheckboxColumn","gridData","isSliderGrid","showAddButton","showGridDeleteButton","showGridStatusButton","fileName"]],template:function(i,e){i&1&&(V(0,fi,2,5,"drawer-header-dynamic-content",0),u(1,"form",1),F(2,"app-labor-pay-detail
1s",2),T(),u(3,"div",3)(4,"div",4)(5,"h6"),pe(6),R(7,"mciTranslate"),T()(),u(8,"div",4)(9,"div",5)(10,"app-common-data-grid",6),R(11,"mciTranslate"),A("gridReady",function(r){return e.onGridReady(r)}),T()()()()),i&2&&(j(!(e.rowData==null||e.rowData.state==null)&&e.rowData.state.code?0:-1),v(),g("formGroup",e.form),v(),g("disableRates",!e.canViewRates)("organizationId",e.rowData==null||e.rowData.organization==null?null:e.rowData.organization.id)("resourceId",e.rowData==null||e.rowData.resource==null?null:e.rowData.resource.id)("workDate",e.rowData==null?null:e.rowData.workdate),v(4),mt(_(7,16,"L.Allocation_Details")),v(4),g("fileName",x(_(11,18,"L.Labor_Allocation")))("columnDefinition",e.columnDefs)("showCheckboxColumn",!1)("gridData",e.gridData)("isSliderGrid",!0)("showAddButton",!1)("showGridDeleteButton",!1)("showGridStatusButton",!1))},dependencies:[Xe,He,ze,Me,Ue,Xt,H,se,Je],encapsulation:2})}}return c})();var Fe=me(Re());var gi=["commentRef"],vi=["jobDetails"],ni=()=>[];function Si(c,P){if(c&1&&(F(0,"drawer-header-dynamic-content",4),R(1,"localizedDate")),c&2){let t=N();g("subTitle2",xe("| ",_(1,3,t.rowData==null?null:t.rowData.workdate)))("globalStateCode",t.rowData==null||t.rowData.state==null?null:t.rowData.state.code)}}function Ti(c,P){if(c&1){let t=ne();u(0,"div",26)(1,"div",12)(2,"mci-form-control",27),R(3,"mciTranslate"),A("checkboxChange",function(e){z(t);let a=N();return U(a.noChangesClick(e))}),T()()(),F(4,"hr",14)}if(c&2){let t=N();v(2),g("checkBoxName",x(_(3,7,"L.No_Changes")))("actionType",t.actionType)("displayLabelName",!1)("displayViewField",!1)("form",t.form)("typeOfControl",t.CONTROL_TYPE.CHECKBOX)}}function Di(c,P){}function bi(c,P){if(c&1&&Ge(0,Di,0,0,"ng-template",10),c&2){N();let t=ke(60);g("ngTemplateOutlet",t)}}function Ci(c,P){}function Ai(c,P){if(c&1&&Ge(0,Ci,0,0,"ng-template",10),c&2){N(2);let t=ke(60);g("ngTemplateOutlet",t)}}function Ri(c,P){if(c&1){let t=ne();u(0,"mat-expansion-panel",7),A("afterCollapse",function(){z(t);let e=N();return U(e.sections.onCollapse("custom_fields"))}),u(1,"mat-expansion-panel-header",8),A("click",function(){z(t);let e=N();return U(e.sections.onClick("custom_fields"))}),u(2,"mat-panel-title"),F(3,"mci-accordion-panel-title",28),R(4,"mciTranslate"),T(),V(5,Ai,1,1,null,10),T(),u(6,"div",11)(7,"div",12),F(8,"app-dynamic-custom-fields",29),T()()(),F(9,"hr",14)}if(c&2){let t=N();g("expanded",!1),v(3),g("stepNumber",2)("titleLabel",_(4,13,"L.Custom_Fields"))("active",t.sections.isActive("custom_fields"))("done",t.isCustomFieldsDone)("required",t.actionType!==t.ACTIONS.VIEW&&t.hasRequiredCustomFields)("count",t.populatedCustomFieldsCount),v(2),j(t.actionType!==t.ACTIONS.VIEW&&(t.customForm!=null&&t.customForm.touched)&&(t.customForm!=null&&t.customForm.invali
1d)?5:-1),v(3),g("actionType",t.actionType)("customFields",t.customFields)("customFormGroup",t.customForm)("numberOfFieldsPerColumn",2)("showTitle",!1)}}function _i(c,P){}function Li(c,P){if(c&1&&Ge(0,_i,0,0,"ng-template",10),c&2){N();let t=ke(60);g("ngTemplateOutlet",t)}}function yi(c,P){if(c&1&&(F(0,"mci-select",18),R(1,"mciTranslate"),R(2,"mciTranslate")),c&2){let t=N();g("placeholder",x(_(1,9,"L.Select_Activity_Code")))("actionType",t.activityCodeActionType)("displayViewField",!0)("inputValues",t.activityCodeList)("labelName",_(2,11,"L.Activity_Code"))("required",t.isActivityCodeRequired)("selectDropdownForm",t.form)("viewFieldValue",t.form==null||t.form.controls==null||t.form.controls.activitycode==null?null:t.form.controls.activitycode.value)}}function Ei(c,P){if(c&1){let t=ne();u(0,"div",11)(1,"div",12)(2,"mat-label",30),pe(3),R(4,"mciTranslate"),T(),u(5,"div")(6,"button",31),A("click",function(){z(t);let e=N();return U(e.showFieldNotes())}),u(7,"mat-icon",32),R(8,"mciTranslate"),pe(9," event_note "),T()()()()()}c&2&&(v(3),ht(" ",_(4,3,"L.Field_Note")," "),v(4),g("matTooltip",x(_(8,5,"L.Field_Note"))))}function Ni(c,P){if(c&1){let t=ne();u(0,"mat-expansion-panel",7),A("afterCollapse",function(){z(t);let e=N();return U(e.sections.onCollapse("attachments"))}),u(1,"mat-expansion-panel-header",8),A("click",function(){z(t);let e=N();return U(e.sections.onClick("attachments"))}),u(2,"mat-panel-title"),F(3,"mci-accordion-panel-title",23),R(4,"mciTranslate"),T()(),u(5,"div")(6,"div",11)(7,"div",12)(8,"app-upload-attachment",33),A("uploadFiles",function(){z(t);let e=N();return U(e.onUploadFiles())})("uploadFilesId",function(e){z(t);let a=N();return U(a.onDownloadFiles(e))}),T()()()()(),F(9,"hr",14)}if(c&2){let t=N();g("expanded",!1),v(3),g("stepNumber",t.attachmentsStepNumber)("titleLabel",_(4,11,"L.Attachments"))("active",t.sections.isActive("attachments"))("done",!!(t.files!=null&&t.files.length))("count",(t.files==null?null:t.files.length)??0),v(5),g("actionType",t.actionType)("files",t.files??et(13,ni))("restrictActions",!0)("showDeleteButton",!1)("showTitle",!1)}}function wi(c,P){c&1&&(u(0,"mat-panel-description",34)(1,"mat-icon",35),pe(2,"fiber_manual_record"),T()())}var st=(function(c){return c.charge="charge",c.hours="hours",c})(st||{}),oi=["ordertype","purchaseorder","purchaseorderlines","costelementtype","workorder","networkorder","wbs","costcenter","internalorders","operation","suboperation","activity","element","areaid","glaccount"],Ze=(()=>{class c extends qe{static{this.PAY_TYPES=["ot","dt","st","r4","r5","r6","r7","r8","r9","r10","r11","r12","r13","r14","r15"]}constructor(){super(),this.allocationService=C(X),this.definitionCodesService=C(Ht),this.skillManagementService=C(Kt),this.changeDetector=C(pt),this.settingsService=C(Ot),this.organizationService=C($t),this.sections=new ti(["job_details","custom_fields","allocation_details","attachments","comments"],["job_details","allocation_details"],t=>this.drawerService.showAccordionExpandAllButton(t)),this.selectLocationMsg=this.mciTranslateService.getTranslation("L.Select_Location"),this.isFormClosed=!1,this.poDefaulting=!1,this.locationId="",this.organizationList=[],this.agreementList=[],this.shiftList=[],this.skillList=[],this.skillData=[],this.gridData=[],this.serverGridData=[],this.files=[],this.existingFiles=[],this.isFromAllocated=!1,this.isRevoked=!1,this.allocationIds=[],this.ALLOCATIONTYPES=Y,this.showEditButton=!0,this.valid=!0,this.isShowDiscardSelection=!0,this.checkboxOptions=[{fieldFormControlName:"isnonbillable",name:this.mciTranslateService.getTranslation("L.Non_Billable")},{fieldFormControlName:"isfixedfee",name:this.mciTranslateService.getTranslation("L.Lump_Sum")},{fieldFormControlName:"issubcontractor",name:this.mciTranslateService.getTranslation("L.Sub_Contractor")}],this.commentTypes=[this.mciTranslateService.getTranslation("L.Rejected_Allocations"),this.mciTranslateService.getTranslation("L.Reject_Allocation"),this.mciTranslateService.getTranslation("L.Void_Timesheets"),this.mciTranslateService.getTranslation("L.Revoke_Allocations")],this.isFixFeeNonBillable=!1,this.rateAdjustmentPersistArr={},this.isRateAdjustmentVisible=!1,this.existingRateAdjustments={},this.showRateAdjustmentOption=!1,this.isBlockAllocationMissing=!1,this.agreementSkillChangePermission=!1,this.activityCodeList=[],this.activityCodeEditPermission=!1,this.storePreviousValObj={},this.isDiscardSelectionOpen=!1,this.isRateAdjustmentApplied=!1,this.parentAllocateData={},this.rateAdjustModalData={},this.canViewRates=!1,this.selectedOrderType={},this.none=this.mciTranslateService.getTranslation("L.None"),this.allocationTranslation=this.mciTranslateService.getTranslation("L.Allocation"),this.allocationPluralTranslation=this.mciTranslateService.getTranslation("L.Allocations"),this.rateAdjustmentTranslation=this.mciTranslateService.getTranslation("L.Rate_Adjustment"),this.rateAdjustmentPluralTranslation=this.mciTranslateService.getTranslation("L.Rate_Adjustments"),this.isCurrentAllocatedEditable=t=>(t.data.type==="charge"?!(this.form?.controls?.isnonbillable?.value||this.form?.controls?.isfixedfee?.value||this.form?.controls?.issubcontractor?.value):!0)&&
1!this.form?.get("nochanges")?.value&&this.actionType!==d.VIEW,this.onModalClose=t=>{if(t)if(t?.eventname==="save")t?.ratekeys?.length?(this.isRateAdjustmentApplied=t?.isRateAdjustmentSave,this.rateAdjustmentPersistArr[`${this.form.controls?.agreement?.value?.id}-${this.form.controls?.skill?.value?.id}`]=t?.rates,this.applyRateAdjustmentValues(t?.rates)):(this.isRateAdjustmentApplied=t?.isRateAdjustmentSave,this.rateAdjustmentPersistArr[`${this.form.controls?.agreement?.value?.id}-${this.form.controls?.skill?.value?.id}`]=t?.rates,this.applyRateAdjustmentValues(t?.rates),this.gridApi?.refreshCells()),this.form.markAsDirty();else{let i=this.rateAdjustmentPersistArr[`${this.form.controls?.agreement?.value?.id}-${this.form.controls?.skill?.value?.id}`]??{};Object.keys(i)?.length>0?(this.isRateAdjustmentApplied=!0,this.applyRateAdjustmentValues(i)):this.isRateAdjustmentApplied=!1}},this.saveWithAttachment=this.saveWithAttachment.bind(this)}getTranslations(){this.isFromAllocated?(this.entity=this.allocationTranslation,this.entityPlural=this.allocationPluralTranslation,this.subTitleEntityName=this.allocationTranslation):(this.entity=this.allocationTranslation,this.entityPlural=this.allocationPluralTranslation,this.subTitleEntityName=this.mciTranslateService.getTranslation("L.Unresolved_Allocation")),this.skillTranslatedLabel=this.mciTranslateService.getTranslation("L.Skill"),this.agreementTranslatedLabel=this.mciTranslateService.getTranslation("L.Agreement"),this.chargeTranslated=this.mciTranslateService.getTranslation("L.Charge"),this.hoursTranslated=this.mciTranslateService.getTranslation("L.Hours")}ngAfterContentChecked(){this.changeDetector.detectChanges()}ngAfterViewInit(){this.drawerService.accordionData({defaultExpand:!0,accordionObj:this.accordion})}ngOnInit(){this.mciTranslateService.onLangChange.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(()=>{this.getTranslations(),this.setColumnDefs(),this.gridApi?.refreshHeader()}),this.customForm=this.formBuilder.group({}),this.uiUtilitiesService.site$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{this.locationId=t?.location_id}),this.drawerService.formConfig$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{if(t!=null){let{rowData:i,actionType:e,permissions:a,extraData:r}=t;if(this.rowData=i,this.actionType=e,this.permissions=a,this.allocationData=r,this.isBlockAllocationMissing=r?.allocationApplicationSettings?.blockallocationmissing??!1,this.poDefaulting=this.allocationData?.poDefaulting,this.isFromAllocated=this.allocationData?.isFromAllocated??!1,this.canViewRates=this.allocationData?.canViewRates??!1,this.isRevoked=this.rowData?.state?.id===w.REVOKED,this.isFromAllocated===!0&&this.rowData?.state?.id!==w.ALLOCATED&&!this.isRevoked&&(this.showEditButton=!1),this.rowData?.isnegativeallocation&&(this.showEditButton=!1),i?.attachments){let n=this.uiUtilitiesService.formatStringWithMultipleArray(i?.attachments);n?.forEach(o=>o.name=o?.filename),this.files=n}this.getRateAdjustPermissions(),this.getTranslations(),this.updateFooterButton(),this.initializeForm();let s=r?.jobDetailsData?.selectedResource?.glaccount;s?.id&&this.form.get("glaccount")?.patchValue(s),this.getAgreements(this.form?.controls?.organization?.value),this.getShifts(),this.isActivityCodeVisible&&this.loadActivityCodes(),this.getLaborGridData(r.jobDetailsData.selectedResource),this.setColumnDefs(),this.rowData.customfields=r.jobDetailsData.selectedResource?.customfields,this.loadCustomFields(this.domainTypes.ALLOCATIONS)}}),this.drawerService.drawerFooterAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{if(t!=null)switch(t){case this.ACTIONS.CLOSE:case this.ACTIONS.CANCEL:this.onFormClose(!1,!1,!1,le.ASYNC_CONFIRM);break;case this.ACTIONS.EDIT:this.onFormEdit(),this.setHeaderLabels(),this.setColumnDefs(),this.form.get("isnonbillable").enable(),this.form.get("isfixedfee").enable(),this.form.get("issubcontractor").enable(),this.form.get("nochanges").enable(),this.form.get("nocostobject").enable(),this.initializeNonBillableLumpSum();break;case this.ACTIONS.RATE_ADJUSTMENT:{let i=this.existingRateAdjustments[`${this.form.controls.agreement?.value?.id}-${this.form.controls.skill?.value?.id}`]??[];this.processRateAdjustments(i);break}case this.ACTIONS.RESUBMIT:case this.ACTIONS.SAVE:this.onSave();break}}),this.allocationService.costObjectsChange$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t!=null&&this.setStatusFixFeeNonBillable(t)}),this.drawerService.triggerAccordionExpandOrCollapseAll$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t!==null&&this.sections.setAll(t)}
1)}onFormEdit(){super.onFormEdit(),this.getSkills()}getRateAdjustPermissions(){$({rateAdjustment:this.commonService.getScreenNamePermissions(D.RATE_ADJUSTMENTS_FOR_ALLOCATIONS),applicationSettings:this.settingsService.getApplicationSettings(),agremeentSkillChange:this.commonService.getScreenNamePermissions(D.ALLOCATIONS_FOR_AGREEMENT_AND_SKILL_CHANGE),activityCode:this.commonService.getScreenNamePermissions(D.ACTIVITY_CODE_ALLOCATIONS)}).subscribe(({rateAdjustment:t,applicationSettings:i,agremeentSkillChange:e,activityCode:a})=>{this.showRateAdjustmentOption=!!(i[0].data?.allocation?.allowrateadjustments&&t[0].data?.edit),this.agreementSkillChangePermission=e[0]?.data?.edit??!1,this.agreementSkillChangePermission||this.form.controls.skill?.disable(),this.activityCodeEditPermission=a[0]?.data?.edit??!1})}setColumnDefs(){this.columnDefs=[this.mciGridService.setZeroRateAlertColumnDef(this.mciTranslateService.getTranslation("M.Zero_Rate_Alert_Hover_Labor_Allocated_Unresolved"),this.showZeroRateAlertForLabor,!(this.allocationData?.jobDetailsData?.locationSettings?.allocation?.zeroratealert??!1)),{field:"type",headerName:this.mciTranslateService.getTranslation("L.Rate_Type"),filter:"agTextColumnFilter",valueFormatter:t=>t.data.type!=="charge"?this.mciTranslateService.getTranslation(`L.${t.data.type.toUpperCase()}`):this.mciTranslateService.getTranslation("L.Other_Charge"),tooltipComponentParams:{customValueCb:t=>t.value!=="charge"?t.data.type.toUpperCase():this.mciTranslateService.getTranslation("L.Other_Charge")}},l({field:"availableHours",headerName:this.mciTranslateService.getTranslation("L.Available"),cellRenderer:t=>this.getCellRenderer(t),valueGetter:t=>this.mathService.roundDisplay(t?.data?.availableHours??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"allocatedHours",headerName:this.mciTranslateService.getTranslation("L.Allocated"),editable:!1,cellEditor:"materialInputEditor",cellEditorParams:{type:tt.NUMBER},cellRenderer:t=>this.getCellRenderer(t),valueGetter:t=>this.mathService.roundDisplay(t?.data?.allocatedHours??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"currentAllocated",headerName:this.mciTranslateService.getTranslation("L.Current_Allocated"),editable:this.isCurrentAllocatedEditable,cellClass:t=>this.isCurrentAllocatedEditable(t)?["editable-cell","numeric-column"]:["non-editable-cell","numeric-column"],cellEditor:"materialInputEditor",cellEditorParams:{type:tt.NUMBER},cellRenderer:t=>this.getCellRenderer(t),valueGetter:t=>this.mathService.roundDisplay(t?.data?.currentAllocated??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"baserate",headerName:this.mciTranslateService.getTranslation("L.Base_Rate"),valueGetter:t=>this.canViewRates?this.mathService.roundDisplay(t?.data?.baserate??0,!1):O},this.getRateColumnBaseDefinition()),l({field:"shiftrate",headerName:this.mciTranslateService.getTranslation("L.Shift_Differential"),valueGetter:t=>this.canViewRates?this.mathService.roundDisplay(t?.data?.shiftrate??0,!1):O},this.getRateColumnBaseDefinition()),l({field:"rateaddervalue",headerName:this.rateAdjustmentTranslation,valueGetter:t=>this.canViewRates?this.mathService.roundDisplay(t?.data?.rateaddervalue??0,!1):O},this.getRateColumnBaseDefinition()),l({field:"rate",headerName:this.mciTranslateService.getTranslation("L.Applied_Rate"),valueGetter:t=>{if(this.canViewRates){if(this.actionType===d.VIEW)return t?.data?.rate;{let i=this.getTotalRateAdjustment(t?.data);return this.mathService.roundDisplay(i??0,!1)}}else return O}},this.getRateColumnBaseDefinition()),{field:"lastediteddate",headerName:this.mciTranslateService.getTranslation("L.Last_Edited"),type:"rightAligned",valueGetter:t=>this.dateTimeService.toLocalizedDateHourMinFormat(t.data.lastediteddate),filter:"agDateColumnFilter",filterParams:{comparator:this.dateTimeService.localizedDateHourMinFilterComparator},comparator:this.dateTimeService.localizedDateHourMinComparator,context:{isAutoSize:!0}},{field:"lasteditedby",headerName:this.mciTranslateService.getTranslation("L.Edited_By")}]}getRateColumnBaseDefinition(){return l(l({cellRenderer:"materialToolTip",cellRendererParams:t=>{let i={simpleTooltip:!0,value:this.mathService.formatNumber(t.value)};return this.canViewRates?i.suffix=this.rowData?.currency?.code:i.tooltip=this.mciTranslateService.getTranslation("M.No_Permission_Rates"),i},tooltipComponentParams:{hide:!this.canViewRates,customValueCb:t=>{let i=t?.value,e=this.rowData?.currency?.code;return`${i} ${e}`}}},this.mciGridService.getBaseNumericColumnDefinition(!0)),this.mciGridService.getDecimalColumnFilterParams())}getTotalRateAdjustment(t){return(t?.baserate??0)+(t?.shiftrate??0)+(t?.rateaddervalue??0)}getCellRenderer(t){let i=this.mathService.formatNumber(t?.value),e=t?.data?.type===st.charge?this.rowData?.currency?.code:this.mciTranslateService.getTranslation("L.Hours_Abbr");return this.mciGridService.cellWithSuffix(i,e)}
1getLaborGridData(t){this.parentAllocateData=t;let i=t,e=[];Object.keys(i?.rate??{}).forEach(s=>{let n={type:"",availableHours:0,allocatedHours:0,currentAllocated:0,rate:0,baserate:0,shiftrate:0,rateadjust:0,rateaddervalue:0,lastediteddate:"",lasteditedby:""};n.type=s,n.availableHours=i.available.hours[s]??0,n.allocatedHours=i.allocate.hours[s]??0,n.currentAllocated=i.hours[s]??0,n.rate=i.rate[s],n.baserate=i.baserate!=null?i.baserate[s]:0,n.shiftrate=i.shiftrate!=null?i.shiftrate[s]:0;let o=i?.savedRateadjustments[s]??[];o?.forEach(h=>{h.rateorpercentflag&&(h.value=this.calTotalRateVal(n.baserate,h?.value,h?.rateorpercentflag))});let m=o??[];n.rateaddervalue=m?.reduce((h,y)=>h+(y?.value??0),0)??0,n.lastediteddate=this.rowData?.lastedited?.date,n.lasteditedby=this.rowData?.lastedited?.user,(n?.availableHours||n?.allocatedHours)&&e.push(n)}),Object.keys(i?.savedRateadjustments??{})?.length&&(this.rateAdjustmentPersistArr[`${this.rowData?.agreement?.id}-${this.rowData?.skill?.id}`]=i?.savedRateadjustments??[]);let r={type:"charge",availableHours:i?.available?.othercharges,allocatedHours:i?.allocate?.othercharges,currentAllocated:i?.othercharges,rate:"",lastediteddate:this.rowData?.lastedited?.date,lasteditedby:this.rowData?.lastedited?.user};(r.availableHours||r.allocatedHours)&&e.push(r),this.initializeNonBillableLumpSum(),this.form.controls.issubcontractor?.setValue(this.rowData?.issubcontractor),this.rowData?.shift&&this.form.controls.shift?.setValue(this.rowData?.shift),this.rowData?.skill&&this.rowData?.skill?.id!==null&&this.form.controls.skill?.setValue(this.rowData?.skill),this.isActivityCodeVisible&&this.rowData?.activitycode?.id&&this.form.controls.activitycode?.setValue({id:this.rowData.activitycode.id,name:this.rowData.activitycode.name}),this.allocationIds=t.allocations,i?.timesheetid&&this.allocationIds.push(i?.timesheetid),this.gridData=e,this.serverGridData=Fe.default.cloneDeep(e),this.actionType===d.EDIT&&this.getSkills()}initializeNonBillableLumpSum(){let t,i,e;if(this.actionType===d.EDIT){let a=this.allocationService.isCostObjectLumpSum(this.allocationData),r=this.allocationService.isCostObjectNonBillable(this.allocationData),s=this.allocationService.isCostObjectSubContractor(this.allocationData);(a||r||s)&&this.disableCheckboxesAddTooltip(a,r,s),t=this.rowData?.isfixedfee||a,i=this.rowData?.isnonbillable||r,e=this.rowData?.issubcontractor||s}else t=this.rowData?.isfixedfee,i=this.rowData?.isnonbillable,e=this.rowData?.issubcontractor;this.form.controls.isnonbillable?.setValue(i),this.form.controls.isfixedfee?.setValue(t),this.form.controls.issubcontractor?.setValue(e)}getShifts(){this.allocationService.getShiftDataList().subscribe(t=>{t[0]?.success&&t[0]?.data&&(this.shiftList=t[0]?.data.filter(i=>i.id!=="9cb58a8a32364642b4d5a42a644b5c42"))})}loadActivityCodes(){let t=this.rowData?.organization?.id;if(!this.locationId||!t){this.activityCodeList=[];return}this.definitionCodesService.getAssignedActivityCodes(this.locationId,t).pi
1pe(this.takeUntilDestroyed(this.destroyRef)).subscribe({next:i=>{this.activityCodeList=i[0]?.success?i[0]?.data??[]:[];let e=this.form?.controls?.activitycode?.value;e?.id&&!this.activityCodeList.some(a=>a.id===e.id)&&(this.activityCodeList=[...this.activityCodeList,e])},error:()=>{this.activityCodeList=[]}})}onStoreAgreementChange(t){this.isDiscardSelectionOpen||(this.storePreviousValObj.agreement=t)}onAgreementChange(t){let i=`${this.storePreviousValObj.agreement?.id}-${this.form.controls.skill?.value?.id}`,e=this.rateAdjustmentPersistArr[i]??{},a=!Fe.default.isEmpty(e),r=this.skillData.filter(n=>n?.agreementid===t?.id),s=this.form.controls?.skill?.value?.id===void 0||r.find(n=>n?.id===this.form.controls?.skill?.value?.id);if(a||!s){let n=[];a&&n.push(this.rateAdjustmentPluralTranslation),s||n.push(this.mciTranslateService.getTranslation("L.Skills")),this.showDiscardSelection(t,this.agreementTranslatedLabel,n,!s)}else this.updateAgreementChanges(t)}updateAgreementChanges(t){this.skillList=this.skillData.filter(e=>e?.agreementid===t?.id);let i=this.skillList.find(e=>e.id===this.rowData?.skill.id);this.isShowDiscardSelection=!1,i?this.onSkillChange(i):(this.gridData.forEach(e=>{e.rate=0,e.baserate=0,e.shiftrate=0,e.rateaddervalue=0}),this.gridApi?.refreshCells()),this.actionType===d.EDIT&&this.getRateAdjustment()}getSkills(){let t=this.dateTimeService.toISODateFormat(this.rowData.workdate),i=this.rowData?.resource?.id;this.skillManagementService.getSkillForResources(t,this.locationId,this.rowData.organization?.id,[i]).subscribe(e=>{if(e[0]?.success&&e[0]?.data){this.skillData=e[0]?.data,this.skillData.forEach(r=>{r.name=r.skillname,r.id=r.skillid}),this.skillList=this.skillData.filter(r=>r?.agreementid===this.rowData?.agreement?.id||this.rowData?.agreement?.id===null);let a=this.skillList.find(r=>r.id===this.rowData?.skill.id);a&&this.onSkillChange(a)}})}onSkillChange(t){let i=`${this.form.controls?.agreement?.value?.id}-${this.storePreviousValObj.skill?.id}`,e=this.rateAdjustmentPersistArr[i]??{};!Fe.default.isEmpty(e)?this.showDiscardSelection(t,this.skillTranslatedLabel,[this.rateAdjustmentPluralTranslation]):this.updateSkillChanges(t)}updateSkillChanges(t){let i=this.getShiftRateKeySuffix(this.form.controls?.shift?.value);this.updateGridValues(t,i)}updateRateAdjustmentBtn(){let t=this.gridData?.find(m=>(m?.availableHours>0||m?.allocatedHours>0)&&m?.type!=="charge"),i=this.form.controls?.agreement?.value?.id??"",e=this.form.controls?.skill?.value?.id??"",a=this.existingRateAdjustments[`${this.form.controls.agreement?.value?.id}-${this.form.controls.skill?.value?.id}`]??[],r=this.form.get("isfixedfee")?.value??!1,s=this.form.get("isnonbillable")?.value??!1,n=this.form.get("issubcontractor")?.value??!1,o=s||n||r;this.isRateAdjustmentVisible=!!(this.showRateAdjustmentOption&&(t?.allocatedHours||t?.availableHours)&&i&&e&&a?.length&&!o),this.updateFooterButton()}onCellValueChanged(t){let i=this.serverGridData[t.rowIndex].currentAllocated,e=this.serverGridData[t.rowIndex].allocatedHours,a=this.serverGridData[t.rowIndex].availableHours,r=t.newValue;if(r===""||r==="0.00")t.data.availableHours=a+i,t.data.allocatedHours=e-i,this.form.markAsDirty();else{let s=parseFloat(r);if(s>=i){let n=s-i,o=this.mathService.roundDisplay(n??0,!1);if(o>a){let m;t.data.type===st.charge?m=this.mciTranslateService.getTranslation("M.Other_Charge_Exceed_Available_Other_Charges"):m=this.mciTranslateService.getTranslation("M.Hours_Exceed_Available_Hours"),this.uiUtilitiesService.showNotificationMessage(m),t.data.currentAllocated=i,t.data.availableHours=a,t.data.allocatedHours=e}else t.data.availableHours=a-o,t.data.allocatedHours=e+o,this.form.markAsDirty()}else{let n=i-s;t.data.availableHours=a+n,t.data.allocatedHours=e-n,this.form.markAsDirty()}}t.api.refreshCells()}selectedOrderTypeEmit(t){this.selectedOrderType=t}updateFooterButton(t=!1){let i=[],e=!this.allocationService.validateJobDetailsValues(this.selectedOrderType,this.form);t?i=[]:i=[{action:d.DELETE,style:W.GHOST_DESTRUCTIVE,position:J.LEFT,visible:this.permissions?.canDelete&&this.actionType!==d.ADD&&this.rowData?.state?.id!==w.ACCEPTED&&this.rowData?.state?.id!==w.AUTHORIZED&&this.rowData?.state?.id!==w.AUTHORIZED_UNACCEPTED},{action:d.EDIT,style:W.SECONDARY,position:J.RIGHT,visible:this.permissions?.canEdit&&this.actionType===d.VIEW&&this.showEditButton},{action:d.CANCEL,style:W.SECONDARY,position:J.RIGHT,visible:this.actionType!==d.VIEW},{action:d.CLOSE,style:W.PRIMARY,position:J.RIGHT,visible:this.actionType===d.VIEW},{action:d.RATE_ADJUSTMENT,style:W.SECONDARY,position:J.RIGHT,visible:this.actionType===d.EDIT&&this.isRateAdjustmentVisible},{action:this.isFromAllocated?d.SAVE:d.RESUBMIT,style:W.PRIMARY,position:J.RIGHT,useFormDirtyForDisabled:!0,disabled:e,visible:this.actionType===d.EDIT}],setTimeout(()=>{this.uiUtilitiesService.updateDrawerFooterButtons(i,this.form)},100)}get hasRequiredCustomFields(){return this.customFields?.some(t=>t?.isrequired)??!1}get populatedCustomFieldsCount(){return this.customFields?.filter(t=>{let i=this.customForm?.get(t.name)?.value;return i==null||i===""?!1:t.format==="Telephone"?typeof i=="string"?!0:!!i?.internationalNumber:t.format==="Color"?!!i?.id:!0})?.length??0}get isCustomFieldsDone(){return this.customFields?.length?this.hasRequiredCustomFields?this.customForm?.valid??!1:this.populatedCustomFieldsCount>0:!1}get isJobDetailsDone(){return this.form?oi.every(t=>this.form.get(t)?.valid??!0):!1}get isActivityCodeVisible(){return this.allocationData?.jobDetailsData?.locationSettings?.allocation?.activitycodes===!0}get isActivityCodeRequired(){return this.isActivityCodeVisible&&this.allocationData?.jobDetailsData?.locationSettings?.allocation?.requireactivitycodes===!0&&this.activityCodeEditPermission}get activityCodeActionType(){return this.activityCodeEditPermission?this.actionType:d.VIEW}get isAttachmentsVisible(){return!!this.files?.length}
1get allocationDetailsStepNumber(){return this.customFields?.length?3:2}get attachmentsStepNumber(){return this.customFields?.length?4:3}get commentsStepNumber(){let t=5;return this.customFields?.length||t--,this.isAttachmentsVisible||t--,t}get hasJobDetailsError(){return oi.some(t=>{let i=this.form?.get(t);return(i?.touched&&i?.invalid)??!1})}get isAllocationDetailsDone(){let t=this.form?.get("shift")?.valid??!1,i=this.form?.get("agreement")?.valid??!1,e=!(this.form?.get("skill")?.invalid??!1),a=!(this.form?.get("activitycode")?.invalid??!1),r=this.gridData?.some(s=>(s.currentAllocated??0)>0)??!1;return t&&i&&e&&a&&r}get hasAllocationDetailsError(){return(this.form?.get("shift")?.touched&&this.form?.get("shift")?.invalid||this.form?.get("agreement")?.touched&&this.form?.get("agreement")?.invalid||this.form?.get("skill")?.touched&&this.form?.get("skill")?.invalid||this.form?.get("activitycode")?.touched&&this.form?.get("activitycode")?.invalid)??!1}initializeForm(){let t=this.allocationData?.jobDetailsData?.selectedResource?.agreement,i=this.allocationData?.jobDetailsData?.selectedResource?.skill;this.form=this.formBuilder.group({timesheetdate:[this.rowData?.workdate],organization:[""],glaccount:[""],ordertype:[""],costelementtype:[""],areaid:["",Pe.required],agreement:[t?.id!==null?{id:t?.id,name:t?.name}:null,Pe.required],isnonbillable:[{value:!1,disabled:this.actionType===d.VIEW||this.actionType===d.EDIT&&!this.allocationData.nonBillPerms?.edit}],isfixedfee:[{value:!1,disabled:this.actionType===d.VIEW||this.actionType===d.EDIT&&!this.allocationData.lumpSumPerms?.edit}],issubcontractor:[{value:!1,disabled:this.actionType===d.VIEW||this.actionType===d.EDIT&&!this.allocationData.subConPerms?.edit}],shift:["",Pe.required],skill:[i?.id!=null?{id:i?.id,name:i?.name}:null,this.isBlockAllocationMissing?Pe.required:null],activitycode:[null],nochanges:[{value:!1,disabled:this.actionType===d.VIEW}],nocostobject:[{value:!1,disabled:this.actionType===d.VIEW}]}),this.form.get("organization").setValue(this.rowData?.organization)}onSave(){this.formSubmitted=!0,this.isFormClosed=!1;let t=this.allocationData?.jobDetailsData?.locationSettings?.allocation?.insufficientfundswarning??!1;if(this.validatePOAgreement(),this.mciFormService.validateAllFormFields(this.form),this.mciFormService.validateAllFormFields(this.customForm),this.form.invalid||this.customForm.invali
1d)this.formSubmitted=!1,this.onFormHasErrors();else if(this.files?.length>0){let i={locationid:this.locationId};this.fileService.uploadFiles(i,this.files,null,this.saveWithAttachment,t),this.closeDiscardDialog()}else this.saveWithAttachment("",t)}validatePOAgreement(){if(!this.jobDetails?.selectedOrderType?.issystemgenerated)if(this.jobDetails.isPoToAgreementValidation&&this.form.controls.purchaseorderid?.value){let i=(this.agreementList?.filter(a=>a?.name.toLowerCase()===this.jobDetails.selectedPurchaseOrder?.agreementid.toLowerCase()))[0]?.id,e=this.form?.get("agreement")?.value;(i==null||i!==e?.id)&&(this.form.controls?.purchaseorder?.markAsTouched(),this.jobDetails.customErrorMessagePO=this.mciTranslateService.getTranslation("M.PO_Agree_Not_Found"),this.form.controls?.purchaseorder?.setErrors({customerror:!0}))}else this.jobDetails.isPoToAgreementValidation&&!this.form.controls.purchaseorderid?.value&&(this.form.controls?.purchaseorder?.markAsTouched(),this.jobDetails.customErrorMessagePO=this.mciTranslateService.getTranslation("M.PO_Agree_Not_Found"),this.form.controls?.purchaseorder?.setErrors({customerror:!0}))}getAgreements(t){this.agreementList=[],this.commonService.getActiveAgreements([t?.id],[this.locationId]).subscribe(i=>{i[0]?.success&&i[0]?.data&&(this.agreementList=i[0].data?.map(e=>({id:e.id,name:e.name,startDate:e.startdate,endDate:e.enddate}))),this.limitAgreementByTimesheetDate()})}limitAgreementByTimesheetDate(){this.agreementList=this.agreementList.filter(t=>{let i=new Date(t.startDate),e=new Date(t.endDate),a=new Date(this.form.controls?.timesheetdate?.value);return a>=i&&a<=e})}saveWithAttachment(t,i=!1){let e=this.prepareRequestObject(t,i);if(this.actionType===this.ACTIONS.ADD&&this.commentRef.onCommentSave(),!this.valid){this.uiUtilitiesService.showNotificationMessage(this.mciTranslateService.getTranslation("M.Allocation_Data_Not_Valid")),this.onFormHasErrors();return}this.allocationService.upsertResourceDetails(e).subscribe({next:a=>{let r=a?.[0]?.errors?.[0]?.message;if(r===bt&&!a?.[0]?.data?.length){this.notificationBarService.showNotificationMessage(this.mciTranslateService.getTranslation(r),""),this.onFormHasErrors(!0),this.closeDiscardDialog();return}if(a[0].success&&a[0].data)if(a[0].data[0].issuccess)this.notificationBarService.showUpsertNotificationMessage(this.entity,d.EDIT),this.isFormClosed||(this.onFormClose(!0,!1,!1,le.ASYNC_CONFIRM),this.drawerService.requestToReloadTableAfterDrawerAction(!0)),this.isFormClosed=!0;else{if(!a[0].data[0].issuccess&&a[0].data[0].moreinfo?.isoverspend)if(i)this.openInSufficientFundsWarningDialog(t);else{let s=this.mciTranslateService.getTranslation("M.Cost_Object_Depleted_Message_Singular");this.modalService.openWarningModal(s,this.mciTranslateService.getTranslation("M.Cost_Object_Depleted_Title_Singular"))}else{let s=this.mciTranslateService.getTranslation("M.Entity_Could_Not_Be_Actioned",{entity:this.entity});this.notificationBarService.showNotificationMessage(s,"")}this.onFormHasErrors()}else this.onFormHasErrors();this.closeDiscardDialog()},error:()=>{this.onFormHasErrors()}})}prepareRequestObject(t,i){return{id:"",classificationname:Y.LABOR,isactive:!0,showinsufficientfundswarning:i,isrejectedallocation:!this.isRevoked,rejectedallocationids:this.allocationIds,revokeallocationids:this.isRevoked?this.allocationIds:[],basicinformation:{timesheetdate:this.dateTimeService.toISODateFormat(this.form.controls.timesheetdate?.value),organizationid:this.form.controls.organization?.value?.id},jobdetails:{isnocostobject:!1,temporarycostobjectname:"",ordertypeid:this.form.controls.ordertype?.value?.id,purchaseorderid:this.form.controls.purchaseorderid?.value==="-1"?null:this.form.controls.purchaseorderid?.value,purchaseorderlineid:this.form.controls.purchaseorderlinesid?.value==="-1"?null:this.form.controls.purchaseorderlinesid?.value,costobjecttypekey:this.form.controls.costelementtype?.value?.key,costcenterid:this.form.controls.costcenterid?.value==="-1"?null:this.form.controls.costcenterid?.value,workunitid:this.getWorkUnitId(),operationid:this.getOperationId(),suboperationid:this.getsubOprationId(),wbsid:this.form.controls.wbsid?.value==="-1"?null:this.form.controls.wbsid?.value,areaid:this.form.controls.areaid?.value?.id,glaccountid:this.form.controls.glaccount?.value?.id},customfields:this.getCustomFieldsPayload(),laborresourceallocations:this.getLaborAllocations(t)}}openInSufficientFundsWarningDialog(t){let i=this.mciTranslateService.getTranslation("M.Cost_Object_Depleted_Title_Singular"),e=this.mciTranslateService.getTranslation("M.Cost_Object_Depleted_Temporarily_Allocate_Message_Singular"),a=this.mciTranslateService.getTranslation("L.Allocate").toUpperCase(),r=this.mciTranslateService.getTranslation("L.Cancel").toUpperCase();this.modalService.openConfirmationModal(e,i,a,r,!0).afterClosed().subscribe(n=>
1{n===d.CONFIRM?this.saveWithAttachment(t,!1):this.onFormHasErrors()})}getWorkUnitId(){switch(this.form.get("costelementtype")?.value?.key){case re.WORKORDER:return this.form.controls.workorderid?.value==="-1"?null:this.form.controls.workorderid?.value;case re.NETWORKORDER:return this.form.controls.networkorderid?.value==="-1"?null:this.form.controls.networkorderid?.value;case re.INTERNALORDER:return this.form.controls.internalordersid?.value==="-1"?null:this.form.controls.internalordersid?.value;default:return null}}getOperationId(){return this.form.get("costelementtype")?.value?.key===re.WORKORDER&&this.form.controls.operationid?.value!=="-1"?this.form.controls.operationid?.value??null:this.form.get("costelementtype")?.value?.key===re.NETWORKORDER&&this.form.controls.activityid?.value!=="-1"?this.form.controls.activityid?.value??null:null}getsubOprationId(){return this.form.get("costelementtype")?.value?.key===re.WORKORDER&&this.form.controls.suboperationid?.value!=="-1"?this.form.controls.suboperationid?.value??null:this.form.get("costelementtype")?.value?.key===re.NETWORKORDER&&this.form.controls.elementid?.value!=="-1"?this.form.controls.elementid?.value??null:null}onUploadFiles(){this.files?.length>0}onDownloadFiles(t){if(Fe.default.isEmpty(this.locationId)){this.uiUtilitiesService.showNotificationMessage(this.selectLocationMsg,"");return}this.fileService.downloadFile(t,this.locationId)}getLaborAllocations(t){let i=[],e={resource:{},agreement:{},skill:{},shift:{},summary:{},activitycode:null,attachmentmetadata:[],allocate:[],othercharges:0,isfixedfee:!1,isnonbillable:!1,issubcontractor:!1,isPartialAllocation:!1};e.resource.id=this.rowData?.resource?.id,e.agreement.id=this.form.controls.agreement?.value?.id??null,e.skill.id=this.form.controls?.skill?.value?.id??null,e.shift.id=this.form.controls?.shift?.value?.id,e.summary.id=this.rowData?.summary?.id??null,e.activitycode=this.isActivityCodeVisible&&this.form.controls.activitycode?.value?.id?{id:this.form.controls.activitycode.value.id}:null,e.attachmentmetadata=t,e.isfixedfee=this.form.controls?.isfixedfee.value??!1,e.isnonbillable=this.form.controls?.isnonbillable.value??!1,e.issubcontractor=this.form.controls?.issubcontractor.value??!1,e.isPartialAllocation=this.checkPartialAllocations();let a=this.rateAdjustmentPersistArr[`${this.form.controls.agreement?.value?.id}-${this.form.controls.skill?.value?.id}`]??{},r=e.isfixedfee||e.isnonbillable||e.issubcontractor;return this.valid=!1,this.gridData.forEach(s=>{let n={type:"",hours:"",rate:""};if(s.currentAllocated>0&&(this.valid=!0),s.type!=="charge"){n.type=s.type,n.hours=s.currentAllocated;let o=a?.[s?.type]??[];if(o?.length>0&&!r){let m=[],h=0;o?.forEach(y=>{m.push(y.rateadjustid),h+=y.value}),n.rateadders={ids:m,value:h}}n.rate=(s?.baserate??0)+(s?.shiftrate??0)+(s?.rateaddervalue??0),e.allocate.push(n)}else e.othercharges=s.currentAllocated}),i.push(e),i}checkPartialAllocations(){return!!this.gridData.some(i=>i.availableHours>0)}noChangesClick(t){t?(this.form.get("isnonbillable").disable(),this.form.get("isfixedfee").disable(),this.form.get("issubcontractor").disable(),this.form.get("nocostobject").disable(),this.form.get("agreement").disable()):(this.form.get("isnonbillable").enable(),this.form.get("isfixedfee").enable(),this.form.get("issubcontractor").enable(),this.form.get("nocostobject").enable(),this.form.get("agreement").enable()),this.customForm?.controls&&Object.keys(this.customForm?.controls).forEach(i=>{t?this.customForm.controls[i].disable():this.customForm.controls[i].enable()}),this.setColumnDefs()}checkboxChangeEvent(t){this.maintainCheckboxState(t),this.updateGridDataFromCheckboxChange(),this.updateRateAdjustmentBtn()}maintainCheckboxState(t){let i=t?.source?.id;t?.checked&&this.checkboxOptions.forEach(e=>{e?.fieldFormControlName!==i&&this.form.get(e?.fieldFormControlName).setValue(!1)})}setStatusFixFeeNonBillable(t){this.isFixFeeNonBillable=t.fixfee||t.nonbillable||t.subcontractor,this.form.get("isfixedfee")?.setValue(t.fixfee),this.form.get("isnonbillable")?.setValue(t.nonbillable),this.form.get("issubcontractor")?.setValue(t.subcontractor),this.isFixFeeNonBillable?this.disableCheckboxesAddTooltip(t.fixfee,t.nonbillable,t.subcontractor):(this.form.controls.isnonbillable.enable(),this.form.controls.isfixedfee.enable(),this.form.controls.issubcontractor.enable(),this.checkboxOptions.forEach(i=>
1{i.tooltip=""})),this.updateGridDataFromCheckboxChange()}updateGridDataFromCheckboxChange(){let t=this.form.get("isfixedfee")?.value??!1,i=this.form.get("isnonbillable")?.value??!1,e=this.form.get("issubcontractor")?.value??!1;t||i||e?this.gridData.forEach(a=>{a.rate=0,a.baserate=0,a.shiftrate=0,a.rateaddervalue=0,a.type==="charge"&&(a.allocatedHours=(a.allocatedHours-a.currentAllocated).toFixed(2),a.currentAllocated=0,a.availableHours=0)}):this.gridData.forEach((a,r)=>{if(this.form.controls.agreement?.value?.id===this.rowData?.agreement?.id&&this.form.controls.skill?.value?.id===this.rowData?.skill?.id&&this.form.controls.shift?.value?.id===this.rowData?.shift?.id)if(a.rate=this.serverGridData[r]?.rate,a.baserate=this.serverGridData[r]?.baserate,a.shiftrate=this.serverGridData[r]?.shiftrate,this.isRateAdjustmentApplied){let s=`${this.form.controls.agreement?.value?.id}-${this.form.controls.skill?.value?.id}`,o=(this.rateAdjustmentPersistArr[s]??{})?.[a.type]??[];a.rateaddervalue=o?.reduce((m,h)=>m+(h?.value??0),0)??0}else a.rateaddervalue=this.serverGridData[r]?.rateaddervalue;if(a?.rate===0){let s=this.skillList.filter(n=>n.skillid===this.form.controls?.skill?.value?.id);this.onSkillChange(s[0])}a.type.toLowerCase()==="charge"&&(a.availableHours=this.serverGridData[r]?.availableHours,a.allocatedHours=this.serverGridData[r]?.allocatedHours,a.currentAllocated=this.serverGridData[r]?.currentAllocated)}),this.gridApi?.refreshCells()}disableCheckboxesAddTooltip(t,i,e=!1){if(this.form.controls.isnonbillable.disable(),this.form.controls.isfixedfee.disable(),this.form.controls.issubcontractor.disable(),t){let a=this.checkboxOptions.find(r=>r.fieldFormControlName==="isfixedfee");a.tooltip=this.mciTranslateService.getTranslation("M.Selected_Cost_Object_Lump_Sum")}else if(i){let a=this.checkboxOptions.find(r=>r.fieldFormControlName==="isnonbillable");a.tooltip=this.mciTranslateService.getTranslation("M.Selected_Cost_Object_Non_Billable")}else if(e){let a=this.checkboxOptions.find(r=>r.fieldFormControlName==="issubcontractor");a.tooltip=this.mciTranslateService.getTranslation("M.Selected_Cost_Object_Sub_Contractor")}}showFieldNotes(){let t=[];this.rowData.fieldnotes.forEach(e=>{let a;e.attachments&&(a=JSON.parse(e.attachments)[0].id),t.push({text:e.text,timestamp:e.timestamp,imageId:a,lat:+e.lat,long:+e.long})});let i={resourceId:this.rowData.resource.id,resourceName:this.rowData.resource.name,organizationName:this.rowData.organization.name,laborId:this.rowData.resource.laborid,positionClass:De.BOTTOM_LEFT,fieldNotesDate:this.rowData.workdate,fieldNotes:t,isVirtualGate:!1,hasCostObject:!0};this.uiUtilitiesService.openFieldNoteDialog(i)}getShiftRateKeySuffix(t){let i=t?.id;if(!i||i===Ct)return"";if(i===At)return"night";if(i===Rt)return"swing";let a=this.shiftList.find(r=>r.id===i)?.defaultname?.toLowerCase();return a==="night"?"night":a==="swing"?"swing":""}onShiftChange(t){let i=this.getShiftRateKeySuffix(t),e=this.skillList.find(a=>a.id===this.form.controls?.skill?.value?.id);this.updateGridValues(e,i)}updateGridValues(t,i){let e=this.gridData,a=this.form.get("isfixedfee")?.value??!1,r=this.form.get("isnonbillable")?.value??!1,s=this.form.get("issubcontractor")?.value??!1;a||r||s?e.forEach(n=>{n.rate=0,n.baserate=0,n.shiftrate=0,n.rateaddervalue=0,n?.type?.toLowerCase()==="charge"&&(n.allocatedHours=(n.allocatedHours-n.currentAllocated).toFixed(2),n.currentAllocated=0,n.availableHours=0)}):e.forEach(n=>{if(n?.type?.toLowerCase()!=="charge"){n.rate=t[n.type.toLowerCase()+i],n.baserate=t[n.type.toLowerCase()],n.shiftrate=(t[n.type.toLowerCase()+i]??0)-(n.baserate??0);let o=`${this.form.controls.agreement?.value?.id}-${this.form.controls.skill?.value?.id}`,m=this.rateAdjustmentPersistArr[o]??{},h=m[n?.type]??[];h?.forEach(y=>{y?.rateorpercentflag&&(y.value=this.calTotalRateVal(n.baserate,y?.ratevalues,y?.rateorpercentflag))}),Fe.default.isEmpty(m)||(this.rateAdjustmentPersistArr[o][n?.type]=h??[]),n.rateaddervalue=h?.reduce((y,b)=>y+(b?.value??0),0)??0}}),this.gridApi?.refreshCells(),this.actionType===d.EDIT&&this.getRateAdjustment()}setHeaderLabels(){let t=this.uiUtilitiesService.getHeaderLabels(this.actionType,this.entity,`${this.rowData?.resource?.name} (${this.rowData?.resource?.laborid})`,_t,this.rowData?.organization?.name);this.uiUtilitiesService.updateHeaderLabels({customField:"",title:t.title,subtitle:this.actionType===d.EDIT?this.rowData?.organization?.name:t.subtitle})}getRateAdjustment(){if((this.form.controls.agreement.value?.id||this.form.controls.agreement.value==="")&&this.form.controls.skill.value?.id||!this.isBlockAllocationMissing){let t=ce.dateToDateRange(new Date(this.form.controls.timesheetdate.value)),i={vend
1orids:this.form.controls.organization.value?.id?[this.form.controls.organization.value?.id]:[],startdate:t.startDate,enddate:t.endDate,skillgroupids:[],agreementids:this.form.controls.agreement.value?.id?[this.form.controls.agreement.value?.id]:[],skillids:this.form.controls.skill.value?.id?[this.form.controls.skill.value?.id]:[],status:!0};this.organizationService.getRateAdjustmentsData(i).subscribe({next:e=>{if(e[0].data?.length){this.existingRateAdjustments[`${this.form.controls.agreement.value?.id}-${this.form.controls.skill.value?.id}`]=e[0]?.data??[];let a=this.existingRateAdjustments[`${this.form.controls.agreement?.value?.id}-${this.form.controls.skill?.value?.id}`]??[];this.calculateRateAdjustments(a,!0)}this.updateRateAdjustmentBtn()},error:()=>{this.updateRateAdjustmentBtn()}})}}processRateAdjustments(t){let e=(this.gridData?.map(s=>{if(s?.baserate>0&&s?.type!=="charge"&&(s?.allocatedHours>0||s?.availableHours>0))return{ratetype:s.type,ratevalue:s.baserate??0}})?.filter(Boolean)??[])?.reduce(function(s,n){return s[n.ratetype]=n.ratevalue??0,s},{});this.calculateRateAdjustments(t);let a={rates:e};(Object.keys(e)??[])?.length&&this.modalService.openRateAdjustmentModal(this.viewRef,a,this.rateAdjustModalData,this.onModalClose)}calTotalRateVal(t,i,e){return i?e?i*t/100:i:0}applyRateAdjustmentValues(t){this.gridData.forEach(i=>{if(i.type!=="charge"){let e=t[i?.type]?.reduce((a,r)=>a+r.value,0)??0;i.rateaddervalue=e}}),this.gridApi?.refreshCells()}getPrevSelectionValue(t,i){this.isDiscardSelectionOpen||(this.storePreviousValObj[t]=this.form.controls[t]?.value),i===!1&&(t==="agreement"||t==="skill")&&setTimeout(()=>this.notifyIfSkillOrAgreementMissing(t),100)}notifyIfSkillOrAgreementMissing(t){if(!this.isBlockAllocationMissing)return;let i=this.form?.controls?.agreement?.value?.id,e=this.form?.controls?.skill?.value?.id;(t?!(t==="agreement"?i:e):!(i&&e))&&this.uiUtilitiesService.showNotificationMessage(this.mciTranslateService.getTranslation("M.Skill_And_Agreement_Required"))}discardSelectionPop(t,i,e){this.modalService.openDiscardSelectionsModal(i,t).afterClosed().subscribe(r=>{r===d.DISCARD?e(!0):e(!1)})}showDiscardSelection(t,i,e,a=!1){this.isDiscardSelectionOpen=!0,this.discardSelectionPop(e,i,r=>{if(r){this.isDiscardSelectionOpen=!1;let s="";i===this.agreementTranslatedLabel?(a&&(this.form.controls.skill.setValue(""),this.isRateAdjustmentVisible=!1,this.updateFooterButton()),s=`${this.storePreviousValObj.agreement?.id}-${this.form.controls.skill?.value?.id}`,this.rateAdjustmentPersistArr[s]={},this.updateAgreementChanges(t),this.applyOnAgreementChange()):i===this.skillTranslatedLabel&&(s=`${this.form.controls?.agreement?.value?.id}-${this.storePreviousValObj.skill?.id}`,this.rateAdjustmentPersistArr[s]={},this.updateSkillChanges(t),this.storePreviousValObj[i.toLowerCase()]=this.form.controls?.skill?.value??{})}else this.isDiscardSelectionOpen=!1,i===this.skillTranslatedLabel?this.form.controls.skill.setValue(this.storePreviousValObj.skill):i===this.agreementTranslatedLabel&&this.form.controls.agreement.setValue(this.storePreviousValObj.agreement)})}applyOnAgreementChange(){this.form?.get("purchaseorder")?.setValidators(null),this.form?.get("purchaseorder")?.updateValueAndValidity(),this.validatePOAgreement()}calculateRateAdjustments(t,i=!1){let a=(this.gridData?.map(o=>{if(o?.baserate>0&&o?.type!=="charge"&&(o?.allocatedHours>0||o?.availableHours>0))return{ratetype:o.type,ratevalue:o.baserate??0}})?.filter(Boolean)??[])?.reduce(function(o,m){return o[m.ratetype]=m.ratevalue??0,o},{}),r=Object.keys(a)??[];t=t.sort(this.compareService.compareNames),t.forEach(o=>{o.ratetype?.forEach(m=>{m.ratename=m.ratename?.toLowerCase()}),o.ratetype=o?.ratetype?.filter(m=>r?.indexOf(m?.ratename)>-1)});let s=[],n=t.map(o=>o.name);if(t?.length>0){let o={};t.forEach((b,E)=>{s.push({rateadjustname:b?.name??"",ratetypes:b.ratetype,ischecked:!1,isindeterminate:!1,ratenameindex:E}),b.ratetype.forEach(p=>{o[p.ratename]===void 0?(p.rateadjustname=b.name,p.rateadjustid=b.id,p.rateorpercentflag=b.rateorpercentflag,p.isdisable=!1,p.rateTypeTooltip="",p.ischecked=!1,p.noRateAdjustment=!1,p.value=this.calTotalRateVal(a?.[p.ratename],p.ratevalue,b.rateorpercentflag),o[p.ratename]=[p]):(p.rateadjustname=b.name,p.rateadjustid=b.id,p.rateorpercentflag=b.rateorpercentflag,p.isdisable=!1,p.rateTypeTooltip="",p.ischecked=!1,p.noRateAdjustment=!1,p.value=this.calTotalRateVal(a?.[p.ratename],p.ratevalue,b.rateorpercentflag),o[p.ratename].push(p))})});let m=Object.keys(o);m.forEach(b=>{let E=o[b].map(p=>p.rateadjustname);
1n.forEach(p=>{E.indexOf(p)===-1&&o[b].push({rateadjustname:p??"",isdisable:!0,noRateAdjustment:!0})}),o[b]=o[b].sort(this.compareService.compareNames)}),m.sort();let h=m.reduce((b,E)=>(b[E]=o[E],b),{});m.indexOf("ST")>-1&&(o=l({ST:h.ST},h));let y=`${this.form.controls?.agreement?.value?.id}-${this.form.controls?.skill?.value?.id}`;this.isRateAdjustmentApplied=!!this.rateAdjustmentPersistArr[y],this.isRateAdjustmentApplied&&(Object.keys(this.rateAdjustmentPersistArr[y])?.forEach(b=>{o[b]?.forEach(E=>{this.rateAdjustmentPersistArr[y][b]?.findIndex(M=>M?.rateassocid===E?.rateassocid)>-1&&(E.ischecked=!0,E.isdisable=!1)})}),s.forEach(b=>{let E=b?.ratetypes?.filter(p=>p?.ischecked);E?.length?E?.length===b?.ratetypes?.length?(b.ischecked=!0,b.isindeterminate=!1):E?.length<b?.ratetypes?.length&&(b.ischecked=!1,b.isindeterminate=!0):(b.ischecked=!1,b.isindeterminate=!1)})),this.rateAdjustModalData={allrates:s,ratesArr:o,previousRateAdjustment:this.rateAdjustmentPersistArr[y]},i&&this.updateRateAdjustmentGridDate(this.rateAdjustModalData)}}updateRateAdjustmentGridDate(t){let i=t.allrates?.filter(a=>a?.isindeterminate||a?.ischecked)?.map(a=>a?.ratetypes?.filter(r=>r?.ischecked&&!r?.idisable))?.flat(1)??[],e={};i?.forEach(a=>{e[a.ratename]?e[a.ratename].push({ratename:a.ratename,rateadjustmentname:a.rateadjustname,value:a.value,rateorpercentflag:a.rateorpercentflag,rateadjustid:a.rateadjustid,rateassocid:a.rateassocid}):e[a.ratename]=[{ratename:a.ratename,rateadjustmentname:a.rateadjustname,value:a.value,rateorpercentflag:a.rateorpercentflag,rateadjustid:a.rateadjustid,rateassocid:a.rateassocid}]}),this.applyRateAdjustmentValues(e)}showZeroRateAlertForLabor(t){let i=c.PAY_TYPES,e=t?.parentRef?.serverGridData?.filter(a=>a.type===t?.data?.type)??[];return e?.length&&!e[0]?.currentAllocated&&!e[0]?.availableHours&&(t?.data?.currentAllocated??0)>0?!1:(t?.data?.currentAllocated??0)>0&&(t?.data?.baserate??0)===0&&i.some(a=>a.toLowerCase()===t?.data?.type?.toLowerCase())}static{this.\u0275fac=function(i){return new(i||c)}}static{this.\u0275cmp=B({type:c,selectors:[["app-labor-rejected-allocations-form"]],viewQuery:function(i,e){if(i&1&&ue(gi,5)(it,5)(vi,5),i&2){let a;te(a=ie())&&(e.commentRef=a.first),te(a=ie())&&(e.accordion=a.first),te(a=ie())&&(e.jobDetails=a.first)}},hostAttrs:[2,"display","block"],features:[K],decls:61,vars:104,consts:[["accordion","matAccordion"],["jobDetails",""],["commentRef",""],["accordionErrorIconRef",""],[3,"globalStateCode","subTitle2"],["autocomplete","off",3,"formGroup"],[1,"mci-ui-accordion","custom-panel-body","accordion-drawer","accordion-drawer-spacing",3,"multi"],[3,"afterCollapse","expanded"],[3,"click"],[3,"stepNumber","titleLabel","active","done","required"],[3,"ngTemplateOutlet"],[1,"row"],[1,"col"],[3,"updateFooterButton","selectedOrderTypeEmit","actionType","classification","form","isFullscreen","jobDetailsData","rowData"],[1,"mci-ui-divider"],["fieldFormControlName","shift","inputValueLabel","name",3,"selectChange","actionType","disabled","displayViewField","inputValues","labelName","required","selectDropdownForm","viewFieldValue","placeholder"],["fieldFormControlName","agreement","inputValueLabel","name",3,"onOpenChangedEvent","selectChange","actionType","displayViewField","inputValues","labelName","required","selectDropdownForm","selectFirstOptionEmitChange","viewFieldValue","disableAlphabeticalSorting","placeholder"],["fieldFormControlName","skill","inputValueLabel","name",3,"onOpenChangedEvent","selectChange","actionType","disabled","displayViewField","inputValues","labelName","required","selectDropdownForm","viewFieldValue","placeholder"],["fieldFormControlName","activitycode","inputValueLabel","name",3,"actionType","displayViewField","inputValues","labelName","required","selectDropdownForm","viewFieldValue","placeholder"],[1,"mci-ui-card-flat-border","remove-horizontal-margin"],[3,"cellEdit","gridReady","showCheckboxColumn","columnDefinition","gridData","isSliderGrid","pageSize","showAddButton","showPaginator","fileName"],[1,"row","mci-ui-drawer-vertical-top-margin"],[3,"checkboxChangeEvent","actionType","checkboxOptions","displayLabelName","displayViewField","form","typeOfControl"],[3,"stepNumber","titleLabel","active","done","count"],[1,"mci-ui-drawer-vertical-top-margin"],["entityName","allocationIds","saveCommentType","Re
1jected Allocations",3,"actionType","getCommentTypes","ids"],[1,"row","mci-ui-no-changes-cb"],["fieldFormControlName","nochanges",3,"checkboxChange","actionType","displayLabelName","displayViewField","form","typeOfControl","checkBoxName"],[3,"stepNumber","titleLabel","active","done","required","count"],[3,"actionType","customFields","customFormGroup","numberOfFieldsPerColumn","showTitle"],[1,"mci-ui-typography-label"],["aria-label","Icon Button","mat-icon-button","",1,"mci-ui-button","mci-form-icon-button",3,"click"],[3,"matTooltip"],[3,"uploadFiles","uploadFilesId","actionType","files","restrictActions","showDeleteButton","showTitle"],[1,"mci-expansion-panel-header-error-description"],[1,"error-icon"]],template:function(i,e){if(i&1&&(V(0,Si,2,5,"drawer-header-dynamic-content",4),u(1,"form",5),V(2,Ti,5,9),u(3,"mat-accordion",6,0)(5,"mat-expansion-panel",7),A("afterCollapse",function(){return e.sections.onCollapse("job_details")}),u(6,"mat-expansion-panel-header",8),A("click",function(){return e.sections.onClick("job_details")}),u(7,"mat-panel-title"),F(8,"mci-accordion-panel-title",9),R(9,"mciTranslate"),T(),V(10,bi,1,1,null,10),T(),u(11,"div",11)(12,"div",12)(13,"app-job-details",13,1),A("updateFooterButton",function(){return e.updateFooterButton()})("selectedOrderTypeEmit",function(r){return e.selectedOrderTypeEmit(r)}),T()()()(),F(15,"hr",14),V(16,Ri,10,15),u(17,"mat-expansion-panel",7),A("afterCollapse",function(){return e.sections.onCollapse("allocation_details")}),u(18,"mat-expansion-panel-header",8),A("click",function(){return e.sections.onClick("allocation_details")}),u(19,"mat-panel-title"),F(20,"mci-accordion-panel-title",9),R(21,"mciTranslate"),T(),V(22,Li,1,1,null,10),T(),u(23,"div",11)(24,"div",12)(25,"mci-select",15),R(26,"mciTranslate"),R(27,"mciTranslate"),A("selectChange",function(){return e.onShiftChange(e.form==null||e.form.controls==null?null:e.form.controls.shift.value)}),T()(),u(28,"div",12)(29,"mci-select",16),R(30,"mciTranslate"),R(31,"mciTranslate"),A("onOpenChangedEvent",function(r){return e.getPrevSelectionValue("agreement",r)})("selectChange",function(){return e.onAgreementChange(e.form.controls.agreement==null?null:e.form.controls.agreement.value)}),T()()(),u(32,"div",11)(33,"div",12)(34,"mci-select",17),R(35,"mciTranslate"),R(36,"mciTranslate"),A("onOpenChangedEvent",function(r){return e.getPrevSelectionValue("skill",r)})("selectChange",function(){return e.onSkillChange(e.form==null||e.form.controls==null?null:e.form.controls.skill.value)}),T()(),u(37,"div",12),V(38,yi,3,13,"mci-select",18),T()(),u(39,"div",11)(40,"div",12)(41,"div",19)(42,"app-common-data-grid",20),R(43,"mciTranslate"),A("cellEdit",function(r){return e.onCellValueChanged(r)})("gridReady",function(r){return e.onGridReady(r)}),T()()()(),u(44,"div",21)(45,"div",12)(46,"mci-form-control",22),A("checkboxChangeEvent",function(r){return e.checkboxChangeEvent(r)}),T()()(),V(47,Ei,10,7,"div",11),T(),F(48,"hr",14),V(49,Ni,10,14),u(50,"mat-expansion-panel",7),A("afterCollapse",function(){return e.sections.onCollapse("comments")}),u(51,"mat-expansion-panel-header",8),A("click",function(){return e.sections.onClick("comments")}
1),u(52,"mat-panel-title"),F(53,"mci-accordion-panel-title",23),R(54,"mciTranslate"),T()(),u(55,"div",24),F(56,"app-comments",25,2),T()(),F(58,"hr",14),T()(),Ge(59,wi,3,0,"ng-template",null,3,ut)),i&2){let a,r,s=ke(57);j(!(e.rowData==null||e.rowData.state==null)&&e.rowData.state.code?0:-1),v(),g("formGroup",e.form),v(),j(!e.isFromAllocated&&!e.isRevoked?2:-1),v(),g("multi",!0),v(2),g("expanded",!0),v(3),g("stepNumber",1)("titleLabel",_(9,83,"L.Job_Details"))("active",e.sections.isActive("job_details"))("done",e.isJobDetailsDone)("required",e.actionType!==e.ACTIONS.VIEW),v(2),j(e.actionType!==e.ACTIONS.VIEW&&e.hasJobDetailsError?10:-1),v(3),g("actionType",e.actionType)("classification",e.ALLOCATIONTYPES.LABOR)("form",e.form)("isFullscreen",!1)("jobDetailsData",e.allocationData.jobDetailsData)("rowData",e.rowData),v(3),j(e.customFields!=null&&e.customFields.length?16:-1),v(),g("expanded",!0),v(3),g("stepNumber",e.allocationDetailsStepNumber)("titleLabel",_(21,85,"L.Hours_Allocated"))("active",e.sections.isActive("allocation_details"))("done",e.isAllocationDetailsDone)("required",e.actionType!==e.ACTIONS.VIEW),v(2),j(e.actionType!==e.ACTIONS.VIEW&&e.hasAllocationDetailsError?22:-1),v(3),g("placeholder",x(_(26,87,"L.Select_Shift")))("actionType",e.actionType)("disabled",(a=e.form.get("nochanges"))==null?null:a.value)("displayViewField",!0)("inputValues",e.shiftList)("labelName",_(27,89,"L.Shift"))("required",!0)("selectDropdownForm",e.form)("viewFieldValue",e.rowData==null||e.rowData.shift==null?null:e.rowData.shift.name),v(4),g("placeholder",x(_(30,91,"L.Select_Agreement")))("actionType",e.actionType)("displayViewField",!0)("inputValues",e.agreementList)("labelName",_(31,93,"L.Agreement"))("required",e.isBlockAllocationMissing)("selectDropdownForm",e.form)("selectFirstOptionEmitChange",!1)("viewFieldValue",e.rowData==null?null:e.rowData.agreement)("disableAlphabeticalSorting",!0),v(5),g("placeholder",x(_(35,95,"L.Select_Skill")))("actionType",e.actionType)("disabled",!e.agreementSkillChangePermission||((r=e.form.get("nochanges"))==null?null:r.value))("displayViewField",!0)("inputValues",e.skillList)("labelName",_(36,97,"L.Skill"))("required",e.isBlockAllocationMissing)("selectDropdownForm",e.form)("viewFieldValue",e.rowData==null||e.rowData.skill==null?null:e.rowData.skill.name),v(4),j(e.isActivityCodeVisible?38:-1),v(4),g("fileName",x(_(43,99,"L.Labor_Allocations_Hours")))("showCheckboxColumn",!1)("columnDefinition",e.columnDefs)("gridData",e.gridData)("isSliderGrid",!0)("pageSize",20)("showAddButton",!1)("showPaginator",!1),v(4),g("actionType",e.actionType)("checkboxOptions",e.checkboxOptions)("displayLabelName",!1)("displayViewField",!1)("form",e.form)("typeOfControl",e.CONTROL_TYPE.CHECKBOX),v(),j(!(e.rowData==null||e.rowData.fieldnotes==null)&&e.rowData.fieldnotes.length?47:-1),v(2),j(e.isAttachmentsVisible?49:-1),v(),g("expanded",!1),v(3),g("stepNumber",e.commentsStepNumber)("titleLabel",_(54,101,"L.Comments"))("active",e.sections.isActive("comments"))("done",!!(!(s==null||s.showComments==null)&&s.showComments.length))("count",(s==null||s.showComments==null?null:s.showComments.length)??0),v(3),g("actionType",e.actionType)("getCommentTypes",e.commentTypes)("ids",e.allocationIds??et(103,ni))}},dependencies:[ft,Xe,He,ze,Me,Ue,It,it,xt,zt,Mt,Ut,Yt,Jt,Gt,H,Ft,vt,gt,yt,St,qt,ii,se,Je],encapsulation:2})}}return c})();var Oe=me(Re());var Ii=["resourceSel"],li=(()=>{class c extends ye{constructor(){super(),this.allocationService=C(X),this.masterDataService=C(Ee),this.personalInformationService=C(Ce),this.resourceService=C(Le),this.importService=C(we),this.organizationList=[],this.locationList=[],this.resourceList=[],this.groupList=[],this.defaultTimeSheetDate=null,this.canViewAcceptance=!1,this.defaultDateRange={id:q.Yesterday},this.showGridDeleteButton=!1,this.showGridAcceptButton=!1,this.isLoadingAcceptButton=!1,this.gridHeight=Ae,this.gridAggregationSummary=lt(null),this.clickEvents=new nt,this.totalRowsSelected=0,this.allowLaborFutureDates=!0,this.canViewRates=!1,this.canViewGLAccount=!1,this.activityCodesEnabled=!1,this.isLoadingExportForImportButton=!1,this.searchResources=t=>k(this,null,function*(){let i=this.filtersForm?.controls.organization?.value?.id;if(!i)return[];let e=this.filtersForm?.controls?.resourceGroup?.value?.map(n=>n.groupid)??[];this.filterDefinitions[4].inlineLoading=!0;let a=[{element:"organization",criteria:[i]},{element:"classificationname",criteria:[ae.LABOR]},{element:"isactive",criteria:[!0]}];e.length>0&&a.push({element:"resourcegroup",criteria:e});let r={payload:t,returnfields:["id","name","resourcegroups"],filters:a},s=yield this.resourceService.getFilteredResources(r);return s!=null&&!t&&(this.resourceList=s.data,this.filterDefinitions[4].inputValues=this.resourceList,this.filterDefinitions[4].totalRecords=s?.totalcount??0,this.filterSectionService.updateAppliedFilterIndicator$.next(null)),this.filterDefinitions[4].inlineLoading=!1,s?.data??[]}),this.getOrganizations=t=>k(this,null,function*(){let i=yield this.commonService.getFilteredOrganizations(t,[this.defaultLocation],["id","name","isactive"]);return t||(this.organizationList=i.data,this.filterDefinitions[1].inputValues=this.organizationList,this.filterDefinitions[1].totalRecords=i?.totalcount??0,!this.filtersForm.controls.organization.value&&this.organizationList?.length>0&&this.filtersForm.controls.organization.setValue(this.organizationList[0]),this.filterSectionService.updateAppliedFilterIndicator$.next(null),i.data?.length>0&&(this.getGroups(this.filtersForm.controls.organization.value?.id??""),this.searchResources()),this.reloadGridData()),i?.data??[]}),this.getExportForImportTemplate=()=>k(this,null,function*(){let t,i=this.getSelectedRows();if(i?.length>0)t={selecteddata:!0,data:i};else{let e=[];this.gridApi?.forEachNode(a=>{e.push(a.data?.childData)}),t={selecteddata:!0,data:e?.flat()}}return this.isLoadingExportForImportButton=!0,new Promise(e=>{this.importService.getExportForImportTemplate(Te.ALLOCATE_LABOR,t).subscribe({next:a=>
1{a[0].data&&this.importService.convertDataAndDownloadExcel(a[0].data,this.templateName),this.isLoadingExportForImportButton=!1,e(!0)},error:()=>{this.isLoadingExportForImportButton=!1,e(!1)}})})}),this.uiUtilitiesService.allocationsTabName=Y.LABOR,this.setupFilterAfterInitObservable(this.onFiltersInitialized.bind(this))}ngOnInit(){this.listingPageGridKey="laborAllocatedListing",this.initializeGrid(D.ALLOCATIONS_FOR_LABOR),this.initializeFilterSection(),this.gridInitialize(),this.uiUtilitiesService.site$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{Oe.default.isEmpty(t)||this.loadSettings(t.location_id)}),this.mciTranslateService.onLangChange.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(()=>{this.gridInitialize(),this.getTranslations(),this.setColumnDefs(),this.gridApi?.refreshHeader()}),this.getTranslations(),this.filterSectionService.applyFilters$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>this.onApplyFilters(t)),this.filterSectionService.resetFilters$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>this.onResetFilters(t)),this.context={componentParent:this},this.drawerService.reloadTableAfterDrawerAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t!=null&&t===!0&&this.reloadGridData()}),this.uiUtilitiesService.gridColumnVisibilityStateChange$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t&&this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)}),this.allocationService.allocationToAcceptChange$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t.success&&(this.reloadGridData(),this.deselectRows()),this.isLoadingAcceptButton=!1}),this.drawerService.drawerFooterAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t===d.DELETE&&this.openDeleteDialog([this.selectedRowData])})}getTranslations(){this.entity=this.mciTranslateService.getTranslation("L.Allocation"),this.entityPlural=this.mciTranslateService.getTranslation("L.Allocations"),this.templateName=this.mciTranslateService.getTranslation("L.Allocate_Labor")}loadSettings(t){this.settingsService.getLocationSettings(t).subscribe(i=>{if(i[0].success){let e=i[0].data;this.allowLaborFutureDates=e?.settings?.acceptance?.allowlaborfuturedates??!0,this.activityCodesEnabled=e?.settings?.allocation?.activitycodes??!1}}),this.settingsService.getApplicationSettings().subscribe(i=>{if(i[0]?.success&&i[0].data){let e=i[0]?.data;this.allocationApplicationSettings=e?.allocation}})}gridInitialize(){this.detailGrid=ri,this.detailGridParams={clickEvents:this.clickEvents.asObservable(),showCheckBoxForChild:!0,childrenSelected:()=>this.parentRowsSelected(),resourceClicked:(t,i)=>this.resourceClicked(t,i),getPermissions:()=>this.permissions,getCanViewGLAccount:()=>this.canViewGLAccount}}parentRowsSelected(){return k(this,null,function*(){this.totalRowsSelected=0;let t=0;this.gridApi?.forEachNode(i=>{if(!i.isSelected()&&i.data.rowsSelected)i.data.laborChildRowsSelected=[],i.data.rowsSelected=0,this.clickEvents.next();else if(i.isSelected()&&i.data.rowsSelected)this.totalRowsSelected+=i.data.rowsSelected;else if(i.isSelected()&&!i.data.rowsSelected){let e=i.data?.childData;e?.length>0&&(i.data.laborChildRowsSelected=e||[]),i.data.rowsSelected=i.data.laborChildRowsSelected?.length,this.totalRowsSelected+=i.data.rowsSelected,this.clickEvents.next()}t+=i.data.laborChildRowsSelected?.length??0}),this.gridApi?.refreshCells(),this.updateGridActionButtons(),this.gridAggregationSummary.update(i=>i&&ee(l({},i),{selected:t}))})}reloadGridData(t=!1){t&&this.skeletonLoadingService.startGridSkeletonLoading();let i=this.getRequestPayload();this.allocationService.getAllocatedLabor(i).subscribe({next:e=>{this.checkIfDataIsRestricted(e),e&&e[0]?.data?(e[0].data?.forEach(a=>{a.exceptions.isException=this.exceptionIconService.checkIfHasException(a?.exceptions)}),this.groupByResource(e[0].data),this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)):this.onAPIError()},error:()=>{this.onAPIError()}})}rowHeight(t){if(!t.node.detail)return;let e=t.data?.childData?.length,r=1*141;return e*40+r+24}groupByResource(t){let i=[],e=this.groupBy(t,a=>[a.resource?.id,a.workdate]);e&&e.forEach(a=>{let r={};r.childData=a,r.summarystatus=a[0].summarystatus,r.state=a[0].state,r.exceptions=this.exceptionIconService.mergeExceptionObjectsForParentRow(a?.map(o=>o?.exceptions)),r.workdate=a[0].workdate,r.organization=a[0].organization,r.resourcegroup=a[0].resourcegroup,r.resource=a[0].resource,r.laborid=a[0].laborid,r.fieldnotes=a[0].fieldnotes,r.currency=a[0].currency,r.agreement=Array.from(new Set(a?.map(o=>o?.agreement?.name)))?.filter(o=>o),a.forEach(o=>{let m=o.timesheetreference?.replace(/ /g,"").split(",")??[];m.length>1&&(o.timesheetreference=Array.from(new Set(m)).join(","))}),a.forEach(o=>{let m=o.revoketimesheetref?.replace(/ /g,"").split(",")??[];m.length>1&&(o.revoketimesheetref=Array.from(new Set(m)).join(","))}),r.timesheetreference=Array.from(new Set(a?.map(o=>o?.timesheetreference)))?.filter(o=>o),r.revoketimesheetref=Array.from(new Set(a?.map(o=>o?.revoketimesheetref)))?.filter(o=>o),r.ordertype=Array.from(new Set(a.map(o=>
1this.uiUtilitiesService.getOrderTypeTranslation(o.costobject?.ordertype?.name))))?.filter(o=>o),r.purchaseorder=Array.from(new Set(a.map(o=>o.costobject?.purchaseorder?.name)))?.filter(o=>o),r.poline=Array.from(new Set(a.map(o=>o.costobject?.purchaseorderline?.name)))?.filter(o=>o),r.suboperation=Array.from(new Set(a.map(o=>o.costobject?.suboperation?.name)))?.filter(o=>o),r.operation=Array.from(new Set(a.map(o=>o.costobject?.operation?.name)))?.filter(o=>o),r.costobjecttype=Array.from(new Set(a.map(o=>o.costobject?.labelname)))?.filter(o=>o),r.costobjectname=Array.from(new Set(a.map(o=>o.costobject?.name)))?.filter(o=>o),r.skill=Array.from(new Set(a?.map(o=>o?.skill?.name)))?.filter(o=>o),r.areaid=Array.from(new Set(a.map(o=>o.area?.labelname)))?.filter(o=>o),r.totalOtherCharge=+a.reduce((o,m)=>o+(m.isnegativeallocation?0:m.othercharges??0),0),r.totalHours=+a.reduce((o,m)=>o+(m.hours?.total??0),0).toFixed(2),r.otherChargesAllocated=r.totalOtherCharge/(a[0].activityothercharges?a[0].activityothercharges:1)*100,r.hoursAllocated=r.totalHours/(a[0].totalactivityhours?a[0].totalactivityhours:1)*100,r.lastEdited=a[0]?.lastedited,a?.length>1&&a.forEach(o=>{new Date(r.lastEdited.date)<new Date(o.lastedited.date)&&(r.lastEdited=o.lastedited),r.state.level>o.state.level&&(r.state=o.state)}),r.attachments=[],a.forEach(o=>{let m=this.uiUtilitiesService.formatStringWithMultipleArray(o.attachments)??[];r.attachments=r.attachments.concat(m)}),r.attachmentCount=r.attachments?.length,Object.keys(a[0].hours).forEach(o=>{r[o]=a.reduce((m,h)=>m+(h.isnegativeallocation?0:h.hours[o]??0),0)});let n=a.find(o=>!!o.timesheetid)?.timesheetid||null;a.forEach(o=>{o.timesheetid=n}),r.timesheetid=n,r.glaccount=Array.from(new Set(a.map(o=>o?.glaccount?.name)))?.filter(o=>o),i.push(r)}),i.forEach((a,r)=>a.id=`${r+1}`),this.gridApi?.setGridOption("rowData",[]),this.gridApi?.setGridOption("rowData",i),this.gridData=i,this.gridAggregationSummary.set({display:!0,shown:0,selected:0,total:i.reduce((a,r)=>a+(r.childData?.length??0),0),entityType:this.entityPlural,entityTypeSingular:this.entity,parentCount:i.length,parentType:this.mciTranslateService.getTranslation("L.Activities"),parentTypeSingular:this.mciTranslateService.getTranslation("L.Activity")})}groupBy(t,i){let e={};return t.forEach(a=>{let r=JSON.stringify(i(a));e[r]=e[r]||[],e[r].push(a)}),Object.keys(e).map(a=>e[a])}getRequestPayload(){if(!this.filtersForm)return null;let t=this.filtersForm.controls.organization?.value?.id??null,i=this.filtersForm.controls.state?.value?.map(s=>s.id)??[],e=this.filtersForm.controls.resource?.value?.map(s=>s.id)??[],a=this.commonService.getResourceGroupIdsForFilter(this.filtersForm.controls.resourceGroup?.value,"id"),r=this.dateTimeService.getDateRangeFromDateShortcut(this.filtersForm,"timesheetDate");return{organizationids:t!=null?[t]:[],stateids:i,resourceids:e,startdate:r.startDate,enddate:r.endDate.substring(0,10),resourcegroupids:a,skilltypeids:[]}}initializeGrid(t){$({allocationPermissions:this.commonService.getScreenNamePermissions(t),acceptancePermissions:this.commonService.getScreenNamePermissions(D.ACCEPTANCE),lumpSumPerms:this.commonService.getScreenNamePermissions(D.LUMP_SUM),nonBillPerms:this.commonService.getScreenNamePermissions(D.NON_BILLABLE),subConPerms:this.commonService.getScreenNamePermissions(D.SUB_CONTRACTOR),viewRatesPermissions:this.commonService.getScreenNamePermissions(D.RATES_FOR_ALLOCATIONS),glAccountAllocationsPermissions:this.commonService.getScreenNamePermissions(D.GL_ACCOUNT_ALLOCATIONS)}).subscribe(({allocationPermissions:i,acceptancePermissions:e,nonBillPerms:a,lumpSumPerms:r,subConPerms:s,viewRatesPermissions:n,glAccountAllocationsPermissions:o})=>{this.permissions.canAssign=e[0]?.data?.assign,this.permissions.canUnassign=e[0]?.data?.unassign,this.canViewAcceptance=e[0]?.data?.assign&&this.permissions?.canAssign,this.lumpSumPerms=r[0]?.data,this.nonBillPerms=a[0]?.data,this.subConPerms=s[0]?.data,i[0].data.assign=this.permissions?.canAssign,i[0].data.unassign=this.permissions?.canUnassign,n[0]?.data?.view&&(this.canViewRates=n[0].data.view),o[0]?.data?.view&&(this.canViewGLAccount=o[0].data.view),this.setPermissionsAndConfigureGrid(i[0]?.data)})}configurePopupOptions(){let t=[{action:d.VIEW,canAct:this.permissions?.canView},{action:d.ACCEPT,canAct:this.canViewAcceptance}];this.popupOptions=t.filter(i=>i.canAct).map(i=>i.action)}getPrefixColumnDef(){return[{headerComponent:ei,headerComponentParams:{allExpanded:!this.allExpanded,onChange:()=>this.expandRows()},sortable:!0,field:"REC",headerName:"",pinned:"left",lockPinned:!0,lockPosition:!0,cellRenderer:"agGroupCellRenderer",valueGetter:()=>"",maxWidth:50,resizable:!1,filter:!1,suppressMovable:!0,suppressColumnsToolPanel:!0},{headerName:G.CONTEXTMENU,cellRenderer:"materialGridMenu",cellRendererParams:{menuEvent:({type:t,value:i})=>this.contentMenuParentClick(t,i),buttons:this.popupOptions,filterButtons:(t,i)=>{let e=t?.summarystatus?.code,a=t?.workdate?new Date(t.workdate):null,r=new Date,s=a&&(a<=r||a>r&&this.allowLaborFutureDates),n=e===oe.ALLOCATED||e===oe.AUTHORIZED_UNACCEPTED,o=!t?.exceptions?.isbadgeerror;return!n||!s||!o||!this.canViewAcceptance?i.filter(m=>m!==d.ACCEPT):i}}}]}setColumnDefs(){let t=this.getPrefixColumnDef(),i=[{headerName:this.mciTranslateService.getTranslation(G.EXCEPTION),field:"exceptions",cellRenderer:"exceptionIconCell",context:{isAutoSize:!0,excludeExcelExport:!1},cellRendererParams:e=>({iconClickEvent:a=>
1{this.onExceptionIconClick(a,e.data)}})},{field:"summarystatus",headerName:this.mciTranslateService.getTranslation("L.State"),cellRenderer:"globalStatesCellRenderer",cellRendererParams:e=>({stateCode:e.data?.summarystatus?.code}),filterValueGetter:e=>e.data.summarystatus.name},{field:"workdate",headerName:this.mciTranslateService.getTranslation("L.Timesheet_Date"),type:"rightAligned",filter:"agDateColumnFilter",valueGetter:e=>this.dateTimeService.toLocalizedDateFormat(e.data.workdate),filterParams:{comparator:this.dateTimeService.localizedDateFilterComparator},comparator:this.dateTimeService.localizedDateComparator,context:{isAutoSize:!0}},{field:"organization.name",headerName:this.mciTranslateService.getTranslation("L.Organization")},{field:"resourcegroup.name",headerName:this.mciTranslateService.getTranslation("L.Group")},{field:"resource.name",headerName:this.mciTranslateService.getTranslation("L.Resource"),context:{isAutoSize:!0}},{field:"resource.laborid",headerName:this.mciTranslateService.getTranslation("L.Labor_Id"),cellClass:"stringCell"},{field:"agreement",headerName:this.mciTranslateService.getTranslation("L.Agreement"),comparator:this.compareService.compareNamesArrayWithoutName,tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")},cellRenderer:"materialToolTip",cellRendererParams:{showDash:!0},context:{isAutoSize:!0}},{field:"skill",headerName:this.mciTranslateService.getTranslation("L.Skill"),comparator:this.compareService.compareNamesArrayWithoutName,tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")},cellRenderer:"materialToolTip",cellRendererParams:{showDash:!0}},{field:"ordertype",headerName:this.mciTranslateService.getTranslation("L.Order_Type"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.ordertype),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"purchaseorder",headerName:this.mciTranslateService.getTranslation("L.Purchase_Order"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.purchaseorder),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"poline",headerName:this.mciTranslateService.getTranslation("L.PO_Line"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.poline),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"costobjecttype",headerName:this.mciTranslateService.getTranslation("L.Cost_Object_Type"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.costobjecttype),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"costobjectname",headerName:this.mciTranslateService.getTranslation("L.Cost_Object"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.costobjectname),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"operation",headerName:this.mciTranslateService.getTranslation("L.Operation_Or_Activity"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.operation),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"suboperation",headerName:this.mciTranslateService.getTranslation("L.Sub_Operation_Or_Element"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.suboperation),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"areaid",headerName:this.mciTranslateService.getTranslation("L.Area_ID"),context:{isAutoSize:!0},resizable:!1,filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.areaid),tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"glaccount",headerName:this.mciTranslateService.getTranslation("L.GL_Account"),filter:"agTextColumnFilter",comparator:this.compareService.compareNamesArrayWithoutName,filterValueGetter:e=>this.getColumnFilterValueGetter(e.data.glaccount),cellRenderer:"materialToolTip",cellRendererParams:{showDash:!0},hide:!this.canViewGLAccount},l({field:"st",headerName:this.mciTranslateService.getTranslation("L.ST"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.st??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"ot",headerName:this.mciTranslateService.getTranslation("L.OT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.ot??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"dt",headerName:this.mciTranslateService.getTranslation("L.DT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.dt??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r4",headerName:this.mciTranslateService.getTranslation("L.R4"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r4??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r5",headerName:this.mciTranslateService.getTranslation("L.R5"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r5??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r6",headerName:this.mciTranslateService.getTranslation("L.R6"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r6??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r7",headerName:this.mciTranslateService.getTranslation("L.R7"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r7??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r8",headerName:this.mciTranslateService.getTranslation("L.R8"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r8??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r9",headerName:this.mciTranslateService.getTranslation("L.R9"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r9??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r10",headerName:this.mciTranslateService.getTranslation("L.R10"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r10??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r11",headerName:this.mciTranslateService.getTranslation("L.R11"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r11??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r12",headerName:this.mciTranslateService.getTranslation("L.R12"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r12??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r13",headerName:this.mciTranslateService.getTranslation("L.R13"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r13??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r14",headerName:this.mciTranslateService.getTranslation("L.R14"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r14??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"r15",headerName:this.mciTranslateService.getTranslation("L.R15"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundDisplay(e?.data?.r15??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"totalOtherCharge",headerName:this.mciTranslateService.getTranslation("L.Other_Charge"),cellRenderer:e=>{let a=this.mathService.formatNumber(e.value);return this.mciGridService.cellWithSuffix(a,e?.data?.currency?.code)},valueGetter:e=>this.mathService.roundDisplay(e?.data?.totalOtherCharge??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hoursAllocated",headerName:this.mciTranslateService.getTranslation("L.Hours_Allocated_Percentage"),cellRenderer:e=>{let a=this.mathService.formatNumber(e?.value);return this.mciGridService.cellWithSuffix(a,"%")},valueGetter:e=>this.mathService.roundDisplay(e?.data?.hoursAllocated??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"otherChargesAllocated",headerName:this.mciTranslateService.getTranslation("L.Other_Charges_Allocated"),cellRenderer:e=>{let a=this.mathService.formatNumber(e?.value);return this.mciGridService.cellWithSuffix(a,"%")},valueGetter:e=>this.mathService.roundDisplay(e?.data?.otherChargesAllocated??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),{headerName:this.mciTranslateService.getTranslation("L.Attachment"),headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",field:"attachmentsCount",cellRenderer:"materialGridIcon",cellRendererParams:e=>e?.data?{icon:"attach_file",isDisplayValue:!0,propertyName:"attachmentsCount",displayValueCb:a=>Oe.default.isEmpty(a?.data?.attachments)?0:a?.data?.attachments.length,disabled:Oe.default.isEmpty(e?.data?.attachments),clickEvent:a=>{let r=Oe.default.isEmpty(a?.attachments)?[]:a?.attachments;if(r?.length){let s={id:a?.id,attachmentData:r},n=Oe.default.clone(this.permissions);n.canDelete=!1,this.modalService.openAttachmentModal(this.viewRef,s,this.mciTranslateService.getTranslation("L.Labor_Allocated"),d.VIEW,n)}}}:{},comparator:this.compareService.attachmentComparator,context:{isAutoSize:!0},resizable:!1},{field:"hasfieldnotes",headerName:this.mciTranslateService.getTranslation("L.Field_Note"),cellRenderer:"materialGridIcon",headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",valueGetter:e=>
1!!e?.data?.fieldnotes,cellRendererParams:e=>e.data?{icon:"event_note",propertyName:"fieldnotes",tooltip:this.mciTranslateService.getTranslation("L.Field_Note"),showIconCb:()=>!!e?.data?.fieldnotes,showDash:!e?.data?.fieldnotes,clickEvent:a=>{if(a.fieldnotes){let r=[];a.fieldnotes.forEach(n=>{let o;n.attachments&&(o=JSON.parse(n.attachments)[0].id),r.push({text:n.text,timestamp:n.timestamp,imageId:o,lat:+n.lat,long:+n.long})});let s={resourceId:a.resource.id,resourceName:a.resource.name,organizationName:a.organization.name,laborId:a.resource.laborid,positionClass:De.BOTTOM_RIGHT,fieldNotesDate:a.workdate,fieldNotes:r,isVirtualGate:!1,hasCostObject:!1};this.uiUtilitiesService.openFieldNoteDialog(s)}}}:{},context:{isAutoSize:!0},resizable:!1},{field:"timesheetreference",headerName:this.mciTranslateService.getTranslation("L.Timesheet_Num"),context:{displayFieldName:""},type:"rightAligned",filterValueGetter:e=>e.data?.timesheetreference.length?e.data?.timesheetreference:null,comparator:this.compareService.compareNamesArrayWithoutName,tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"revoketimesheetref",headerName:this.mciTranslateService.getTranslation("L.Revoked_Timesheet_Num"),context:{displayFieldName:""},type:"rightAligned",filterValueGetter:e=>e.data?.revoketimesheetref.length?e.data?.revoketimesheetref:null,comparator:this.compareService.compareNamesArrayWithoutName,tooltipComponentParams:{customValueCb:e=>e.value?.join(", ")}},{field:"lastEdited.date",headerName:this.mciTranslateService.getTranslation("L.Last_Edited"),type:"rightAligned",filter:"agDateColumnFilter",valueGetter:e=>this.dateTimeService.toLocalizedDateHourMinFormat(e.data.lastEdited?.date),filterParams:{comparator:this.dateTimeService.localizedDateHourMinFilterComparator},comparator:this.dateTimeService.localizedDateHourMinComparator,context:{isAutoSize:!0}},{field:"lastEdited.user",headerName:this.mciTranslateService.getTranslation("L.Edited_By")}];this.columnDefs=[...t,...i]}getColumnFilterValueGetter(t){return t?.length?t:""}contentMenuParentClick(t,i){switch(this.actionType=t,this.selectedRowData=i,t){case this.actionList.VIEW:this.openDrawerAndSetForm(t,!1);break;case this.actionList.ACCEPT:this.onAcceptClick([i]);break;default:break}}contentMenuClick(t,i){switch(this.actionType=t,t){case this.actionList.EDIT:case this.actionList.VIEW:this.selectedRowData=i,this.getJobDetailsDataAndOpenDrawer(i,t);break;case this.actionList.ACCEPT:this.onAcceptClick([i]);break;case this.actionList.DELETE:this.openDeleteDialog([i]);break;default:break}}getJobDetailsDataAndOpenDrawer(t,i){let e=this.uiUtilitiesService.site$.value.location_id,a=this.commonUtilitiesService.getTokenData().oid,r={OrganizationId:t.organization?.id,TimesheetDate:this.dateTimeService.toISODateFormat(t.workdate),ResourceId:t.resource?.id,AllocationIds:t?.allocations?.replaceAll('"',"")?.split(",")??[]};$({areaIdPermissions:this.commonService.getScreenNamePermissions(D.ALLOCATIONS_FOR_AREA_ID_CHANGE),orderTypes:this.masterDataService.getOrderTypes(),locationSettings:this.commonService.getLocationSettings(e),areaIds:this.commonService.getRestrictedAreaIdsByLocation(e),resourceInfo:this.allocationService.getLaborAllocatedResource(r),allocationInfo:this.allocationService.getLaborRejectedAllocation(r),userInfo:this.personalInformationService.getUser(a)}).pipe(Se(this.destroyRef)).subscribe(({areaIdPermissions:s,orderTypes:n,locationSettings:o,areaIds:m,resourceInfo:h,allocationInfo:y,userInfo:b})=>{let E;if(h[0]?.data?.length){let p=h[0]?.data?.map(L=>L?.rateadjustments?.length?(L?.rateadjustments?.forEach(f=>{f.ratetypename=f.ratetypename?.toLowerCase()??"",f.rateassocid=f.rateassocid??"",f.rateadjustid=f.rateadjustid??"",f.value=f?.ratevalues??0,f.rateorpercentflag=f?.rateorpercentflag??!1}),{ratekey:L.rateadjustments[0]?.ratetypename?.toLowerCase()??"",ratearr:L?.rateadjustments??[]}):null)?.filter(Boolean)??[],M=Object.keys(h[0]?.data[0].hours);h[0]?.data?.forEach(L=>{M?.forEach(f=>{L?.hours[f]>0&&L?.hours[f]!==null&&(h[0].data[0].hours[f]=L?.hours[f]??0)})}),h[0]?.data?.forEach(L=>{M?.forEach(f=>{L?.rate[f]>0&&L?.rate[f]!==null&&(h[0].data[0].rate[f]=L?.rate[f]??0)})}),h[0]?.data?.forEach(L=>{M?.forEach(f=>{L?.baserate[f]>0&&L?.baserate[f]!==null&&(h[0].data[0].baserate[f]=L?.baserate[f]??0)})}),h[0].data[0].hours.total=M?.reduce((L,f)=>L+(f!=="total"?h[0]?.data[0]?.hours[f]:0),0);let je=p?.reduce(function(L,f){return L[f.ratekey]=f.ratearr??[],L},{});h[0].data[0].rateadjust=h[0]?.data[0]?.rateaddervalue??{},E=h[0]?.data[0],E&&y&&(E.allocate=y[0].data[0].allocate,E.available=y[0].data[0].available,E.savedRateadjustments=je??{},E.allocations=h[0].data?.map(L=>L?.allocations?.replaceAll('"',"")?.split(","))?.flat(1))}this.jobDetailsData={locationSettings:o[0]?.data?.settings,areaIdEditPermission:s[0]?.data?.edit,orderTypes:n[0]?.data,areaIds:m[0]?.data?.map(p=>({id:p.AreaId,name:p.AreaName,areadisplayfield:p.AreaDisplayField})),selectedResource:E,userOrderType:b[0].data.ordertype},this.openDrawerAndSetForm(i,!0)})}openDrawerAndSetForm(t,i){let e=this.getDrawerHeaderLabels(t,`${this.selectedRowData?.resource?.name} (${this.selectedRowData?.resource?.laborid})`,this.selectedRowData?.organization?.name),a=i?Ze:si,r=this.isRejectedOrVoidState(),s={isFromAllocated:i&&!r,allowLaborFutureDates:this.allowLaborFutureDates,nonBillPerms:this.nonBillPerms,lumpSumPerms:this.lumpSumPerms,subConPerms:this.subConPerms,jobDetailsData:this.jobDetailsData,canViewRates:this.canViewRates,canViewAcceptance:this.canViewAcceptance,allocationApplicationSettings:this.allocationApplicationSettings,canViewGLAccount:this.canViewGLAccount,activityCodesEnabled:this.activityCodesEnabled},n=new de(t,this.selectedRowData,this.permissions,s),o=new _e(a,e.title,this.actionType===d.EDIT?this.selectedRowData?.organization?.name:e.subtitle,null,this.drawerSizesEnum.MEDIUM,null,n);this.drawerService.updateDrawerContent(o),this.drawerService.openDrawer()}onAcceptClick(t){this.isLoadingAcceptButton=!0;let i=Ye.accepted;this.allocationService.onAcceptance(t,i,"summarystatus","resource",We.LABOR,"summarystatus","resourcegroup")}onMassDelete(){let t=this.getSelectedRows();this.openDeleteDialog(t)}
1getSelectedRows(){let t=[];return this.gridApi?.forEachNode(i=>{i.isSelected()&&i.data?.laborChildRowsSelected&&t.push(i.data.laborChildRowsSelected)}),t?.flat()}openDeleteDialog(t){let i=(t??[]).map(a=>ee(l({},a),{name:a?.resource?.name??""})),e=this.modalService.openConfirmActionModal(t,this.entity,this.entityPlural,d.DELETE,le.ASYNC_CONFIRM);e.componentInstance.confirmAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(a=>{if(a===d.DELETE){let r=this.allocationService.getDeleteRequestBody(t);this.allocationService.deleteLaborAllocationsByIds(r).subscribe(s=>{e.close(),s[0]?.success&&(this.uiUtilitiesService.closeDrawer(),this.reloadGridData(!0)),this.uiUtilitiesService.handleMassActionResponseMessage(s[0],$e.DELETE,this.entity,this.entityPlural,"",i)})}})}onFiltersInitialized(t){this.filtersForm=t,this.getModelValues(this.uiUtilitiesService.site$.value,!0),this.uiUtilitiesService.site$.pipe(he(1),this.takeUntilDestroyed(this.destroyRef)).subscribe(i=>{i&&this.getModelValues(i,!1)}),this.filterSectionService.filterChanged$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(i=>{let e=i.selectedValue!==void 0?i.selectedValue:i.form?.controls?.[i.formControlName]?.value;i.isAdvancedFilter&&i.formControlName&&this.filtersForm?.controls[i.formControlName]&&this.filtersForm.controls[i.formControlName].setValue(e,{emitEvent:!1}),i.formControlName==="organization"?this.onOrganizationChange(e?.id):i.formControlName==="resourceGroup"&&this.onGroupChange()})}onOrganizationChange(t){this.filtersForm.controls?.resource?.reset(),this.filterSectionService.resetFormControls$.next(["resource"]),this.getGroups(t),this.searchResources(),this.filterSectionService.updateFormAdvFilter$.next(this.filtersForm)}onGroupChange(){return k(this,null,function*(){try{this.resourceList=[],yield this.searchResources();let i=(this.filtersForm.controls.resource.value??[]).filter(e=>this.resourceList.some(a=>a.id===e.id));this.filtersForm.controls.resource.setValue(i),this.filterSectionService.updateFormAdvFilter$.next(this.filtersForm)}catch(t){this.filterDefinitions[4].inlineLoading=!1}})}getGroups(t){this.filterDefinitions[3].inlineLoading=!0,this.resourceService.getLaborGroups({name:"labor",vendorids:[t]},"Labor Group").subscribe({next:i=>{i[0]?.data&&i[0]?.success?this.groupList=i[0].data:this.groupList=[],this.filterDefinitions[3].inputValues=this.groupList,this.filterDefinitions[3].inlineLoading=!1},error:()=>{this.filterDefinitions[3].inlineLoading=!1}})}getModelValues(t,i){i||(this.filtersForm.controls.organization.reset(),this.filtersForm.controls.resource.reset()),this.defaultLocation=t?.location_id,this.getOrganizations()}onResetFilters(t){this.filtersForm.reset({filterSort:this.defaultFilterSort,timesheetDate:this.defaultDateRange,organization:this.organizationList[0],resourceGroup:this.getGroups(this.organizationList[0].id),resource:[]}),this.searchResources(),this.filterSectionService.afterReset$.next(null),t&&this.reloadGridData()}initializeFilterSection(){let t=this.commonUtilitiesService.getTokenData().oid,i;this.personalInformationService.getDefaultDateFilter(be.ALLOCATED,t).subscribe(e=>{i=e,i&&i.selectedvalue&&(this.defaultDateRange.id=parseInt(q[i.selectedvalue])),this.filterDefinitions=[{labelName:this.mciTranslateService.getTranslation("L.Timesheet_Date"),controlType:this.CONTROL_TYPE.DATE_SHORTCUT,disableAlphabeticalSorting:!0,isMultiSelect:!1,formControlName:"timesheetDate",inputValueLabel:"name",initialValue:this.defaultDateRange,accordionGroupName:this.mciTranslateService.getTranslation("L.Date_Range"),useSession:!0,sessionKey:Q.FORM_SPECIFIC},{labelName:this.mciTranslateService.getTranslation("L.Organization"),isMultiSelect:!1,inputValueLabel:"name",inputValues:this.organizationList,controlType:this.CONTROL_TYPE.PICKER,formControlName:"organization",useSession:!0,sessionKey:Q.ORGANIZATION,placeholder:this.mciTranslateService.getTranslation("L.Select_Organization"),callbackSearch:this.getOrganizations},{labelName:this.mciTranslateService.getTranslation("L.State"),isMultiSelect:!0,inputValueLabel:"name",inputValues:this.globalStatesService.getAllocationGlobalStates(ae.LABOR),controlType:this.CONTROL_TYPE.PICKER,enableDataLoadingOnScrollOrSearch:!1,formControlName:"state",placeholder:this.mciTranslateService.getTranslation("L.Select_States")},{labelName:this.mciTranslateService.getTranslation("L.Group"),isMultiSelect:!0,inputValueLabel:"name",inputValues:[],subGroupKey:"vendorname",controlType:this.CONTROL_TYPE.PICKER,enableDataLoadingOnScrollOrSearch:!1,formControlName:"resourceGroup",recordIdName:"id",placeholder:this.mciTranslateService.getTranslation("L.Select_Groups")},{labelName:this.mciTranslateService.getTranslation("L.Resource"),isMultiSelect:!0,inputValueLabel:"name",inputValues:this.resourceList,controlType:this.CONTROL_TYPE.PICKER,formControlName:"resource",placeholder:this.mciTranslateService.getTranslation("L.Select_Resources"),callbackSearch:this.searchResources}];let a={filterDefinitions:this.filterDefinitions,showAdvancedFilterButton:!0,associatedGridId:this.listingPageGridKey,alertLargeTimesheetDateFilter:!0};this.filterSectionService.initialize(a)})}updateGridActionButtons(){let t=[],i=[];this.gridApi?.forEachNode(s=>{s.data.laborChildRowsSelected?.length&&(s.data.laborChildRowsSelected.forEach(n=>{t.push(n)}),i.push(...s.data.laborChildRowsSelected.map(n=>n?.state?.id)))}),this.showGridAcceptButton=!1;let e=i?.some(s=>s===w.ALLOCATED||s===w.REJECTED||s===w.VOIDED||s===w.REVOKED),a=new Date,r=t.filter(s=>{let n=s?.summarystatus?.code===oe.ALLOCATED||s?.summarystatus?.code===oe.AUTHORIZED_UNACCEPTED,o=new Date(s?.workdate);return n&&(o<=a||o>a&&this.allowLaborFutureDates)});this.showGridDeleteButton=e,r?.length>0&&!t?.some(s=>s?.exceptions?.isbadgeerror)&&(this.showGridAcceptButton=!0)}resourceClicked(t,i){this.contentMenuClick(t,i)}isRejectedOrVoidState(){return this.selectedRowData?.state?.id===w.REJECTED||this.selectedRowData?.state?.id===w.VOIDED}onColumnStateReset(){this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)}
1onExceptionIconClick(t,i){switch(t){case S.PAY_FORMULA_MISSING:case S.SCHEDULE_MISSING:case S.RUNNER:case S.REVOKED:case S.RISK_ATTRIBUTE_EXPIRED:case S.OVERRIDE_APPROVE:case S.OVERRIDE_REJECT:case S.OVERRIDE_REQUEST:case S.OVERRIDE_DECLINE:case S.BADGE_ERROR:{let e={exceptionIcon:t,extraData:{resourceId:i?.resource?.id,timesheetDate:i.workdate,organizationId:i.organization.id,timesheetId:i.timesheetid,timesheetRef:i.timesheetreference[0]}};this.exceptionIconService.onExceptionIconClick(e);break}default:break}}onRowDataUpdated(t){super.onRowDataUpdated(t),this.updateGridAggregationSummary()}onPaginationChanges(t){this.updateGridAggregationSummary(t.pageIndex)}onSearchEvent(){this.updateGridAggregationSummary()}onFilterChange(){this.updateGridAggregationSummary()}updateGridAggregationSummary(t=0){let i=this.gridApi?.paginationGetPageSize()??50,e=t*i,a=e+i,r=0,s=0,n=0,o=0;this.gridApi?.forEachNodeAfterFilterAndSort(m=>{if(m.data){let h=m.data.childData?.length??0;r+=h,s++,o>=e&&o<a&&(n+=h),o++}}),this.paginator()&&(this.paginator().length=s),this.gridAggregationSummary.update(m=>m&&ee(l({},m),{total:r,parentCount:s,shown:n}))}static{this.\u0275fac=function(i){return new(i||c)}}static{this.\u0275cmp=B({type:c,selectors:[["app-labor-allocated"]],viewQuery:function(i,e){if(i&1&&ue(Ii,5),i&2){let a;te(a=ie())&&(e.resourceSel=a.first)}},features:[K],decls:5,vars:29,consts:[["associatedGridId","laborAllocatedListing",3,"isDataRestrictedChange","isDataRestricted","showLongDateAlertForDataRestriction","formName","totalFilterCount"],[1,"mci-ui-card-flat-border"],[1,"mci-ui-table"],[3,"addClick","columnStateReset","filterChanged","gridReady","searchEvent","massAcceptEvent","massDelete","onNodeSelect","paginatorEvent","rowDataUpdated","columnDefinition","detailCellRenderer","detailCellRendererParams","exportForImportCB","getRowHeight","getRowIdCB","gridData","gridAggregationSummary","gridHeight","isLoadingAcceptButton","isLoadingExportForImportButton","key","masterDetail","showAddButton","showExportImportGridMenuOption","showGridAcceptButton","showGridDeleteButton","showGridExportForImportButton","showGridStatusButton","templateName","useNewExportForImportMethod","fileName"]],template:function(i,e){i&1&&(u(0,"app-filter-section",0),ve("isDataRestrictedChange",function(r){return ge(e.isDataRestricted,r)||(e.isDataRestricted=r),r}),T(),u(1,"div",1)(2,"div",2)(3,"app-common-data-grid",3),R(4,"mciTranslate"),A("addClick",function(){return e.contentMenuClick(e.actionList.ADD,null)})("columnStateReset",function(){return e.onColumnStateReset()})("filterChanged",function(){return e.onFilterChange()})("gridReady",function(r){return e.onGridReady(r)})("searchEvent",function(){return e.onSearchEvent()})("massAcceptEvent",function(){return e.onAcceptClick(e.gridApi==null?null:e.gridApi.getSelectedRows())})("massDelete",function(){return e.onMassDelete()})("onNodeSelect",function(){return e.parentRowsSelected()})("paginatorEvent",function(r){return e.onPaginationChanges(r)})("rowDataUpdated",function(r){return e.onRowDataUpdated(r)}),T()()()),i&2&&(fe("isDataRestricted",e.isDataRestricted),g("showLongDateAlertForDataRestriction",!0)("formName",e.listingPageGridKey)("totalFilterCount",5),v(3),g("fileName",x(_(4,27,"L.Labor_Allocated")))("columnDefinition",e.columnDefs)("detailCellRenderer",e.detailGrid)("detailCellRendererParams",e.detailGridParams)("exportForImportCB",e.getExportForImportTemplate)("getRowHeight",e.rowHeight)("getRowIdCB",e.getRowIdCallBack)("gridData",e.gridData)("gridAggregationSummary",e.gridAggregationSummary())("gridHeight",e.gridHeight)("isLoadingAcceptButton",e.isLoadingAcceptButton)("isLoadingExportForImportButton",e.isLoadingExportForImportButton)("key",e.listingPageGridKey)("masterDetail",!0)("showAddButton",!1)("showExportImportGridMenuOption",!0)("showGridAcceptButton",e.canViewAcceptance&&e.showGridAcceptButton)("showGridDeleteButton",(e.permissions==null?null:e.permissions.canDelete)&&e.showGridDeleteButton)("showGridExportForImportButton",!0)("showGridStatusButton",!1)("templateName",e.templateName)("useNewExportForImportMethod",!0))},dependencies:[Ne,H,se],encapsulation:2})}}return c})();var ot=me(Re());var Fi=["resourceSel"],ci=(()=>{class c extends ye{constructor(){super(),this.laborActivityService=C(Wt),this.allocationManagementService=C(X),this.importService=C(we),this.resourceService=C(Le),this.masterDataService=C(Ee),this.personalInformationService=C(Ce),this.organizationList=[],this.resourceList=[],this.filteredResources=[],this.groupList=[],this.laborNotAllocatedIds=[],this.showAllocateBtn=!1,this.defaultDateRange={id:q.Yesterday},this.laborActivityClearBadgeError=!1,this.laborActivityRecalculate=!1,this.laborActivityAllocate=!1,this.laborActivityRequestOverride=!1,this.laborChargesAdd=!1,this.laborChargesView=!1,this.laborChargesDelete=!1,this.laborChargesEdit=!1,this.laborOverridesAdd=!1,this.laborOverridesView=!1,this.laborOverridesDelete=!1,this.hourRounding=0,this.gridHeight=Ae,this.allocationLabel=this.mciTranslateService.getTranslation("L.Allocation"),this.showAutoAllocateBtn=!1,this.isLoadingExportForImportButton=!1,this.insufficientFundsWarning=!1,this.canViewRates=!1,this.menuEventCallBack=t=>{t.headerName===G.CONTEXTMENU&&(t.actionType===d.VIEW?this.laborActivityService.getLaborActivityById(t.rowData?.summary?.id).subscribe(i=>{let e=i[0]?.data;i[0]?.success&&e&&(e.timesheetdate=e.workdate,e.otherchargesamount=e?.available?.othercharges,this.contentMenuClick(t.actionType,e))}):this.contentMenuClick(t.actionType,t.rowData))},this.getExportForImportTemplate=()=>k(this,null,function*(){let t;return this.gridApi?.getSelectedRows()?.length>0?t={selecteddata:!0,data:this.gridApi?.getSelectedRows()}:t={selecteddata:!1,filters:this.getRequestPayload()},this.isLoadingExportForImportButton=!0,new Promise(e=>{this.importService.getExportForImportTemplate(Te.ALLOCATE_LABOR,t).subscribe({next:a=>
1{a[0].data&&this.importService.convertDataAndDownloadExcel(a[0].data,this.templateName),this.isLoadingExportForImportButton=!1,e(!0)},error:()=>{this.isLoadingExportForImportButton=!1,e(!1)}})})}),this.searchResources=(t,i)=>k(this,null,function*(){let e=i??this.filtersForm,a=e?.controls.organization?.value?.id;if(!a)return[];let r=e?.controls?.group?.value?.map(m=>m.groupid)??[];this.filterDefinitions[3].inlineLoading=!0;let s=[{element:"location",criteria:[this.defaultLocation]},{element:"organization",criteria:[a]},{element:"classificationname",criteria:[ae.LABOR]},{element:"isactive",criteria:[!0]}];r.length>0&&s.push({element:"resourcegroup",criteria:r});let n={payload:t,returnfields:["id","name","resourcegroups"],filters:s},o=yield this.resourceService.getFilteredResources(n);return o!=null&&!t&&(this.resourceList=o.data,this.filterDefinitions[3].inputValues=this.resourceList,this.filterDefinitions[3].totalRecords=o?.totalcount??0,this.filterSectionService.updateAppliedFilterIndicator$.next(null)),this.filterDefinitions[3].inlineLoading=!1,o?.data??[]}),this.getOrganizations=t=>k(this,null,function*(){let i=yield this.commonService.getFilteredOrganizations(t,[this.defaultLocation],["id","name","isactive"]);return t||(this.organizationList=i.data,this.filterDefinitions[1].inputValues=this.organizationList,this.filterDefinitions[1].totalRecords=i?.totalcount??0,!this.filtersForm.controls.organization.value&&this.organizationList?.length>0&&this.filtersForm.controls.organization.setValue(this.organizationList[0]),this.filterSectionService.updateAppliedFilterIndicator$.next(null),i.data?.length>0&&(this.getGroups(this.filtersForm.controls.organization.value?.id??""),this.searchResources()),this.reloadGridData()),i?.data??[]}),this.uiUtilitiesService.allocationsTabName=Y.LABOR,this.setupFilterAfterInitObservable(this.onFiltersInitialized.bind(this))}ngOnInit(){this.listingPageGridKey="laborNotAllocatedListing",this.getUserPermissions(),this.initializeFilterSection(),this.mciTranslateService.onLangChange.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(()=>{this.setColumnDefs(),this.gridApi?.refreshHeader(),this.getTranslations()}),this.getTranslations(),this.filterSectionService.applyFilters$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>this.onApplyFilters(t)),this.filterSectionService.resetFilters$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>this.onResetFilters(t)),this.fullscreenFormService.reloadTableAfterDrawerAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t!=null&&t===!0&&this.reloadGridData()}),this.drawerService.reloadTableAfterDrawerAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t!=null&&t===!0&&this.reloadGridData()}),this.uiUtilitiesService.gridColumnVisibilityStateChange$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t&&this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)}),this.drawerService.drawerFooterAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t===d.ALLOCATE&&(this.loaderService.show(),this.actionType=d.ALLOCATE,this.getJobDetailsDataAndOpenDrawer(t))})}getUserPermissions(){let i={privilegelist:[D.ALLOCATIONS_FOR_LABOR,D.OTHER_CHARGES_EXPENSES,D.LABOR_OVERRIDES,D.LABOR_RESOURCE_PERSONNEL_ID,D.ACTIVITY_IN_OUT,D.RATES_FOR_ALLOCATIONS]};$({userDetailsPermission:this.loginService.getUserDetails(i)}).subscribe(({userDetailsPermission:e})=>{let a;if(e[0]?.success&&e[0]?.data?.authorizationinfo?.privileges?.length){let r=e[0]?.data?.authorizationinfo?.privileges,s=new Map(r.map(o=>[o.privilege_Name,o.privilege_Set])),n=o=>s.get(o);a=n(D.ALLOCATIONS_FOR_LABOR),this.laborChargesView=n(D.OTHER_CHARGES_EXPENSES)?.view,this.laborChargesEdit=n(D.OTHER_CHARGES_EXPENSES)?.edit,this.laborOverridesView=n(D.LABOR_OVERRIDES)?.view,this.personnelIdPermissions=n(D.LABOR_RESOURCE_PERSONNEL_ID),this.activityInAndOutPermissions=n(D.ACTIVITY_IN_OUT),this.canViewRates=n(D.RATES_FOR_ALLOCATIONS)?.view??!1}this.setPermissionsAndConfigureGrid(a)})}getTranslations(){this.entity=this.mciTranslateService.getTranslation("L.Allocation"),this.entityPlural=this.mciTranslateService.getTranslation("L.Allocations"),this.fileName=this.mciTranslateService.getTranslation("L.Labor_Not_Allocated"),this.templateName=this.mciTranslateService.getTranslation("L.Allocate_Labor"),this.addDrawerTitle=this.mciTranslateService.getTranslation("L.Add_Allocations_Title"),this.addDrawerSubtitle=this.mciTranslateService.getTranslation("L.Add_Allocations_Subtitle")}reloadGridData(){this.deselectRows();let t=this.getRequestPayload();t&&this.allocationManagementService.getFilteredLaborNotAllocated(t).subscribe({next:i=>{if(this.checkIfDataIsRestricted(i),i&&i[0].data){let e=i[0].data.map(a=>(a.exceptions.isException=this.exceptionIconService.checkIfHasException(a?.exceptions),ee(l({},a),{timesheetdate:a.workdate,otherchargesamount:a.available.othercharges})));i[0].data?.forEach(a=>{a.exceptions.hasautoallocation=a.exceptions.hasautoallocation&&(parseFloat(a?.available?.hours?.total)>0||parseFloat(a?.available?.othercharges)>0&&!a?.preapproval?.iszerorated)&&(a?.activity?.status?.id===Be.IN||a?.activity?.status?.id===Be.OUT||a?.activity?.status?.id===Be.PARTIALLY_ALLOCATED||a?.activity?.status?.id===Be.OVERRIDE)}),this.gridData=e,this.gridData.forEach((a,r)=>
1a.id=`${r+1}`),this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)}else this.onAPIError()},error:()=>{this.onAPIError()}})}getRequestPayload(){if(!this.filtersForm)return null;let t=this.filtersForm?.controls?.organization?.value?.id??null,i=this.filtersForm?.controls?.resource.value?.map(r=>r.id)??[],e=this.commonService.getResourceGroupIdsForFilter(this.filtersForm?.controls?.group?.value,"id"),a=this.dateTimeService.getDateRangeFromDateShortcut(this.filtersForm,"timesheetDate");return{organizationids:t!=null?[t]:[],resourceids:i,startdate:a.startDate,enddate:a.endDate.substring(0,10),resourcegroupids:e,skilltypeids:[]}}configurePopupOptions(){let t=[{action:d.VIEW,canAct:this.permissions?.canView},{action:d.ALLOCATE,canAct:this.permissions?.canAdd},{action:d.AUTO_ALLOCATE,canAct:this.permissions?.canAdd}];this.popupOptions=t.filter(i=>i.canAct).map(i=>i.action)}setColumnDefs(){let t=[{headerName:G.CONTEXTMENU,context:{isMenuEvent:!0},cellRenderer:"materialGridMenu",cellRendererParams:{buttons:this.popupOptions,filterButtons:(e,a)=>e?.exceptions?.hasautoallocation===!0?a:a?.filter(s=>s!==d.AUTO_ALLOCATE)}},{headerName:this.mciTranslateService.getTranslation(G.EXCEPTION),field:"exceptions",cellRenderer:"exceptionIconCell",context:{isAutoSize:!0,excludeExcelExport:!1,excludeImportTemplate:!1},cellRendererParams:e=>({iconClickEvent:a=>{this.onExceptionIconClick(a,e.data)},iconSortType:Dt.ACTIVITY})},{field:"allocation.status",headerName:this.mciTranslateService.getTranslation("L.State"),cellRenderer:"globalStatesCellRenderer",cellRendererParams:e=>({stateCode:e.data?.allocation.status?.code}),filterValueGetter:e=>e.data.allocation.status?.name},{field:"workdate",valueGetter:e=>this.dateTimeService.toLocalizedDateFormat(e.data.workdate),type:"rightAligned",headerName:this.mciTranslateService.getTranslation("L.Timesheet_Date"),filter:"agDateColumnFilter",filterParams:{comparator:this.dateTimeService.localizedDateFilterComparator},comparator:this.dateTimeService.localizedDateComparator,context:{isAutoSize:!0}},{field:"organization.name",headerName:this.mciTranslateService.getTranslation("L.Organization")}],i=[{field:"resource.name",headerName:this.mciTranslateService.getTranslation("L.Resource"),context:{isAutoSize:!0}},{field:"resource.laborid",headerName:this.mciTranslateService.getTranslation("L.Labor_Id"),filter:"agTextColumnFilter"},{field:"resourcegroup.name",headerName:this.mciTranslateService.getTranslation("L.Group")},{field:"skill.name",headerName:this.mciTranslateService.getTranslation("L.Skill_Type"),context:{excludeImportTemplate:!0}},{field:"agreement.name",headerName:this.mciTranslateService.getTranslation("L.Agreement"),context:{isAutoSize:!0}},{field:"shift.name",headerName:this.mciTranslateService.getTranslation("L.Shift"),hide:!0},{field:"resource.pid",headerName:this.mciTranslateService.getTranslation("L.PID"),context:{excludeImportTemplate:!0},flex:1,minWidth:this.mciGridService.getColumnMinWidthByHeader(this.mciTranslateService.getTranslation("L.PID")),valueFormatter:e=>this.personnelIdPermissions?.view?e.value:this.emDash,tooltipValueGetter:()=>this.personnelIdPermissions?.view?"":this.noPermissionToViewFieldTranslation},l({field:"available.hours.total",headerName:this.mciTranslateService.getTranslation("L.Total_Hours"),context:{excludeImportTemplate:!0},cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.total,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.st",headerName:this.mciTranslateService.getTranslation("L.ST"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.st,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.ot",headerName:this.mciTranslateService.getTranslation("L.OT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.ot,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.dt",headerName:this.mciTranslateService.getTranslation("L.DT"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.dt,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r4",headerName:this.mciTranslateService.getTranslation("L.R4"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r4,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r5",headerName:this.mciTranslateService.getTranslation("L.R5"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r5,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r6",headerName:this.mciTranslateService.getTranslation("L.R6"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r6,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r7",headerName:this.mciTranslateService.getTranslation("L.R7"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r7,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r8",headerName:this.mciTranslateService.getTranslation("L.R8"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r8,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r9",headerName:this.mciTranslateService.getTranslation("L.R9"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r9,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r10",headerName:this.mciTranslateService.getTranslation("L.R10"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r10,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r11",headerName:this.mciTranslateService.getTranslation("L.R11"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r11,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r12",headerName:this.mciTranslateService.getTranslation("L.R12"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r12,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r13",headerName:this.mciTranslateService.getTranslation("L.R13"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r13,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r14",headerName:this.mciTranslateService.getTranslation("L.R14"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r14,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.hours.r15",headerName:this.mciTranslateService.getTranslation("L.R15"),cellRenderer:e=>this.mathService.formatNumber(e.value),valueGetter:e=>this.mathService.roundHours(e?.data?.available?.hours?.r15,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"available.othercharges",headerName:this.mciTranslateService.getTranslation("L.Other_Charge"),context:{excludeImportTemplate:!0},cellRenderer:e=>{let a=this.mathService.formatNumber(e?.value),r=e?.data?.currency?.code||this.uiUtilitiesService.site$.value.currency?.abbr;return this.mciGridService.cellWithSuffix(a,r)},valueGetter:e=>this.mathService.roundRate(e?.data?.available?.othercharges,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),{field:"hasfieldnotes",headerName:this.mciTranslateService.getTranslation("L.Field_Note"),cellRenderer:"materialGridIcon",headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",filterValueGetter:e=>
1e?.data?.fieldnotes?!0:"",valueGetter:e=>!!e?.data?.fieldnotes,cellRendererParams:e=>e.data?{icon:"event_note",propertyName:"fieldnotes",tooltip:this.mciTranslateService.getTranslation("L.Field_Note"),showIconCb:()=>!!e?.data?.fieldnotes,showDash:!e?.data?.fieldnotes,clickEvent:a=>{if(a.fieldnotes){let r=[];a.fieldnotes.forEach(n=>{let o;n.attachments&&(o=JSON.parse(n.attachments)[0].id),r.push({text:n.text,timestamp:n.timestamp,imageId:o,lat:+n.lat,long:+n.long})});let s={resourceId:a.resource.id,resourceName:a.resource.name,organizationName:a.organization.name,laborId:a.resource.laborid,positionClass:De.BOTTOM_CENTER,fieldNotesDate:a.workdate,fieldNotes:r,isVirtualGate:!1,hasCostObject:!1};this.uiUtilitiesService.openFieldNoteDialog(s)}}}:{},context:{isAutoSize:!0},resizable:!1}];this.columnDefs=[...t,...i],this.columnDefs.forEach(e=>{e.hide&&(e.context={excludeExcelExport:!0})})}contentMenuClick(t,i){switch(this.actionType=t,t){case this.actionList.ADD:this.loaderService.show(),this.laborNotAllocationRowData=null,this.getJobDetailsDataAndOpenDrawer(t);break;case this.actionList.VIEW:this.laborNotAllocationRowData=i,this.openDrawerAndSetForm(t);break;case this.actionList.DELETE:break;case this.actionList.ALLOCATE:this.laborNotAllocationRowData=ot.default.cloneDeep(i),this.getJobDetailsDataAndOpenDrawer(t);break;case d.AUTO_ALLOCATE:this.selectedRowData=i,this.onAutoAllocate([i]);break;default:break}}getJobDetailsDataAndOpenDrawer(t){let i=this.uiUtilitiesService.site$.value.location_id,e=this.commonUtilitiesService.getTokenData().oid;$({areaIdPermissions:this.commonService.getScreenNamePermissions(D.ALLOCATIONS_FOR_AREA_ID_CHANGE),orderTypes:this.masterDataService.getOrderTypes(),locationSettings:this.commonService.getLocationSettings(i),areaIds:this.commonService.getRestrictedAreaIdsByLocation(i),userInfo:this.personalInformationService.getUser(e)}).pipe(Se(this.destroyRef)).subscribe(({areaIdPermissions:a,orderTypes:r,locationSettings:s,areaIds:n,userInfo:o})=>{this.jobDetailsData={locationSettings:s[0]?.data?.settings,areaIdEditPermission:a[0]?.data?.edit,orderTypes:r[0]?.data,areaIds:n[0]?.data?.map(m=>({id:m.AreaId,name:m.AreaName,areadisplayfield:m.AreaDisplayField})),userOrderType:o[0].data.ordertype},this.openFullscreenFormAndSetForm(t)})}openFullscreenFormAndSetForm(t){let i=null,e=null;t===d.ALLOCATE?(i=this.mciTranslateService.getTranslation("L.Add_Allocations_Title"),e=this.mciTranslateService.getTranslation("L.Add_Allocations_Subtitle")):(i=`${this.laborNotAllocationRowData?.resource?.name} (${this.laborNotAllocationRowData?.resourceid})`,e=`${this.laborNotAllocationRowData?.organization?.name}`);let a=this.getDrawerHeaderLabels(t,i,e),s={massAllocateRows:ot.default.cloneDeep(this.gridApi?.getSelectedRows()),tabName:Y.LABOR,isFromNotAllocated:!0,isFromOverFlowOrBulk:this.actionType===this.actionList?.ALLOCATE,isLabor:!0,actionType:this.actionType,jobDetailsData:this.jobDetailsData,listingPageGridKey:this.listingPageGridKey,listingPageTimesheetFilterDate:this.filtersForm?.controls?.timesheetDate?.value?.id},n=new de(t,this.laborNotAllocationRowData,this.permissions,s),o=new Vt(Qt,a.title,a.subtitle,n);this.fullscreenFormService.updateDrawerContent(o),this.fullscreenFormService.openDrawer()}openDrawerAndSetForm(t){let i=this.getDrawerHeaderLabels(t,`${this.laborNotAllocationRowData?.resource?.name} (${this.laborNotAllocationRowData?.resourceid})`,this.laborNotAllocationRowData?.organization?.name),e=new de(t,this.laborNotAllocationRowData,this.permissions,{laborActivityPermissions:{deletePermission:this.permissions?.canDelete,editPermission:this.permissions?.canEdit},chargesPermissions:{chargesAdd:this.laborChargesAdd,chargesView:this.laborChargesView,chargesDelete:this.laborChargesDelete,chargesEdit:this.laborChargesEdit},overridesPermissions:{overridesAdd:this.laborOverridesAdd,overridesView:this.laborOverridesView,overridesDelete:this.laborOverridesDelete},clearBadgeErrorPermission:this.laborActivityClearBadgeError,hourRounding:this.hourRounding,requestOverride:this.requestOverride,isAllocationView:!0,allocationAdd:this.permissions.canAdd,activityInAndOutPermissions:this.activityInAndOutPermissions,canViewRates:this.canViewRates}),a=new _e(Zt,i.title,i.subtitle,null,this.drawerSizesEnum.MEDIUM,null,e);this.drawerService.updateDrawerContent(a),this.drawerService.openDrawer()}resetFilters(){this.filtersForm.controls.timesheetDateFilter.reset(),this.filtersForm.controls.organizationFilter.reset(),this.reloadGridData()}onMassAutoAllocate(t){this.onAutoAllocate(t)}onMassAllocate(){this.actionType=d.ALLOCATE,this.laborNotAllocationRowData=null,this.getJobDetailsDataAndOpenDrawer(d.ADD)}onSelectionChanged(t){let i=t[0],e=t?.filter(r=>r?.workdate===i?.workdate&&r.organization?.id===i.organization?.id),a=t?.filter(r=>r?.exceptions?.hasautoallocation===!0);e.length===t.length?this.showAllocateBtn=!0:this.showAllocateBtn=!1,this.showAutoAllocateBtn=a?.length===t?.length&&t?.length>0}onFiltersInitialized(t){this.filtersForm=t,this.getModelValues(this.uiUtilitiesService.site$.value,!0),this.uiUtilitiesService.site$.pipe(he(1),this.takeUntilDestroyed(this.destroyRef)).subscribe(i=>{i&&this.getModelValues(i,!1)}),this.filterSectionService.filterChanged$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(i=>{let e=i.form;i.formControlName==="organization"?this.onOrganizationChange(i.selectedValue?.id,e):i.formControlName==="group"&&this.onGroupChange(e)}
1)}onOrganizationChange(t,i){this.resourceList=[],this.filtersForm.controls?.resource?.reset(),this.filterSectionService.resetFormControls$.next(["resource"]),this.filtersForm.controls?.group?.reset(),this.filterSectionService.resetFormControls$.next(["group"]),this.getGroups(t),this.searchResources(void 0,i)}onGroupChange(t){return k(this,null,function*(){this.resourceList=[],yield this.searchResources(void 0,t);let e=(t.controls.resource.value??[]).filter(a=>this.resourceList.some(r=>r.id===a.id));t.controls.resource.setValue(e)})}getGroups(t){this.filterDefinitions[2].inlineLoading=!0,this.resourceService.getLaborGroups({name:"labor",vendorids:[t]},"Labor Group").subscribe({next:i=>{i[0]?.data&&i[0]?.success?this.groupList=i[0].data:this.groupList=[],this.filterDefinitions[2].inputValues=this.groupList,this.filterDefinitions[2].inlineLoading=!1},error:()=>{this.filterDefinitions[2].inlineLoading=!1}})}getModelValues(t,i){i||(this.filtersForm.controls.organization.reset(),this.filtersForm.controls.resource.reset()),this.defaultLocation=t?.location_id,this.getLocationSettingsForAutoAllocate(this.defaultLocation),this.getOrganizations()}getLocationSettingsForAutoAllocate(t){this.laborActivityService.getLocationInsufficientFundsWarning(t).pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(i=>{this.insufficientFundsWarning=i})}onResetFilters(t){this.filtersForm.reset({filterSort:this.defaultFilterSort,timesheetDate:this.defaultDateRange,organization:this.organizationList[0],group:this.getGroups(this.organizationList[0].id),resource:[]}),this.searchResources(),this.filterSectionService.afterReset$.next(null),t&&this.reloadGridData()}initializeFilterSection(){let t=this.commonUtilitiesService.getTokenData().oid,i;this.personalInformationService.getDefaultDateFilter(be.NOT_ALLOCATED,t).subscribe(e=>{i=e,i&&i.selectedvalue&&(this.defaultDateRange.id=parseInt(q[i.selectedvalue])),this.filterDefinitions=[{labelName:this.mciTranslateService.getTranslation("L.Timesheet_Date"),controlType:this.CONTROL_TYPE.DATE_SHORTCUT,disableAlphabeticalSorting:!0,isMultiSelect:!1,formControlName:"timesheetDate",inputValueLabel:"name",initialValue:this.defaultDateRange,accordionGroupName:this.mciTranslateService.getTranslation("L.Date_Range"),useSession:!0,sessionKey:Q.FORM_SPECIFIC},{labelName:this.mciTranslateService.getTranslation("L.Organization"),placeholder:this.mciTranslateService.getTranslation("L.Select_Organization"),isMultiSelect:!1,inputValueLabel:"name",inputValues:this.organizationList,controlType:this.CONTROL_TYPE.PICKER,formControlName:"organization",useSession:!0,sessionKey:Q.ORGANIZATION,callbackSearch:this.getOrganizations},{labelName:this.mciTranslateService.getTranslation("L.Group"),placeholder:this.mciTranslateService.getTranslation("L.Select_Groups"),isMultiSelect:!0,inputValueLabel:"name",inputValues:[],subGroupKey:"vendorname",controlType:this.CONTROL_TYPE.PICKER,enableDataLoadingOnScrollOrSearch:!1,recordIdName:"id",formControlName:"group"},{labelName:this.mciTranslateService.getTranslation("L.Resource"),placeholder:this.mciTranslateService.getTranslation("L.Select_Resources"),isMultiSelect:!0,inputValueLabel:"name",inputValues:this.resourceList,controlType:this.CONTROL_TYPE.PICKER,formControlName:"resource",callbackSearch:this.searchResources}];let a={filterDefinitions:this.filterDefinitions,showAdvancedFilterButton:!0,associatedGridId:this.listingPageGridKey,alertLargeTimesheetDateFilter:!0};this.filterSectionService.initialize(a)})}onColumnStateReset(){this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)}onExceptionIconClick(t,i){let e={exceptionIcon:t,extraData:{resourceId:i?.resource?.id}};switch(t){case S.PAY_FORMULA_MISSING:case S.SCHEDULE_MISSING:case S.SKILL_MISSING:case S.RUNNER:case S.RISK_ATTRIBUTE_EXPIRED:this.exceptionIconService.onExceptionIconClick(e);break;case S.OVERRIDE_APPROVE:case S.OVERRIDE_REJECT:case S.OVERRIDE_REQUEST:case S.OVERRIDE_DECLINE:e.extraData.timesheetDate=i.workdate,e.extraData.organizationId=i.organization.id,this.exceptionIconService.onExceptionIconCl
1ick(e);break;case S.AUTO_ALLOCATE:e.extraData.timesheetDate=i.workdate,e.extraData.organizationId=i.organization.id,e.extraData.resourceId=i.resource.id,e.extraData.locationId=this.uiUtilitiesService.site$.value.location_id,this.exceptionIconService.onExceptionIconClick(e);break;default:break}}onAutoAllocate(t,i=!0){this.laborActivityService.onAutoAllocate({rowData:t,allocationLabel:this.allocationLabel,isInitialCall:i,insufficientFundsWarning:this.insufficientFundsWarning,onRetry:e=>this.onAutoAllocate(e,!1),onSuccess:()=>this.reloadGridData(),onShowSuccess:e=>this.notificationBarService.showNotificationMessage(e,""),onShowError:e=>this.notificationBarService.showNotificationMessage(e,"")}).subscribe()}static{this.\u0275fac=function(i){return new(i||c)}}static{this.\u0275cmp=B({type:c,selectors:[["app-labor-not-allocated"]],viewQuery:function(i,e){if(i&1&&ue(Fi,5),i&2){let a;te(a=ie())&&(e.resourceSel=a.first)}},features:[K],decls:4,vars:23,consts:[["associatedGridId","laborNotAllocatedListing",3,"isDataRestrictedChange","isDataRestricted","showLongDateAlertForDataRestriction","formName","totalFilterCount"],[1,"mci-ui-card-flat-border"],[1,"mci-ui-table"],[3,"addClick","columnStateReset","massAllocate","massAutoAllocate","onRowSelect","rowDataUpdated","columnDefinition","exportForImportCB","fileName","isLoadingExportForImportButton","getRowIdCB","gridData","gridHeight","key","menuEventCB","showAddButton","showExportImportGridMenuOption","showGridAllocateButton","showGridAutoAllocateButton","showGridDeleteButton","showGridExportForImportButton","showGridStatusButton","templateName","isAllocationButtonPrimary","useNewExportForImportMethod"]],template:function(i,e){i&1&&(u(0,"app-filter-section",0),ve("isDataRestrictedChange",function(r){return ge(e.isDataRestricted,r)||(e.isDataRestricted=r),r}),T(),u(1,"div",1)(2,"div",2)(3,"app-common-data-grid",3),A("addClick",function(){return e.contentMenuClick(e.actionList.ADD,null)})("columnStateReset",function(){return e.onColumnStateReset()})("massAllocate",function(){return e.onMassAllocate()})("massAutoAllocate",function(){return e.onMassAutoAllocate(e.gridApi==null?null:e.gridApi.getSelectedRows())})("onRowSelect",function(r){return e.onSelectionChanged(r)})("rowDataUpdated",function(r){return e.onRowDataUpdated(r)}),T()()()),i&2&&(fe("isDataRestricted",e.isDataRestricted),g("showLongDateAlertForDataRestriction",!0)("formName",e.listingPageGridKey)("totalFilterCount",4),v(3),g("columnDefinition",e.columnDefs)("exportForImportCB",e.getExportForImportTemplate)("fileName",e.fileName)("isLoadingExportForImportButton",e.isLoadingExportForImportButton)("getRowIdCB",e.getRowIdCallBack)("gridData",e.gridData)("gridHeight",e.gridHeight)("key",e.listingPageGridKey)("menuEventCB",e.menuEventCallBack)("showAddButton",e.permissions==null?null:e.permissions.canAdd)("showExportImportGridMenuOption",!0)("showGridAllocateButton",(e.permissions==null?null:e.permissions.canAdd)&&e.showAllocateBtn)("showGridAutoAllocateButton",(e.permissions==null?null:e.permissions.canAdd)&&e.showAutoAllocateBtn)("showGridDeleteButton",!1)("showGridExportForImportButton",!0)("showGridStatusButton",!1)("templateName",e.templateName)("isAllocationButtonPrimary",(e.permissions==null?null:e.permissions.canAdd)&&e.showAutoAllocateBtn)("useNewExportForImportMethod",!0))},dependencies:[Ne,H],encapsulation:2})}}return c})();var di=me(Re());var mi=(()=>{class c extends ye{constructor(){super(),this.allocationManagementService=C(X),this.personalInformationService=C(Ce),this.resourceService=C(Le),this.masterDataService=C(Ee),this.importService=C(we),this.notificationStateService=C(Bt),this.canViewGLAccount=!1,this.organizationList=[],this.locationList=[],this.resourceList=[],this.groupList=[],this.showDynamicFields=!0,this.defaultDateRange={id:q.Yesterday},this.allocationsToDelete=[],this.gridHeight=Ae,this.canViewRates=!1,this.isLoadingExportForImportButton=!1,this.searchResources=t=>k(this,null,function*(){let i=this.filtersForm?.controls.organization?.value?.id;if(!i)return[];let e=this.filtersForm?.controls?.group?.value?.map(n=>n.groupid)??[];this.filterDefinitions[3].inlineLoading=!0;let a=[{element:"organization",criteria:[i]},{element:"classificationname",criteria:[ae.LABOR]},{element:"isactive",criteria:[!0]}];e.length>0&&a.push({element:"resourcegroup",criteria:e});let r={payload:t,returnfields:["id","name","resourcegroups"],filters:a},s=yield this.resourceService.getFilteredResources(r);return s!=null&&!t&&(this.resourceList=s.data,this.filterDefinitions[3].inputValues=this.resourceList,this.filterDefinitions[3].totalRecords=s?.totalcount??0,this.filterSectionService.updateAppliedFilterIndicator$.next(null)),this.filterDefinitions[3].inlineLoading=!1,s?.data??[]}),this.getOrganizations=t=>k(this,null,function*(){let i=yield this.commonService.getFilteredOrganizations(t,[this.defaultLocation],["id","name","isactive"]);return t||(this.organizationList=i.data,this.filterDefinitions[1].inputValues=this.organizationList,this.filterDefinitions[1].totalRecords=i?.totalcount??0,!this.filtersForm.controls.organization.value&&this.organizationList?.length>0&&this.filtersForm.controls.organization.setValue(this.organizationList[0]),this.filterSectionService.updateAppliedFilterIndicator$.next(null),i.data?.length>0&&(this.getGroups(this.filtersForm.controls.organization.value?.id??""),this.searchResources()),this.reloadGridData(!1,!0)),i?.data??[]}),this.getExportForImportTemplate=()=>k(this,null,function*(){let t=this.gridApi?.getSelectedRows(),i={selecteddata:!0,data:t?.length?t:this.gridData};return this.isLoadingExportForImportButton=!0,new Promise(e=>{this.importService.getExportForImportTemplate(Te.ALLOCATE_LABOR,i).subscribe({next:a=>
1{a[0].data&&this.importService.convertDataAndDownloadExcel(a[0].data,this.templateName),this.isLoadingExportForImportButton=!1,e(!0)},error:()=>{this.isLoadingExportForImportButton=!1,e(!1)}})})}),this.uiUtilitiesService.allocationsTabName=Y.LABOR,this.setupFilterAfterInitObservable(this.onFiltersInitialized.bind(this))}ngOnInit(){this.listingPageGridKey="laborUnresolvedListing",this.initializeGrid(D.ALLOCATIONS_FOR_LABOR),this.commonService.getScreenNamePermissions(D.GL_ACCOUNT_ALLOCATIONS).subscribe(t=>{t[0]?.data?.view&&(this.canViewGLAccount=!0,this.setColumnDefs())}),this.initializeFilterSection(),this.mciTranslateService.onLangChange.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(()=>{this.getTranslations(),this.setColumnDefs(),this.gridApi?.refreshHeader()}),this.getTranslations(),this.getLumpNonBillSubConPermissions(),this.commonService.getScreenNamePermissions(D.CUSTOM_FIELDS).subscribe(t=>{t[0]?.data&&(this.showDynamicFields=t[0]?.data?.view&&t[0]?.data?.add&&t[0]?.data?.edit)}),this.filterSectionService.applyFilters$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>this.onApplyFilters(t)),this.filterSectionService.resetFilters$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>this.onResetFilters(t)),this.drawerService.reloadTableAfterDrawerAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t!=null&&t===!0&&this.reloadGridData()}),this.uiUtilitiesService.gridColumnVisibilityStateChange$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t&&this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)}),this.drawerService.drawerFooterAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(t=>{t===d.DELETE&&this.openDeleteDialog([this.selectedRowData])})}getLumpNonBillSubConPermissions(){$({lumpSumPerms:this.commonService.getScreenNamePermissions(D.LUMP_SUM),nonBillPerms:this.commonService.getScreenNamePermissions(D.NON_BILLABLE),subConPerms:this.commonService.getScreenNamePermissions(D.SUB_CONTRACTOR),viewRatesPermissions:this.commonService.getScreenNamePermissions(D.RATES_FOR_ALLOCATIONS)}).subscribe(({lumpSumPerms:t,nonBillPerms:i,subConPerms:e,viewRatesPermissions:a})=>{this.lumpSumPerms=t[0]?.data,this.nonBillPerms=i[0]?.data,this.subConPerms=e[0]?.data,a[0]?.data?.view&&(this.canViewRates=a[0].data.view)})}getTranslations(){this.entity=this.mciTranslateService.getTranslation("L.Allocation"),this.entityPlural=this.mciTranslateService.getTranslation("L.Allocations"),this.fileName=this.mciTranslateService.getTranslation("L.Labor_Unresolved"),this.templateName=this.mciTranslateService.getTranslation("L.Allocate_Labor")}reloadGridData(t=!1,i=!1,e=null){t&&this.skeletonLoadingService.startGridSkeletonLoading();let a=this.getRequestPayload();this.allocationManagementService.getUnresolvedLabor(a).subscribe({next:r=>{this.checkIfDataIsRestricted(r),r&&r[0].data?(this.gridData=r[0].data,this.gridData.forEach((s,n)=>{s?.attachments&&(this.gridData[n].attachments=this.uiUtilitiesService.formatStringWithMultipleArray(s.attachments)),s.exceptions.isException=this.exceptionIconService.checkIfHasException(s?.exceptions)}),this.gridData.forEach((s,n)=>s.id=`${n+1}`),this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey),i&&this.route.queryParams.subscribe(s=>{this.applyRouteFilters(s)}),e?.recordId&&(this.selectedRowData=this.gridData.find(s=>s.allocationgroupid===e.recordId),this.selectedRowData&&this.getJobDetailsDataAndOpenDrawer(this.selectedRowData,d.VIEW))):this.onAPIError()},error:()=>{this.onAPIError()}})}getRequestPayload(){if(!this.filtersForm)return null;let t=this.filtersForm.controls?.organization?.value?.id??null,i=this.filtersForm.controls.resource.value?.map(r=>r.id)??[],e=this.commonService.getResourceGroupIdsForFilter(this.filtersForm.controls.group?.value,"id"),a=this.dateTimeService.getDateRangeFromDateShortcut(this.filtersForm,"timesheetDate");return{organizationids:t!=null?[t]:[],resourceids:i,startdate:a.startDate,enddate:a.endDate.substring(0,10),resourcegroupids:e,skilltypeids:[]}}configurePopupOptions(){let t=[{action:d.VIEW,canAct:this.permissions?.canView},{action:d.EDIT,canAct:this.permissions?.canEdit},{action:d.DELETE,canAct:this.permissions?.canDelete}];this.popupOptions=t.filter(i=>i.canAct).map(i=>i.action)}setColumnDefs(){this.columnDefs=[{headerName:G.CONTEXTMENU,cellRenderer:"materialGridMenu",cellRendererParams:{menuEvent:({type:t,value:i})=>this.contentMenuClick(t,i),buttons:this.popupOptions}},{field:"comment",cellRenderer:"commentCell",headerName:this.mciTranslateService.getTranslation(G.COMMENT)},{headerName:this.mciTranslateService.getTranslation(G.EXCEPTION),field:"exceptions",cellRenderer:"exceptionIconCell",context:{excludeImportTemplate:!1,excludeExcelExport:!1,isAutoSize:!0},cellRendererParams:t=>({iconClickEvent:i=>
1{this.onExceptionIconClick(i,t.data)}})},{field:"state",headerName:this.mciTranslateService.getTranslation("L.State"),cellRenderer:"globalStatesCellRenderer"},{field:"workdate",type:"rightAligned",headerName:this.mciTranslateService.getTranslation("L.Timesheet_Date"),filter:"agTextColumnFilter",valueGetter:t=>this.dateTimeService.toLocalizedDateFormat(t.data.workdate),filterParams:{comparator:this.dateTimeService.localizedDateFilterComparator},comparator:this.dateTimeService.localizedDateComparator,context:{isAutoSize:!0}},{field:"resource.name",headerName:this.mciTranslateService.getTranslation("L.Resource"),cellEditor:"materialInputEditor",filter:"agTextColumnFilter",context:{isAutoSize:!0}},{field:"resource.laborid",headerName:this.mciTranslateService.getTranslation("L.Labor_Id"),filter:"agTextColumnFilter"},{field:"resourcegroup.name",headerName:this.mciTranslateService.getTranslation("L.Group")},{field:"skill.name",headerName:this.mciTranslateService.getTranslation("L.Skill"),cellEditor:"materialInputEditor",filter:"agTextColumnFilter",cellRenderer:t=>t.value??O},{field:"organization.name",headerName:this.mciTranslateService.getTranslation("L.Organization"),filter:"agTextColumnFilter"},{field:"agreement.name",headerName:this.mciTranslateService.getTranslation("L.Agreement"),filter:"agTextColumnFilter",context:{isAutoSize:!0},cellRenderer:t=>t.value??O},l({field:"hours.st",headerName:this.mciTranslateService.getTranslation("L.ST"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.st??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.ot",headerName:this.mciTranslateService.getTranslation("L.OT"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.ot??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.dt",headerName:this.mciTranslateService.getTranslation("L.DT"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.dt??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r4",headerName:this.mciTranslateService.getTranslation("L.R4"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r4??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r5",headerName:this.mciTranslateService.getTranslation("L.R5"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r5??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r6",headerName:this.mciTranslateService.getTranslation("L.R6"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r6??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r7",headerName:this.mciTranslateService.getTranslation("L.R7"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r7??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r8",headerName:this.mciTranslateService.getTranslation("L.R8"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r8??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r9",headerName:this.mciTranslateService.getTranslation("L.R9"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r9??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r10",headerName:this.mciTranslateService.getTranslation("L.R10"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r10??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r11",headerName:this.mciTranslateService.getTranslation("L.R11"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r11??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r12",headerName:this.mciTranslateService.getTranslation("L.R12"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r12??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r13",headerName:this.mciTranslateService.getTranslation("L.R13"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r13??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r14",headerName:this.mciTranslateService.getTranslation("L.R14"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r14??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"hours.r15",headerName:this.mciTranslateService.getTranslation("L.R15"),cellRenderer:t=>this.mathService.formatNumber(t.value),valueGetter:t=>this.mathService.roundDisplay(t?.data?.hours?.r15??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l({field:"othercharges",headerName:this.mciTranslateService.getTranslation("L.Other_Charge"),cellRenderer:t=>{let i=this.mathService.formatNumber(t.value),e=t.data?.currency?.code;return this.mciGridService.cellWithSuffix(i,e)},valueGetter:t=>this.mathService.roundDisplay(t?.data?.othercharges??0,!1)},this.mciGridService.getBaseDecimalColumnDefinition()),l(l({field:"cost",headerName:this.mciTranslateService.getTranslation("L.Total_Amount"),cellRenderer:"materialToolTip",cellRendererParams:t=>{let i={simpleTooltip:!0};return i.value=this.mathService.formatNumber(t.value),this.canViewRates?i.suffix=t.data?.currency?.code:i.tooltip=this.mciTranslateService.getTranslation("M.No_Permission_Rates"),i},valueGetter:t=>this.canViewRates?this.mathService.roundDisplay(t?.data?.cost??0,!1):O,tooltipComponentParams:{hide:!this.canViewRates,customValueCb:t=>{let i=t?.value,e=t.data?.currency?.code;return`${i} ${e}`}}},this.mciGridService.getBaseNumericColumnDefinition(!0)),this.mciGridService.getDecimalColumnFilterParams()),{field:"area.labelname",headerName:this.mciTranslateService.getTranslation("L.Area_ID"),filter:"agTextColumnFilter",context:{isAutoSize:!0}},{field:"glaccount.name",headerName:this.mciTranslateService.getTranslation("L.GL_Account"),filter:"agTextColumnFilter",valueGetter:t=>t?.data?.glaccount?.name??O,cellRenderer:"materialToolTip",hide:!this.canViewGLAccount}
1,{field:"costobject.ordertype.name",headerName:this.mciTranslateService.getTranslation("L.Order_Type"),filter:"agTextColumnFilter",valueGetter:t=>this.uiUtilitiesService.getOrderTypeTranslation(t.data.costobject?.ordertype?.name)},{field:"costobject.purchaseorder.name",headerName:this.mciTranslateService.getTranslation("L.Purchase_Order"),filter:"agTextColumnFilter"},{field:"costobject.purchaseorderline.name",headerName:this.mciTranslateService.getTranslation("L.Purchase_Order_Line"),filter:"agTextColumnFilter"},{field:"costobject.labelname",headerName:this.mciTranslateService.getTranslation("L.Cost_Object_Type"),filter:"agTextColumnFilter"},{field:"costobject.name",headerName:this.mciTranslateService.getTranslation("L.Cost_Object"),filter:"agTextColumnFilter"},{field:"costobject.operation.name",headerName:this.mciTranslateService.getTranslation("L.Operation_Or_Activity"),filter:"agTextColumnFilter"},{field:"costobject.suboperation.name",headerName:this.mciTranslateService.getTranslation("L.Sub_Operation_Or_Element"),filter:"agTextColumnFilter"},{field:"attachmentdata",headerName:this.mciTranslateService.getTranslation("L.Attachment"),headerClass:"ag-center-aligned-header",cellClass:"ag-center-aligned-cell",cellRenderer:"materialGridIcon",filter:"agNumberColumnFilter",cellRendererParams:t=>t?.data?{icon:"attach_file",isDisplayValue:!0,propertyName:"attachmentdata",displayValueCb:i=>i?.data?.attachments?i.data.attachments.length:0,disabled:di.default.isEmpty(t?.data?.attachments),clickEvent:i=>{if(i.attachments){let e=i.attachments,a={id:i.resource.id,attachmentData:e};this.modalService.openAttachmentModal(this.viewRef,a,this.mciTranslateService.getTranslation("L.Labor_Unresolved_Allocation"),this.actionType,this.attachmentsPermissions,!1)}}}:{},comparator:this.compareService.attachmentComparator,context:{isAutoSize:!0},resizable:!1}]}contentMenuClick(t,i){switch(this.actionType=t,t){case this.actionList.EDIT:case this.actionList.VIEW:this.selectedRowData=i,this.getJobDetailsDataAndOpenDrawer(i,t);break;case this.actionList.DELETE:this.onMassDelete([i]);break;default:break}}getJobDetailsDataAndOpenDrawer(t,i){let e=this.uiUtilitiesService.site$.value.location_id,a=this.commonUtilitiesService.getTokenData().oid,r={OrganizationId:t.organization?.id,TimesheetDate:this.dateTimeService.toISODateFormat(t.workdate),ResourceId:t.resource?.id,AllocationIds:t?.allocations?.replaceAll('"',"")?.split(",")??[]};$({areaIdPermissions:this.commonService.getScreenNamePermissions(D.ALLOCATIONS_FOR_AREA_ID_CHANGE),orderTypes:this.masterDataService.getOrderTypes(),locationSettings:this.commonService.getLocationSettings(e),areaIds:this.commonService.getRestrictedAreaIdsByLocation(e),resourceInfo:this.allocationManagementService.getLaborAllocatedResource(r),allocationInfo:this.allocationManagementService.getLaborRejectedAllocation(r),userInfo:this.personalInformationService.getUser(a),applicationSettings:this.settingsService.getApplicationSettings()}).pipe(Se(this.destroyRef)).subscribe(({areaIdPermissions:s,orderTypes:n,locationSettings:o,areaIds:m,resourceInfo:h,allocationInfo:y,userInfo:b,applicationSettings:E})=>{let p;if(h[0]?.data?.length){let M=h[0]?.data?.map(f=>f?.rateadjustments?.length?(f?.rateadjustments?.forEach(I=>{I.ratetypename=I.ratetypename?.toLowerCase()??"",I.rateassocid=I.rateassocid??"",I.rateadjustid=I.rateadjustid??"",I.value=I?.ratevalues??0,I.rateorpercentflag=I?.rateorpercentflag??!1}),{ratekey:f.rateadjustments[0]?.ratetypename?.toLowerCase()??"",ratearr:f?.rateadjustments??[]}):null)?.filter(Boolean)??[],je=Object.keys(h[0]?.data[0].hours);h[0]?.data?.forEach(f=>{je?.forEach(I=>{f?.hours[I]>0&&f?.hours[I]!==null&&(h[0].data[0].hours[I]=f?.hours[I]??0)})}),h[0].data[0].hours.total=je?.reduce((f,I)=>f+(I!=="total"?h[0]?.data[0]?.hours[I]:0),0);let L=M?.reduce(function(f,I){return f[I.ratekey]=I.ratearr??[],f},{});h[0].data[0].rateadjust=h[0]?.data[0]?.rateaddervalue??{},p=h[0]?.data[0],p&&y&&(p.allocate=y[0].data[0].allocate,p.available=y[0].data[0].available,p.savedRateadjustments=L??{},p.allocations=h[0].data?.map(f=>f?.allocations?.replaceAll('"',"")?.split(","))?.flat(1))}this.jobDetailsData={locationSettings:o[0]?.data?.settings,areaIdEditPermission:s[0]?.data?.edit,orderTypes:n[0]?.data,areaIds:m[0]?.data?.map(M=>({id:M.AreaId,name:M.AreaName,areadisplayfield:M.AreaDisplayField})),selectedResource:p,userOrderType:b[0].data.ordertype},this.allocationApplicationSettings=E[0].data?.allocation,this.openDrawerAndSetForm(i)})}openDrawerAndSetForm(t){let i=this.selectedRowData?.resource?.name??"",e=this.selectedRowData?.resource?.laborid,a=e?`${i} (${e})`:i,r=this.getDrawerHeaderLabels(t,a,this.selectedRowData?.organization?.name),s={showDynamicFields:this.showDynamicFields,nonBillPerms:this.nonBillPerms,lumpSumPerms:this.lumpSumPerms,subConPerms:this.subConPerms,jobDetailsData:this.jobDetailsData,canViewRates:this.canViewRates,allocationApplicationSettings:this.allocationApplicationSettings},n=new de(t,this.selectedRowData,this.permissions,s),o=new _e(Ze,r.title,this.actionType===d.EDIT?this.selectedRowData?.organization?.name:r.subtitle,null,this.drawerSizesEnum.MEDIUM,null,n);this.drawerService.updateDrawerContent(o),this.drawerService.openDrawer()}onFiltersInitialized(t){this.filtersForm=t,this.getModelValues(this.uiUtilitiesService.site$.value,!0),this.uiUtilitiesService.site$.pipe(he(1),this.takeUntilDestroyed(this.destroyRef)).subscribe(i=>{i&&this.getModelValues(i,!1)}),this.filterSectionService.filterChanged$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(i=>{let e=i.selectedValue!==void 0?i.selectedValue:i.form?.controls?.[i.formControlName]?.value;i.isAdvancedFilter&&i.formControlName&&this.filtersForm?.controls[i.formControlName]&&this.filtersForm.controls[i.formControlName].setValue(e,{emitEvent:!1}),i.formControlName==="organization"?this.onOrganizationChange(e?.id):i.formControlName==="group"&&this.onGroupChange()})}applyRouteFilters(t){if(t?.locationId&&t?.locationId===this.uiUtilitiesService.site$.value.location_id){t?.startDate&&t?.endDate&&(this.filtersForm.controls.timesheetDate.setValue({id:q.CustomDateRange}),this.filtersForm.controls.customStartDate.setValue(ce.parseISODateLocal(t.startDate)),this.filtersForm.controls.customEndDate.setValue(ce.parseISODateLocal(t.endD
1ate))),t?.orgIds&&this.filtersForm.controls.organization.setValue(this.organizationList.find(e=>t.orgIds.includes(e.id))),this.onApplyFilters(this.filtersForm,t);let i={notificationtypes:[Tt.REJECT_ALLOCATION],classifications:[ae.LABOR],enddate:t.endDate};this.notificationStateService.clearTypes(i).pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(e=>{e||this.notificationBarService.showErrorNotificationMessage(this.mciTranslateService.getTranslation("M.Unable_To_Update_Notifications"))})}}onOrganizationChange(t){this.filtersForm.controls?.resource?.reset(),this.filterSectionService.resetFormControls$.next(["resource"]),this.getGroups(t),this.searchResources()}onGroupChange(){let t=this.filtersForm.controls?.resource?.value??[],i=this.filtersForm.controls?.group?.value?.map(a=>a.groupid)??[],e;i.length===0?e=t:e=t.filter(a=>a.resourcegroups?.some(r=>i.includes(r.id))),this.filtersForm.controls.resource.setValue(e),this.filterSectionService.updateFormAdvFilter$.next(this.filtersForm),this.searchResources()}getGroups(t){this.filterDefinitions[2].inlineLoading=!0,this.resourceService.getLaborGroups({name:"labor",vendorids:[t]},"Labor Group").subscribe({next:i=>{i[0]?.data&&i[0]?.success?this.groupList=i[0].data:this.groupList=[],this.filterDefinitions[2].inputValues=this.groupList,this.filterDefinitions[2].inlineLoading=!1},error:()=>{this.filterDefinitions[2].inlineLoading=!1}})}getModelValues(t,i){i||(this.filtersForm.controls.organization.reset(),this.filtersForm.controls.resource.reset()),this.defaultLocation=t?.location_id,this.getOrganizations()}onApplyFilters(t,i=null){this.filtersForm=t,this.reloadGridData(!1,!1,i)}onResetFilters(t){this.filtersForm.reset({filterSort:this.defaultFilterSort,timesheetDate:this.defaultDateRange,organization:this.organizationList[0],group:this.getGroups(this.organizationList[0].id),resource:[]}),this.searchResources(),this.filterSectionService.afterReset$.next(null),t&&this.reloadGridData()}initializeFilterSection(){let t=this.commonUtilitiesService.getTokenData().oid,i;this.personalInformationService.getDefaultDateFilter(be.UNRESOLVED,t).subscribe(e=>{i=e,i&&i.selectedvalue&&(this.defaultDateRange.id=parseInt(q[i.selectedvalue])),this.filterDefinitions=[{labelName:this.mciTranslateService.getTranslation("L.Timesheet_Date"),controlType:this.CONTROL_TYPE.DATE_SHORTCUT,disableAlphabeticalSorting:!0,isMultiSelect:!1,formControlName:"timesheetDate",inputValueLabel:"name",initialValue:this.defaultDateRange,accordionGroupName:this.mciTranslateService.getTranslation("L.Date_Range"),useSession:!0,sessionKey:Q.FORM_SPECIFIC},{labelName:this.mciTranslateService.getTranslation("L.Organization"),placeholder:this.mciTranslateService.getTranslation("L.Select_Organization"),isMultiSelect:!1,inputValueLabel:"name",inputValues:this.organizationList,controlType:this.CONTROL_TYPE.PICKER,formControlName:"organization",useSession:!0,sessionKey:Q.ORGANIZATION,callbackSearch:this.getOrganizations},{labelName:this.mciTranslateService.getTranslation("L.Group"),placeholder:this.mciTranslateService.getTranslation("L.Select_Groups"),isMultiSelect:!0,inputValueLabel:"name",inputValues:[],controlType:this.CONTROL_TYPE.PICKER,enableDataLoadingOnScrollOrSearch:!1,recordIdName:"id",subGroupKey:"vendorname",formControlName:"group"},{labelName:this.mciTranslateService.getTranslation("L.Resource"),placeholder:this.mciTranslateService.getTranslation("L.Select_Resources"),isMultiSelect:!0,inputValueLabel:"name",inputValues:this.resourceList,controlType:this.CONTROL_TYPE.PICKER,formControlName:"resource",callbackSearch:this.searchResources}];let a={filterDefinitions:this.filterDefinitions,showAdvancedFilterButton:!0,associatedGridId:this.listingPageGridKey,alertLargeTimesheetDateFilter:!0};this.filterSectionService.initialize(a)})}onMassDelete(t){this.openDeleteDialog(t)}openDeleteDialog(t){let i=(t??[]).map(a=>ee(l({},a),{name:a?.resource?.name??""})),e=this.modalService.openConfirmActionModal(t,this.entity,this.entityPlural,d.DELETE,le.ASYNC_CONFIRM);e.componentInstance.confirmAction$.pipe(this.takeUntilDestroyed(this.destroyRef)).subscribe(a=>{if(a===d.DELETE){let r=this.allocationManagementService.getDeleteRequestBody(t);this.allocationManagementService.deleteLaborAllocationsByIds(r).subscribe(s=>{e.close(),s[0].success&&(this.reloadGridData(!0),this.deselectRows(),this.uiUtilitiesService.closeDrawer()),this.uiUtilitiesService.handleMassActionResponseMessage(s[0],$e.DELETE,this.entity,this.entityPlural,"",i)})}})}onColumnStateReset(){this.mciGridService.determineRateColumnVisibility(this.columnDefs,this.gridData,this.gridApi,this.listingPageGridKey)}
1onExceptionIconClick(t,i){switch(t){case S.PAY_FORMULA_MISSING:case S.SCHEDULE_MISSING:case S.RUNNER:case S.REVOKED:case S.RISK_ATTRIBUTE_EXPIRED:case S.OVERRIDE_APPROVE:case S.OVERRIDE_REJECT:case S.OVERRIDE_REQUEST:case S.OVERRIDE_DECLINE:{let e={exceptionIcon:t,extraData:{resourceId:i?.resource?.id,timesheetDate:i.workdate,organizationId:i.organization.id,timesheetId:i.timesheet.id,timesheetRef:i.timesheetreference}};this.exceptionIconService.onExceptionIconClick(e);break}default:break}}static{this.\u0275fac=function(i){return new(i||c)}}static{this.\u0275cmp=B({type:c,selectors:[["app-labor-unresolved"]],features:[K],decls:4,vars:19,consts:[["associatedGridId","laborUnresolvedListing",3,"isDataRestrictedChange","isDataRestricted","showLongDateAlertForDataRestriction","formName","totalFilterCount"],[1,"mci-ui-card-flat-border"],[1,"mci-ui-table"],[3,"addClick","columnStateReset","gridReady","massDelete","rowDataUpdated","columnDefinition","exportForImportCB","fileName","getRowIdCB","gridData","gridHeight","isLoadingExportForImportButton","key","showAddButton","showGridDeleteButton","showGridExportForImportButton","showGridStatusButton","templateName","showExportImportGridMenuOption","useNewExportForImportMethod"]],template:function(i,e){i&1&&(u(0,"app-filter-section",0),ve("isDataRestrictedChange",function(r){return ge(e.isDataRestricted,r)||(e.isDataRestricted=r),r}),T(),u(1,"div",1)(2,"div",2)(3,"app-common-data-grid",3),A("addClick",function(){return e.contentMenuClick(e.actionList.ADD,null)})("columnStateReset",function(){return e.onColumnStateReset()})("gridReady",function(r){return e.onGridReady(r)})("massDelete",function(){return e.onMassDelete(e.gridApi==null?null:e.gridApi.getSelectedRows())})("rowDataUpdated",function(r){return e.onRowDataUpdated(r)}),T()()()),i&2&&(fe("isDataRestricted",e.isDataRestricted),g("showLongDateAlertForDataRestriction",!0)("formName",e.listingPageGridKey)("totalFilterCount",4),v(3),g("columnDefinition",e.columnDefs)("exportForImportCB",e.getExportForImportTemplate)("fileName",e.fileName)("getRowIdCB",e.getRowIdCallBack)("gridData",e.gridData)("gridHeight",e.gridHeight)("isLoadingExportForImportButton",e.isLoadingExportForImportButton)("key",e.listingPageGridKey)("showAddButton",!1)("showGridDeleteButton",e.permissions==null?null:e.permissions.canDelete)("showGridExportForImportButton",!0)("showGridStatusButton",!1)("templateName",e.templateName)("showExportImportGridMenuOption",!0)("useNewExportForImportMethod",!0))},dependencies:[Ne,H],encapsulation:2})}}return c})();var vs=(()=>{class c{constructor(){this.tabs=[{label:Ke.NOT_ALLOCATED,screenName:D.ALLOCATIONS_FOR_LABOR,component:ci},{label:Ke.ALLOCATED,screenName:D.ALLOCATIONS_FOR_LABOR,component:li},{label:Ke.UNRESOLVED,screenName:D.ALLOCATIONS_FOR_LABOR,component:mi}]}static{this.\u0275fac=function(i){return new(i||c)}}static{this.\u0275cmp=B({type:c,selectors:[["app-labor-allocation-management"]],decls:1,vars:1,consts:[[3,"tabs"]],template:function(i,e){i&1&&F(0,"mci-tab-group",0),i&2&&g("tabs",e.tabs)},dependencies:[ai],encapsulation:2})}}return c})();export{vs as LaborAllocationManagementComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.