Exemplo n.º 1
0
        private void GenerateMPFDataByPeriod(GenericMPFFileDetail mpfFileDetail, ArrayList periodList)
        {
            foreach (GenericMPFFileContributionDetail contributionDetail in mpfFileDetail.MPFContributionDetailList)
            {
                MPFPeriod currentMPFPeriod = null;
                foreach (MPFPeriod mpfPeriod in periodList)
                {
                    if (mpfPeriod.PeriodFrom < contributionDetail.PeriodTo && mpfPeriod.PeriodTo > contributionDetail.PeriodFrom)
                    {
                        if (mpfPeriod.PeriodFrom > contributionDetail.PeriodFrom)
                        {
                            mpfPeriod.PeriodFrom = contributionDetail.PeriodFrom;
                        }
                        if (mpfPeriod.PeriodTo < contributionDetail.PeriodTo)
                        {
                            mpfPeriod.PeriodFrom = contributionDetail.PeriodFrom;
                        }
                        currentMPFPeriod = mpfPeriod;
                    }
                }
                if (currentMPFPeriod == null)
                {
                    currentMPFPeriod = CreateMPFPeriod(contributionDetail.PeriodFrom, contributionDetail.PeriodTo);
                    periodList.Add(currentMPFPeriod);
                }
                string[] mpfFileMCDetailStringList = new string[6];
                mpfFileMCDetailStringList[0] = MPFPlanPlanNo;
                mpfFileMCDetailStringList[1] = "1";
                mpfFileMCDetailStringList[2] = mpfFileDetail.HKIDPassport;
                mpfFileMCDetailStringList[3] = contributionDetail.MCER.ToString("0.00");
                mpfFileMCDetailStringList[4] = contributionDetail.MCEE.ToString("0.00");
                mpfFileMCDetailStringList[5] = contributionDetail.RelevantIncome.ToString("0.00");

                currentMPFPeriod.DetailStringList.Add(string.Join(FIELD_DELIMITER, mpfFileMCDetailStringList));

                if (contributionDetail.VCEE != 0 || contributionDetail.VCER != 0)
                {
                    string vcPlanNo = string.Empty;

                    System.Xml.XmlNodeList vcPlanNoNodeNode = HROne.CommonLib.Utility.GetXmlDocumentByDataString(mpfFileDetail.EmpAVCPlanExtendXMLString).GetElementsByTagName("EmpAVCPlanBOCIVCPlanNo");
                    if (vcPlanNoNodeNode.Count > 0)
                    {
                        vcPlanNo = vcPlanNoNodeNode[0].InnerText;
                    }
                    if (string.IsNullOrEmpty(vcPlanNo))
                    {
                        throw new Exception("Voluntary Plan No. is missing:" + mpfFileDetail.EmpNo + " - " + mpfFileDetail.EmpName);
                    }

                    string[] mpfFileVCDetailStringList = new string[6];
                    mpfFileVCDetailStringList[0] = vcPlanNo;
                    mpfFileVCDetailStringList[1] = "0";
                    mpfFileVCDetailStringList[2] = mpfFileDetail.HKIDPassport;
                    mpfFileVCDetailStringList[3] = contributionDetail.VCER.ToString("0.00");
                    mpfFileVCDetailStringList[4] = contributionDetail.VCEE.ToString("0.00");
                    mpfFileVCDetailStringList[5] = contributionDetail.RelevantIncome.ToString("0.00");
                    currentMPFPeriod.DetailStringList.Add(string.Join(FIELD_DELIMITER, mpfFileVCDetailStringList));
                }
            }
        }
Exemplo n.º 2
0
        //private void SaveSequenceNo(int NewSequenceNo)
        //{
        //    EMPFPlan mpfPlan = new EMPFPlan();
        //    mpfPlan.MPFPlanID = MPFPlanID;
        //    if (EMPFPlan.db.select(dbConn, mpfPlan))
        //    {
        //        System.Xml.XmlDocument xmlDoc = HROne.CommonLib.Utility.GetXmlDocumentByDataString(mpfPlan.MPFPlanExtendData);
        //        System.Xml.XmlNodeList nodeList = xmlDoc.GetElementsByTagName(MPF_PLAN_XML_SEQUENCE_NODE_NAME);
        //        System.Xml.XmlNode sequenceNoNode;
        //        if (nodeList.Count > 0)
        //            sequenceNoNode = nodeList[0];
        //        else
        //        {
        //            sequenceNoNode = xmlDoc.CreateElement(MPF_PLAN_XML_SEQUENCE_NODE_NAME);
        //            xmlDoc.DocumentElement.AppendChild(sequenceNoNode);
        //        }

        //        sequenceNoNode.InnerText = NewSequenceNo.ToString();

        //        nodeList = xmlDoc.GetElementsByTagName(MPF_PLAN_XML_LAST_GENERATE_DATE);
        //        System.Xml.XmlNode lastDateNode;
        //        if (nodeList.Count > 0)
        //            lastDateNode = nodeList[0];
        //        else
        //        {
        //            lastDateNode = xmlDoc.CreateElement(MPF_PLAN_XML_LAST_GENERATE_DATE);
        //            xmlDoc.DocumentElement.AppendChild(lastDateNode);
        //        }

        //        lastDateNode.InnerText = AppUtils.ServerDateTime().ToString("yyyyMMdd");

        //        mpfPlan.MPFPlanExtendData = xmlDoc.InnerXml;
        //        EMPFPlan.db.update(dbConn, mpfPlan);
        //    }

        //}
        private void GenerateMPFDataByPeriod(GenericMPFFileDetail mpfFileDetail, ArrayList periodList)
        {
            foreach (GenericMPFFileContributionDetail contributionDetail in mpfFileDetail.MPFContributionDetailList)
            {
                MPFPeriod currentMPFPeriod = null;
                foreach (MPFPeriod mpfPeriod in periodList)
                {
                    if (mpfPeriod.PeriodFrom < contributionDetail.PeriodTo && mpfPeriod.PeriodTo > contributionDetail.PeriodFrom)
                    {
                        if (mpfPeriod.PeriodFrom > contributionDetail.PeriodFrom)
                        {
                            mpfPeriod.PeriodFrom = contributionDetail.PeriodFrom;
                        }
                        if (mpfPeriod.PeriodTo < contributionDetail.PeriodTo)
                        {
                            mpfPeriod.PeriodFrom = contributionDetail.PeriodFrom;
                        }
                        currentMPFPeriod = mpfPeriod;
                    }
                }
                if (currentMPFPeriod == null)
                {
                    currentMPFPeriod = CreateMPFPeriod(contributionDetail.PeriodFrom, contributionDetail.PeriodTo);
                    periodList.Add(currentMPFPeriod);
                }

                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                empInfo.EmpID = mpfFileDetail.EmpID;
                EEmpPersonalInfo.db.select(dbConn, empInfo);

                string[] mpfFileMCDetailStringList = new string[13];
                mpfFileMCDetailStringList[0]  = "D";
                mpfFileMCDetailStringList[1]  = string.Empty.PadLeft(10);
                mpfFileMCDetailStringList[2]  = mpfFileDetail.HKIDPassport.PadRight(15).Substring(0, 15);
                mpfFileMCDetailStringList[3]  = empInfo.EmpEngSurname.PadRight(20).Substring(0, 20);
                mpfFileMCDetailStringList[4]  = empInfo.EmpEngOtherName.PadRight(20).Substring(0, 20);
                mpfFileMCDetailStringList[5]  = contributionDetail.RelevantIncome.ToString("00000000000.00").Replace(".", "");
                mpfFileMCDetailStringList[6]  = contributionDetail.MCEE.ToString("00000000000.00").Replace(".", "");
                mpfFileMCDetailStringList[7]  = contributionDetail.MCER.ToString("00000000000.00").Replace(".", "");
                mpfFileMCDetailStringList[8]  = contributionDetail.VCEE.ToString("00000000000.00").Replace(".", "");
                mpfFileMCDetailStringList[9]  = contributionDetail.VCER.ToString("00000000000.00").Replace(".", "");
                mpfFileMCDetailStringList[10] = ((double)0).ToString("00000000000.00").Replace(".", ""); //  no surcharge support
                mpfFileMCDetailStringList[11] = " ";                                                     //  Not In Use Since file specification 1.7a
                mpfFileMCDetailStringList[12] = string.Empty.PadLeft(8);                                 //  Not In Use Since file specification 1.7a

                currentMPFPeriod.TotalContributionAmount += contributionDetail.MCER + contributionDetail.MCEE;
                currentMPFPeriod.TotalContributionAmount += contributionDetail.VCER + contributionDetail.VCEE;
                currentMPFPeriod.DetailStringList.Add(string.Join(FIELD_DELIMITER, mpfFileMCDetailStringList));
            }
        }
Exemplo n.º 3
0
        //private double GenerateMPFDataByPeriod(GenericExistingEmployeeMPFFileDetail mpfFileDetail, ArrayList periodList, string recordType)
        private double GenerateMPFDataByPeriod(GenericMPFFileDetail mpfFileDetail, ArrayList periodList, string recordType)
        {
            double m_totalFigures = 0; // for use in data segment footer

            //ECessationReason m_empTermReason = new ECessationReason();
            //m_empTermReason.CessationReasonID = mpfFileDetail.CessationReasonID;
            //m_empTermReason = ECessationReason.db.select(dbConn, m_empTermReason);
            //if (m_empTermReason)
            //    return 0;


            foreach (GenericMPFFileContributionDetail contributionDetail in mpfFileDetail.MPFContributionDetailList)
            {
                MPFPeriod currentMPFPeriod = null;
                foreach (MPFPeriod mpfPeriod in periodList)
                {
                    if (mpfPeriod.PeriodFrom < contributionDetail.PeriodTo && mpfPeriod.PeriodTo > contributionDetail.PeriodFrom)
                    {
                        if (mpfPeriod.PeriodFrom > contributionDetail.PeriodFrom)
                        {
                            mpfPeriod.PeriodFrom = contributionDetail.PeriodFrom;
                        }
                        if (mpfPeriod.PeriodTo < contributionDetail.PeriodTo)
                        {
                            mpfPeriod.PeriodFrom = contributionDetail.PeriodFrom;
                        }
                        currentMPFPeriod = mpfPeriod;
                    }
                }
                if (currentMPFPeriod == null)
                {
                    currentMPFPeriod = CreateMPFPeriod(contributionDetail.PeriodFrom, contributionDetail.PeriodTo);
                    periodList.Add(currentMPFPeriod);
                }

                m_totalFigures += (contributionDetail.VCEE +
                                   contributionDetail.VCER +
                                   contributionDetail.MCEE +
                                   contributionDetail.MCER +
                                   contributionDetail.RelevantIncome +
                                   contributionDetail.VCRelevantIncome);

                if (recordType == "CA")
                {
                    string[] mpfFileMCDetailStringList = new string[15];
                    mpfFileMCDetailStringList[0]  = recordType.PadRight(2).Substring(0, 2);
                    mpfFileMCDetailStringList[1]  = this.MPFPlanParticipationNo.PadRight(4).Substring(0, 4);
                    mpfFileMCDetailStringList[2]  = mpfFileDetail.HKIDPassport.PadRight(15).Substring(0, 15);
                    mpfFileMCDetailStringList[3]  = "FMPF"; // <-- hardcode for MT000288 Fidelity scheme // this.MPFSchemeCode.PadRight(4).Substring(0, 4);
                    mpfFileMCDetailStringList[4]  = contributionDetail.PeriodFrom.ToString("yyyyMMdd").PadRight(8).Substring(0, 8);
                    mpfFileMCDetailStringList[5]  = contributionDetail.PeriodTo.ToString("yyyyMMdd").PadRight(8).Substring(0, 8);
                    mpfFileMCDetailStringList[6]  = "M"; // MPF Mandatory contribution
                    mpfFileMCDetailStringList[7]  = "RG";
                    mpfFileMCDetailStringList[8]  = contributionDetail.MCER.ToString("0000000000000.00").Replace(".", "");
                    mpfFileMCDetailStringList[9]  = contributionDetail.MCEE.ToString("0000000000000.00").Replace(".", "");
                    mpfFileMCDetailStringList[10] = currentMPFPeriod.PeriodFrom.ToString("yyyyMMdd").PadRight(8).Substring(0, 8);
                    mpfFileMCDetailStringList[11] = "".PadRight(15);
                    mpfFileMCDetailStringList[12] = "".PadRight(2);
                    mpfFileMCDetailStringList[13] = "".PadRight(1);
                    mpfFileMCDetailStringList[14] = contributionDetail.RelevantIncome.ToString("0000000000000.00").Replace(".", "");

                    currentMPFPeriod.DetailStringList.Add(string.Join(FIELD_DELIMITER, mpfFileMCDetailStringList));
                }

                if (contributionDetail.VCEE != 0 || contributionDetail.VCER != 0)
                {
                    //string vcPlanNo = string.Empty;

                    //System.Xml.XmlNodeList vcPlanNoNodeNode = HROne.CommonLib.Utility.GetXmlDocumentByDataString(mpfFileDetail.EmpAVCPlanExtendXMLString).GetElementsByTagName("EmpAVCPlanBOCIVCPlanNo");
                    //if (vcPlanNoNodeNode.Count > 0)
                    //    vcPlanNo = vcPlanNoNodeNode[0].InnerText;
                    //if (string.IsNullOrEmpty(vcPlanNo))
                    //{
                    //    throw new Exception("Voluntary Plan No. is missing:" + mpfFileDetail.EmpNo + " - " + mpfFileDetail.EmpName);
                    //}

                    if (recordType == "CA")
                    {
                        string[] mpfFileVCDetailStringList = new string[15];
                        mpfFileVCDetailStringList[0]  = recordType.PadRight(2).Substring(0, 2);
                        mpfFileVCDetailStringList[1]  = this.MPFPlanParticipationNo.PadRight(4).Substring(0, 4);
                        mpfFileVCDetailStringList[2]  = mpfFileDetail.HKIDPassport.PadRight(15).Substring(0, 15);
                        mpfFileVCDetailStringList[3]  = this.MPFSchemeCode.PadRight(4).Substring(0, 4);
                        mpfFileVCDetailStringList[4]  = contributionDetail.PeriodFrom.ToString("yyyyMMdd").PadRight(8).Substring(0, 8);
                        mpfFileVCDetailStringList[5]  = contributionDetail.PeriodTo.ToString("yyyyMMdd").PadRight(8).Substring(0, 8);
                        mpfFileVCDetailStringList[6]  = "V"; // Voluntary Mandatory contribution
                        mpfFileVCDetailStringList[7]  = "RG";
                        mpfFileVCDetailStringList[8]  = contributionDetail.VCER.ToString("0000000000000.00").Replace(".", "");
                        mpfFileVCDetailStringList[9]  = contributionDetail.VCEE.ToString("0000000000000.00").Replace(".", "");
                        mpfFileVCDetailStringList[10] = currentMPFPeriod.PeriodFrom.ToString("yyyyMMdd");
                        mpfFileVCDetailStringList[11] = "".PadRight(15);
                        mpfFileVCDetailStringList[12] = "".PadRight(2);
                        mpfFileVCDetailStringList[13] = "".PadRight(1);
                        mpfFileVCDetailStringList[14] = contributionDetail.RelevantIncome.ToString("0000000000000.00").Replace(".", "");

                        currentMPFPeriod.DetailStringList.Add(string.Join(FIELD_DELIMITER, mpfFileVCDetailStringList));
                    }
                }
            }
            return(m_totalFigures);
        }
Exemplo n.º 4
0
        protected string GenerateMPFDetailLine(GenericMPFFileDetail mpfFileDetail, out string TerminationDetailLine)
        {
            AIAMPFFile mpfFile = (AIAMPFFile)mpfFileDetail.MPFFile;

            string mpfFileDetailLine = string.Empty;

            TerminationDetailLine = string.Empty;

            string BenefitPlanNo = "01";

            System.Xml.XmlNodeList BenefitPlanNoNode = HROne.CommonLib.Utility.GetXmlDocumentByDataString(mpfFileDetail.EmpMPFPlanExtendXMLString).GetElementsByTagName(EMP_MPF_XML_BENEFIT_PLAN_NO);
            if (BenefitPlanNoNode.Count > 0)
            {
                string tmpBenefitPlanNo = BenefitPlanNoNode[0].InnerText.Trim();
                if (!string.IsNullOrEmpty(tmpBenefitPlanNo))
                {
                    BenefitPlanNo = tmpBenefitPlanNo;
                }
            }

            foreach (GenericMPFFileContributionDetail contributionDetail in mpfFileDetail.MPFContributionDetailList)
            {
                string[] mpfFileContributionDetailArray = new string[22];
                mpfFileContributionDetailArray[0] = MPFPlanPlanNo.PadRight(6).Substring(0, 6);
                mpfFileContributionDetailArray[1] = mpfFileDetail.HKIDPassport.PadRight(15).Substring(0, 15);
                mpfFileContributionDetailArray[2] = BenefitPlanNo.PadRight(6).Substring(0, 6); //default is 01 if not exists
                mpfFileContributionDetailArray[3] = string.Empty.PadRight(17);
                mpfFileContributionDetailArray[4] = "F";                                       //  support Regular service ONLY
                mpfFileContributionDetailArray[5] = "N";                                       //  does NOT support Adjustment batch
                mpfFileContributionDetailArray[6] = " ";                                       //  no adjustment batch so no -ve sign
                mpfFileContributionDetailArray[7] = contributionDetail.MCER.ToString("0000000.00").Replace(".", string.Empty);
                mpfFileContributionDetailArray[8] = " ";                                       //  no adjustment batch so no -ve sign
                mpfFileContributionDetailArray[9] = contributionDetail.MCEE.ToString("0000000.00").Replace(".", string.Empty);
                if (contributionDetail.VCER == 0)
                {
                    mpfFileContributionDetailArray[10] = "NONE "; //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[12] = " ";     //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[13] = ((double)0).ToString("0000000.00").Replace(".", string.Empty);
                }
                else
                {
                    mpfFileContributionDetailArray[10] = "SFA  "; //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[12] = " ";     //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[13] = contributionDetail.VCER.ToString("0000000.00").Replace(".", string.Empty);
                }
                if (contributionDetail.VCEE == 0)
                {
                    mpfFileContributionDetailArray[11] = "NONE "; //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[14] = " ";     //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[15] = ((double)0).ToString("0000000.00").Replace(".", string.Empty);
                }
                else
                {
                    mpfFileContributionDetailArray[11] = "SFA  "; //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[14] = " ";     //  no adjustment batch so no -ve sign
                    mpfFileContributionDetailArray[15] = contributionDetail.VCEE.ToString("0000000.00").Replace(".", string.Empty);
                }
                mpfFileContributionDetailArray[16] = "00000";   // use rate=0
                mpfFileContributionDetailArray[17] = "00000";   // use rate=0

                mpfFileContributionDetailArray[18] = contributionDetail.PeriodFrom.ToString("yyyyMMdd");
                mpfFileContributionDetailArray[19] = contributionDetail.PeriodTo.ToString("yyyyMMdd");

                if (contributionDetail.VCEE == 0 && contributionDetail.VCER == 0)
                {
                    mpfFileContributionDetailArray[20] = ((double)0).ToString("00000000000.00".Replace(".", string.Empty));
                }
                else
                {
                    mpfFileContributionDetailArray[20] = contributionDetail.VCRelevantIncome.ToString("00000000000.00").Replace(".", string.Empty);
                    AIATotalVCRelevantIncome          += contributionDetail.VCRelevantIncome;
                }
                mpfFileContributionDetailArray[21] = contributionDetail.RelevantIncome.ToString("00000000000.00").Replace(".", string.Empty);

                string tmpDetailLine = string.Join(FIELD_DELIMITER, mpfFileContributionDetailArray);

                if (tmpDetailLine.Length != 148)
                {
                    throw new Exception("Invalid length of detail record");
                }

                if (string.IsNullOrEmpty(mpfFileDetailLine))
                {
                    mpfFileDetailLine = tmpDetailLine;
                }
                else
                {
                    mpfFileDetailLine += RECORD_DELIMITER + tmpDetailLine;
                }
            }
            if (mpfFileDetail is GenericExistingEmployeeMPFFileDetail)
            {
                GenericExistingEmployeeMPFFileDetail existingDetail = (GenericExistingEmployeeMPFFileDetail)mpfFileDetail;
                if (!string.IsNullOrEmpty(existingDetail.TermCode))
                {
                    string[] mpfFileTerminationDetailArray = new string[11];
                    mpfFileTerminationDetailArray[0]  = MPFPlanPlanNo.PadRight(6).Substring(0, 6);
                    mpfFileTerminationDetailArray[1]  = BenefitPlanNo.PadRight(6).Substring(0, 6);  //default is 01 if not exists
                    mpfFileTerminationDetailArray[2]  = mpfFileDetail.HKIDPassport.PadRight(15).Substring(0, 15);
                    mpfFileTerminationDetailArray[3]  = string.Empty.PadRight(17);
                    mpfFileTerminationDetailArray[4]  = mpfFileDetail.EmpName.PadRight(60).Substring(0, 60);
                    mpfFileTerminationDetailArray[6]  = existingDetail.LastEmploymentDate.ToString("yyyyMMdd");
                    mpfFileTerminationDetailArray[7]  = existingDetail.LastEmploymentDate.ToString("yyyyMMdd");
                    mpfFileTerminationDetailArray[8]  = existingDetail.TermCode.Substring(0, 1);
                    mpfFileTerminationDetailArray[9]  = existingDetail.LSPSPAmount.ToString("00000000000.00").Replace(".", string.Empty);
                    mpfFileTerminationDetailArray[10] = existingDetail.LSPSPAmountPaidByER > 0 ? "Y" : "N";

                    string tmpDetailLine = string.Join(FIELD_DELIMITER, mpfFileTerminationDetailArray);

                    if (tmpDetailLine.Length != 135)
                    {
                        throw new Exception("Invalid length of detail record");
                    }

                    TerminationDetailLine = tmpDetailLine;
                }
            }

            return(mpfFileDetailLine);
        }