示例#1
0
 public override bool Equals(object obj)
 {
     if (obj is EmpBankTransactionBreakDownKey)
     {
         EmpBankTransactionBreakDownKey compare = (EmpBankTransactionBreakDownKey)obj;
         if (compare.m_EmpAccID.Equals(m_EmpAccID) && compare.m_ValueDate.Date.Ticks.Equals(m_ValueDate.Date.Ticks))
         {
             return(true);
         }
     }
     return(false);
 }
示例#2
0
        public virtual void LoadBankFileDetail(ArrayList PayrollBatchList, ArrayList EmpList)
        {
            BankFileDetails.Clear();
            m_TotalAmount = 0;

            //  Move autoPayList out of the EmpList loop for sharing bank account feature between roles
            Dictionary <EmpBankTransactionBreakDownKey, GenericBankFileDetail> autoPayList = new Dictionary <EmpBankTransactionBreakDownKey, GenericBankFileDetail>();
            List <int> PayPeriodIDList = new List <int>();

            foreach (EEmpPersonalInfo empInfo in EmpList)
            {
                Dictionary <EmpBankTransactionBreakDownKey, GenericBankFileDetail> chequePaymentList = new Dictionary <EmpBankTransactionBreakDownKey, GenericBankFileDetail>();

                DBFilter empPayrollFilter = new DBFilter();
                empPayrollFilter.add(new Match("EmpID", empInfo.EmpID));
                OR orPayrollBatch = new OR();
                foreach (EPayrollBatch payBatch in PayrollBatchList)
                {
                    orPayrollBatch.add(new Match("PayBatchID", payBatch.PayBatchID));
                }
                empPayrollFilter.add(orPayrollBatch);

                ArrayList empPayrollList = EEmpPayroll.db.select(dbConn, empPayrollFilter);

                foreach (EEmpPayroll empPayroll in empPayrollList)
                {
                    if (!PayPeriodIDList.Contains(empPayroll.PayPeriodID))
                    {
                        PayPeriodIDList.Add(empPayroll.PayPeriodID);
                    }

                    if (!m_ValueDate.Ticks.Equals(0))
                    {
                        empPayroll.EmpPayValueDate = m_ValueDate;
                    }
                    if (empPayroll.EmpPayValueDate.Ticks.Equals(0))
                    {
                        EPayrollBatch payBatch = new EPayrollBatch();
                        payBatch.PayBatchID = empPayroll.PayBatchID;
                        if (EPayrollBatch.db.select(dbConn, payBatch))
                        {
                            empPayroll.EmpPayValueDate = payBatch.PayBatchValueDate;
                        }
                    }

                    DBFilter paymentRecordFilter = new DBFilter();
                    paymentRecordFilter.add(new Match("EmpPayrollID", empPayroll.EmpPayrollID));
                    OR orPaymentMethodTerm = new OR();
                    orPaymentMethodTerm.add(new Match("PayRecMethod", "A"));
                    if (m_IsGenerateChequePayment)
                    {
                        orPaymentMethodTerm.add(new Match("PayRecMethod", "Q"));
                    }
                    paymentRecordFilter.add(orPaymentMethodTerm);

                    ArrayList paymentRecordList = EPaymentRecord.db.select(dbConn, paymentRecordFilter);
                    foreach (EPaymentRecord paymentRecord in paymentRecordList)
                    {
                        if (paymentRecord.PayRecMethod.Equals("A"))
                        {
                            EEmpBankAccount empAcc = new EEmpBankAccount();
                            empAcc.EmpBankAccountID = paymentRecord.EmpAccID;
                            if (!EEmpBankAccount.db.select(dbConn, empAcc))
                            {
                                empAcc = EEmpBankAccount.GetDefaultBankAccount(dbConn, empInfo.EmpID);
                                if (empAcc == null)
                                {
                                    EEmpPersonalInfo.db.select(dbConn, empInfo);
                                    throw new InvalidEEBankAccountException(empInfo.EmpNo, empInfo.EmpEngFullName);
                                }
                            }
                            EmpBankTransactionBreakDownKey key = new EmpBankTransactionBreakDownKey(empAcc.EmpBankAccountID, empPayroll.EmpPayValueDate);

                            GenericBankFileDetail BankFileDetail;
                            if (autoPayList.ContainsKey(key))
                            {
                                BankFileDetail = autoPayList[key];
                            }
                            else
                            {
                                BankFileDetail = CreateBankFileDetail(empAcc.EmpID);
                                BankFileDetail.EmpBankAccountHolderName = empAcc.EmpBankAccountHolderName.Trim();
                                BankFileDetail.BankCode   = empAcc.EmpBankCode;
                                BankFileDetail.BranchCode = empAcc.EmpBranchCode;
                                BankFileDetail.AccountNo  = empAcc.EmpAccountNo;
                                BankFileDetail.ValueDate  = empPayroll.EmpPayValueDate;
                                autoPayList.Add(key, BankFileDetail);
                            }
                            BankFileDetail.Amount += paymentRecord.PayRecActAmount;
                            BankFileDetail.Amount  = Math.Round(BankFileDetail.Amount, 2, MidpointRounding.AwayFromZero);
                            m_TotalAmount         += paymentRecord.PayRecActAmount;
                        }
                        else if (paymentRecord.PayRecMethod.Equals("Q") && m_IsGenerateChequePayment)
                        {
                            EmpBankTransactionBreakDownKey key = new EmpBankTransactionBreakDownKey(0, empPayroll.EmpPayValueDate);
                            GenericBankFileDetail          BankFileDetail;
                            if (chequePaymentList.ContainsKey(key))
                            {
                                BankFileDetail = chequePaymentList[key];
                            }
                            else
                            {
                                BankFileDetail                 = CreateBankFileDetail(empInfo.EmpID);
                                BankFileDetail.ValueDate       = empPayroll.EmpPayValueDate;
                                BankFileDetail.IsChequePayment = true;
                                chequePaymentList.Add(key, BankFileDetail);
                            }
                            BankFileDetail.Amount += paymentRecord.PayRecActAmount;
                            BankFileDetail.Amount  = Math.Round(BankFileDetail.Amount, 2, MidpointRounding.AwayFromZero);
                            m_TotalAmount         += paymentRecord.PayRecActAmount;
                        }
                    }
                }

                BankFileDetails.AddRange(chequePaymentList.Values);
                chequePaymentList.Clear();
            }
            BankFileDetails.AddRange(autoPayList.Values);
            autoPayList.Clear();

            List <GenericBankFileDetail> NegativeBankFileDetailList = new List <GenericBankFileDetail>();
            List <GenericBankFileDetail> zeroAmountBankFileDetails  = new List <GenericBankFileDetail>();

            foreach (GenericBankFileDetail bankFileDetail in BankFileDetails)
            {
                if (bankFileDetail != null)
                {
                    if (bankFileDetail.Amount < 0)
                    {
                        NegativeBankFileDetailList.Add(bankFileDetail);
                    }
                    else if (Math.Abs(bankFileDetail.Amount) <= 0.005)
                    {
                        zeroAmountBankFileDetails.Add(bankFileDetail);
                    }
                }
            }
            foreach (GenericBankFileDetail bankFileDetail in zeroAmountBankFileDetails)
            {
                BankFileDetails.Remove(bankFileDetail);
                ZeroBankFileDetails.Add(bankFileDetail);
            }
            foreach (int PayPeriodID in PayPeriodIDList)
            {
                EPayrollPeriod payPeriod = new EPayrollPeriod();
                payPeriod.PayPeriodID = PayPeriodID;
                if (EPayrollPeriod.db.select(dbConn, payPeriod))
                {
                    if (m_PayPeriodFr.Ticks.Equals(0) || m_PayPeriodFr > payPeriod.PayPeriodFr)
                    {
                        m_PayPeriodFr = payPeriod.PayPeriodFr;
                    }
                    if (m_PayPeriodTo.Ticks.Equals(0) || m_PayPeriodTo < payPeriod.PayPeriodTo)
                    {
                        m_PayPeriodTo = payPeriod.PayPeriodTo;
                    }
                }
            }
            if (NegativeBankFileDetailList.Count > 0)
            {
                throw new NegativeAmountException(new ArrayList(NegativeBankFileDetailList));
            }
        }