Skip to content

Commit

Permalink
Merge pull request #804 from odisha-muktasoft/UCEM-1009
Browse files Browse the repository at this point in the history
[UCEM-1009,UCEM-1011,UCEM-1041] : updated the individual API call and…
  • Loading branch information
Tulika-eGov authored Nov 26, 2024
2 parents 28a0aca + 7c76d68 commit 20970bf
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const Urls = {

wageseeker: {
create: "/individual/v1/_create",
search: "/individual/v1/_search",
search: "/mukta-services/individual/v1/_search",
wmssearch: "/wms/individual/_search",
update: "/individual/v1/_update",
delete: "/individual/v1/_delete",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AttendanceService from "../../elements/Attendance";
import { WageSeekerService } from "../../elements/WageSeeker";
import { WorksService } from "../../elements/Works";

const attendanceTypes = {
Expand Down Expand Up @@ -41,29 +42,31 @@ const getWeekAttendance = (data) => {
return weekAttendance
}

const getAttendanceTableData = async(data, skills, t, expenseCalculations) => {
const getAttendanceTableData = async(data, skills, t, expenseCalculations, indResponse) => {
let individuals = indResponse?.Individual;
let tableData = {}
if(data?.individualEntries?.length > 0) {
data?.individualEntries.filter((ob) => ob?.attendanceEntries !== null)?.forEach((item, index) => {
let tableRow = {}
let individualdata = individuals?.filter((ob) => ob?.individualId === item?.additionalDetails?.userId)?.[0]
tableRow.id = item.id
tableRow.sno = index + 1
tableRow.registerId = item?.additionalDetails?.userId || t("NA")
tableRow.registerId = {isLink:true, label:individualdata?.individualId, to:`/works-ui/employee/masters/view-wageseeker?tenantId=${individualdata?.tenantId}&individualId=${individualdata?.individualId}`} || t("NA")
tableRow.actualWorkingDays = item?.actualTotalAttendance || 0
tableRow.nameOfIndividual = item?.additionalDetails?.userName || t("NA")
tableRow.guardianName = item?.additionalDetails?.fatherName || t("NA")
const skill = skills[item?.additionalDetails?.skillCode]
tableRow.nameOfIndividual = individualdata?.name?.givenName || t("NA")
tableRow.guardianName = individualdata?.fatherName || t("NA")
const skill = skills[individualdata?.skills?.[0]?.type]
tableRow.skill = skill ? `${t(skill.sorSubType)} - ${skill.description}` : t("NA");
tableRow.amount = skills[item?.additionalDetails?.skillCode]?.amount * item?.actualTotalAttendance || 0
tableRow.amount = skills[individualdata?.skills?.[0]?.type]?.amount * item?.actualTotalAttendance || 0
tableRow.modifiedAmount = expenseCalculations?.filter(data=>data?.payee?.identifier === item?.individualId)?.[0]?.lineItems?.[0]?.amount || 0;
tableRow.modifiedWorkingDays = item?.modifiedTotalAttendance ? item?.modifiedTotalAttendance : item?.actualTotalAttendance
tableRow.bankAccountDetails = {
accountNo : item?.additionalDetails?.bankDetails || t("NA"),
ifscCode : null
}
tableRow.aadharNumber = item?.additionalDetails?.aadharNumber || t("NA")
// tableRow.bankAccountDetails = {
// accountNo : item?.additionalDetails?.bankDetails || t("NA"),
// ifscCode : null
// }
// tableRow.aadharNumber = item?.additionalDetails?.aadharNumber || t("NA")
tableRow.attendence = getWeekAttendance(item?.attendanceEntries)
tableRow.perDayWage = skills[item?.additionalDetails?.skillCode]?.rates?.rate || 0
tableRow.perDayWage = skills[individualdata?.skills?.[0]?.type]?.rates?.rate || 0
tableData[item.id] = tableRow
});

Expand All @@ -88,7 +91,7 @@ const getAttendanceTableData = async(data, skills, t, expenseCalculations) => {
return tableData
}

const transformViewDataToApplicationDetails = async (t, data, skills) => {
const transformViewDataToApplicationDetails = async (t, data, skills, indResponse) => {

const expenseCalculatorPayload = {
criteria : {
Expand All @@ -103,7 +106,7 @@ const transformViewDataToApplicationDetails = async (t, data, skills) => {
if(data?.musterRolls?.length === 0) throw new Error('No data found');

const musterRoll = data.musterRolls[0]
const attendanceTableData = await getAttendanceTableData(musterRoll, skills, t, expenseCalculations)
const attendanceTableData = await getAttendanceTableData(musterRoll, skills, t, expenseCalculations, indResponse)

const totalAmount = expenseCalculationsResponse?.calculation?.totalAmount;
const weekDates = getWeekDates(musterRoll)
Expand Down Expand Up @@ -206,9 +209,19 @@ export const fetchAttendanceDetails = async (t, tenantId, searchParams) => {
try {
const response = await AttendanceService.search(tenantId, searchParams);
// const workflowDetails = await workflowDataDetails(tenantId, searchParams.musterRollNumber);
let IndsToSearch = response?.musterRolls?.[0].individualEntries.map((ob) => ob?.individualId)

let indPayload =IndsToSearch?.length!==0 ? {
Individual:{
id:IndsToSearch
}
} : null

const indResponse = await WageSeekerService.search(tenantId, indPayload, {tenantId,offset:0,limit:100});

const skills = await getWageSeekerSkills(response)

return transformViewDataToApplicationDetails(t, response, skills)
return transformViewDataToApplicationDetails(t, response, skills, indResponse)
} catch (error) {
throw new Error(error?.response?.data?.Errors[0].message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import BillingService from "../../../elements/Bill";
import { ContractService } from "../../../elements/Contracts";
import AttendanceService from "../../../elements/Attendance";
import { WageSeekerService } from "../../../elements/WageSeeker";

const getBeneficiaryData = async (wageBillDetails, tenantId, musterRoll, t) => {
const getBeneficiaryData = async (wageBillDetails, tenantId, musterRoll, t, indResponse) => {
let tableData = {}
const individuals = musterRoll?.individualEntries
const individuals = indResponse?.Individual
if(wageBillDetails?.length > 0) {
wageBillDetails?.forEach((item, index) => {
let tableRow = {}
const individual = individuals?.find(ind => ind?.individualId === item?.payee?.identifier)
const individual = individuals?.find(ind => ind?.id === item?.payee?.identifier)
tableRow.id = item?.id
tableRow.sno = index + 1
tableRow.registerId = individual?.additionalDetails?.userId || t("NA")
tableRow.nameOfIndividual = individual?.additionalDetails?.userName || t("NA")
tableRow.guardianName = individual?.additionalDetails?.fatherName || t("NA")
//tableRow.registerId = individual?.individualId || t("NA")
tableRow.registerId = {to:`/works-ui/employee/masters/view-wageseeker?tenantId=${tenantId}&individualId=${individual?.individualId}`, label:individual?.individualId, isLink:true}
tableRow.nameOfIndividual = individual?.name?.givenName || t("NA")
tableRow.guardianName = individual?.fatherName || t("NA")
// tableRow.amount = item?.payableLineItems?.[0]?.amount || 0 //check if correct(add all payable here)
tableRow.amount = item?.payableLineItems?.reduce((acc,item)=>{
if(item?.type==="PAYABLE") return acc + item.amount
return acc
},0) || 0 //check if correct(add all payable here)
tableRow.bankAccountDetails = {
accountNo : individual?.additionalDetails?.bankDetails || t("NA"),
ifscCode : null
}
// tableRow.bankAccountDetails = {
// accountNo : individual?.additionalDetails?.bankDetails || t("NA"),
// ifscCode : null
// }
//update this id
tableData[item.id] = tableRow
});
Expand All @@ -35,7 +37,7 @@ const getBeneficiaryData = async (wageBillDetails, tenantId, musterRoll, t) => {
totalRow.nameOfIndividual = "DNR"
totalRow.guardianName = "DNR"
totalRow.amount = 0
totalRow.bankAccountDetails = ""
//totalRow.bankAccountDetails = ""

tableData['total'] = totalRow
}
Expand Down Expand Up @@ -70,8 +72,18 @@ const transformViewDataToApplicationDetails = async (t, data, tenantId) => {
//get muster details
const musterRes = await AttendanceService.search(tenantId, { musterRollNumber: musterRollNum });
const musterRoll = musterRes?.musterRolls?.[0]

let IndsToSearch = musterRes?.musterRolls?.[0].individualEntries.map((ob) => ob?.individualId)

let indPayload =IndsToSearch?.length!==0 ? {
Individual:{
id:IndsToSearch
}
} : null

const indResponse = await WageSeekerService.search(tenantId, indPayload, {tenantId,offset:0,limit:100});

const beneficiaryData = await getBeneficiaryData(wageBill?.billDetails, tenantId, musterRoll, t)
const beneficiaryData = await getBeneficiaryData(wageBill?.billDetails, tenantId, musterRoll, t, indResponse)

const billDetails = {
title: " ",
Expand All @@ -90,7 +102,7 @@ const transformViewDataToApplicationDetails = async (t, data, tenantId) => {
title: "EXP_BENEFICIARY_DETAILS",
asSectionHeader: true,
values: [
{ title: "ES_COMMON_MUSTER_ROLL_ID", value: musterRollNum || t("ES_COMMON_NA")},
{ title: "ES_COMMON_MUSTER_ROLL_ID", value: musterRollNum || t("ES_COMMON_NA"), isLink : true, to : '/works-ui/employee/attendencemgmt/view-attendance?tenantId=od.testing&musterRollNumber=MR/2024-25/09/24/000957'},
{ title: "ES_COMMON_MUSTER_ROLL_PERIOD", value: `${Digit.DateUtils.ConvertTimestampToDate(musterRoll?.startDate, 'dd/MM/yyyy')} - ${Digit.DateUtils.ConvertTimestampToDate(musterRoll?.endDate, 'dd/MM/yyyy')}` || t("ES_COMMON_NA") }
],
additionalDetails : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { WageSeekerService } from "../../elements/WageSeeker";
const transformViewDataToApplicationDetails = async (t, data, tenantId) => {
if(data?.Individual?.length === 0) throw new Error('No data found');

const individual = data.Individual[0]
const individual = data?.Individual?.[0]
const headerLocale = Digit.Utils.locale.getTransformedLocale(tenantId)

const bankDetailPayload = { bankAccountDetails: { tenantId, serviceCode: "IND", referenceId: [individual?.id] } }
Expand All @@ -25,14 +25,14 @@ const transformViewDataToApplicationDetails = async (t, data, tenantId) => {
asSectionHeader: true,
values: [
{ title: "MASTERS_WAGE_SEEKER_ID", value: individual?.individualId || t("NA")},
{ title: "ES_COMMON_AADHAR", value: adhaar ? adhaar?.identifierId : t("NA")},
{ title: "ES_COMMON_AADHAR", value: adhaar ? t(adhaar?.identifierId) : t("NA")},
{ title: "MASTERS_NAME_OF_WAGE_SEEKER", value: individual?.name?.givenName || t("NA")},
{ title: "MASTERS_FATHER_HUSBAND_NAME", value: individual?.fatherName || t("NA")},
{ title: "ES_COMMON_RELATIONSHIP", value: individual?.relationship ? `COMMON_MASTERS_RELATIONSHIP_${individual?.relationship}` : t("NA")},
{ title: "ES_COMMON_RELATIONSHIP", value: individual?.relationship ? (individual?.relationship?.includes("UNDISCLOSED")? t(individual?.relationship): `COMMON_MASTERS_RELATIONSHIP_${individual?.relationship}`) : t("NA")},
{ title: "ES_COMMON_BIRTHDATE", value: individual?.dateOfBirth || t("NA")},
{ title: "CORE_COMMON_PROFILE_GENDER", value: individual?.gender ? `COMMON_MASTERS_GENDER_${individual?.gender}` : t("NA")},
{ title: "CORE_COMMON_PROFILE_GENDER", value: individual?.gender ?(individual?.gender?.includes("UNDISCLOSED") ? t(individual?.gender) : `COMMON_MASTERS_GENDER_${individual?.gender}`) : t("NA")},
{ title: "CORE_COMMON_PROFILE_MOBILE_NUMBER", value: individual?.mobileNumber || t("NA")},
{ title: "MASTERS_SOCIAL_CATEGORY", value: socialCategory ? `COMMON_MASTERS_SOCIAL_${socialCategory?.value}` : t("NA")}
{ title: "MASTERS_SOCIAL_CATEGORY", value: socialCategory ? (socialCategory?.value?.includes("UNDISCLOSED")? t(socialCategory?.value): `COMMON_MASTERS_SOCIAL_${socialCategory?.value}`) : t("NA")}
],
additionalDetails: {
skills: {
Expand All @@ -41,17 +41,18 @@ const transformViewDataToApplicationDetails = async (t, data, tenantId) => {
},
photo : {
title: "ES_COMMON_PHOTOGRAPH",
thumbnailsToShow: thumbnails
thumbnailsToShow: thumbnails,
isMasked : thumbnails && individual?.additionalFields?.isPhotoMasked == true ? "CS_COMMON_UNDISCLOSED" : false
}
}
}
const locationDetails = {
title: "ES_COMMON_LOCATION_DETAILS",
asSectionHeader: true,
values: [
{ title: "CORE_COMMON_PROFILE_CITY", value: individual?.address?.[0]?.tenantId ? Digit.Utils.locale.getCityLocale(individual?.address?.[0]?.tenantId) : t("NA")},
{ title: "COMMON_WARD", value: individual?.address?.[0]?.ward?.code ? Digit.Utils.locale.getMohallaLocale(individual?.address?.[0]?.ward?.code, tenantId) : t("NA")},
{ title: "COMMON_LOCALITY", value: individual?.address?.[0]?.locality?.code ? Digit.Utils.locale.getMohallaLocale(individual?.address?.[0]?.locality?.code, tenantId) : t("NA")},
{ title: "CORE_COMMON_PROFILE_CITY", value: individual?.address?.[0]?.tenantId ? (individual?.address?.[0]?.city?.includes("*") ? getAddressMasked(Digit.Utils.locale.getCityLocale(individual?.address?.[0]?.tenantId)) : Digit.Utils.locale.getCityLocale(individual?.address?.[0]?.tenantId)) : t("NA")},
{ title: "COMMON_WARD", value: individual?.address?.[0]?.ward?.code ? (individual?.address?.[0]?.ward?.additionalDetails?.isMasked ? getAddressMasked(Digit.Utils.locale.getMohallaLocale(individual?.address?.[0]?.ward?.code, tenantId)) : Digit.Utils.locale.getMohallaLocale(individual?.address?.[0]?.ward?.code, tenantId)) : t("NA")},
{ title: "COMMON_LOCALITY", value: individual?.address?.[0]?.locality?.code ? (individual?.address?.[0]?.locality?.additionalDetails?.isMasked ? getAddressMasked(Digit.Utils.locale.getMohallaLocale(individual?.address?.[0]?.locality?.code, tenantId)) : Digit.Utils.locale.getMohallaLocale(individual?.address?.[0]?.locality?.code, tenantId)) : t("NA")},
{ title: "ES_COMMON_STREET", value: individual?.address?.[0]?.street || t("NA")},
{ title: "ES_COMMON_DOOR_NO", value: individual?.address?.[0]?.doorNo || t("NA")},
]
Expand Down Expand Up @@ -83,6 +84,11 @@ const transformViewDataToApplicationDetails = async (t, data, tenantId) => {
}
}

const getAddressMasked = (value) => {
return value.replace(/.(?=.{1,}$)/g, '*');

}

const fetchBankDetails = async (data, tenantId) => {
if(data?.Individual?.length === 0) throw new Error('No data found');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,21 @@ const WeekAttendence = ({ state, dispatch, modify, setSaveAttendanceState, weekD
return Digit.Utils.dss.formatterWithoutRound(value, 'number');
},
},
{
Header: () => <p>{t("ATM_BANK_ACCOUNT_DETAILS")}</p>,
accessor: "bankAccountDetails",
Cell: ({ value, column, row }) => {
return renderBankAccountDetails(value);
},
},
{
Header: () => <p>{t("ATM_WAGE_SEEKER_AADHAR")}</p>,
accessor: "aadharNumber",
Cell: ({ value, column, row }) => {
return String(t(value));
}
}
// removed for DPP
// {
// Header: () => <p>{t("ATM_BANK_ACCOUNT_DETAILS")}</p>,
// accessor: "bankAccountDetails",
// Cell: ({ value, column, row }) => {
// return renderBankAccountDetails(value);
// },
// },
// {
// Header: () => <p>{t("ATM_WAGE_SEEKER_AADHAR")}</p>,
// accessor: "aadharNumber",
// Cell: ({ value, column, row }) => {
// return String(t(value));
// }
// }
]
let colsToReturn = [];
// if(showFullTableReadOnly || editable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ export const mustorRollDetailsTableColumns = (t) => [
return <Amount customStyle={{ textAlign: 'right'}} value={value} t={t}></Amount>
}
},
{
Header: () => <p>{t("EXP_BANK_ACCOUNT_DETAILS")}</p>,
accessor: "bankAccountDetails",
Cell: ({ value, column, row }) => {
return renderBankAccountDetails(value);
}
},
//removed for DPP
// {
// Header: () => <p>{t("EXP_BANK_ACCOUNT_DETAILS")}</p>,
// accessor: "bankAccountDetails",
// Cell: ({ value, column, row }) => {
// return renderBankAccountDetails(value);
// }
// },
// {
// Header: () => <p>{t("ES_COMMON_PAYMENT_STATUS")}</p>,
// accessor: "paymentStatus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ export const getWageSeekerUpdatePayload = ({formData, wageSeekerDataFromAPI, ten
givenName: formData?.basicDetails_wageSeekerName
}
Individual.dateOfBirth = Digit.DateUtils.ConvertTimestampToDate(new Date(formData?.basicDetails_dateOfBirth), 'dd/MM/yyyy')
Individual.gender = formData?.basicDetails_gender?.code
if(!(formData?.basicDetails_gender?.code?.includes("UNDISCLOSED"))) Individual.gender = formData?.basicDetails_gender?.code
Individual.mobileNumber = formData?.basicDetails_mobileNumber
Individual.fatherName = formData?.basicDetails_fatherHusbandName
Individual.relationship = formData?.basicDetails_relationShip?.code
if(!(formData?.basicDetails_relationShip?.code?.includes("UNDISCLOSED")))Individual.relationship = formData?.basicDetails_relationShip?.code
// Individual.skills = formData?.skillDetails_skill?.map(skill => ({ level: skill?.code?.split('.')?.[0], type: skill?.code?.split('.')?.[1]}))
Individual.photo = formData?.basicDetails_photograph?.[0]?.[1]?.fileStoreId?.fileStoreId

//DPP update here as well for socialCategory
if(formData?.basicDetails_socialCategory?.code) {
Individual.additionalFields = {
fields: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Photos = ({ data, OpenImage }) => {
<CardLabel style={{fontSize: "16px", fontWeight: "600", marginBottom: "8px", marginTop: "20px"}}>{t(data?.title)}</CardLabel>
{ data?.thumbnailsToShow ?
<DisplayPhotos style={{maxWidth: "850px", paddingTop: 0}} srcs={data?.thumbnailsToShow?.thumbs} onClick={(src, index) => { OpenImage(src, index, data?.thumbnailsToShow) }}/>
: <CardLabel >{t('NA')}</CardLabel>
: <CardLabel >{data?.isMasked ? t(data?.isMasked) : t('NA')}</CardLabel>
}
</React.Fragment>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ const Table = ({
<tr {...row.getRowProps()}>
{showAutoSerialNo && <td>{i + 1}</td>}
{row.cells.map((cell) => {
const cellValue = cell.value;
const isLinkObject = cellValue && typeof cellValue === "object" && cellValue.isLink;
return (
<td
// style={{ padding: "20px 18px", fontSize: "16px", borderTop: "1px solid grey", textAlign: "left", verticalAlign: "middle" }}
Expand All @@ -199,9 +201,9 @@ const Table = ({
getCellProps(cell),
])}
>
{cell.attachment_link ? (
<a style={{ color: "#1D70B8" }} href={cell.attachment_link}>
{cell.render("Cell")}
{cell.attachment_link || isLinkObject ? (
<a style={{ color: isLinkObject ? "#c84c0e" :"#1D70B8" }} href={cell.attachment_link || cellValue?.to}>
{isLinkObject? cellValue?.label : cell.render("Cell")}
</a>
) : (
<React.Fragment> {cell.render("Cell")} </React.Fragment>
Expand Down

0 comments on commit 20970bf

Please sign in to comment.