Exemplo n.º 1
0
        //List<PaymentDetailsReport> reportList = new List<PaymentDetailsReport>();

        private void ShowPaymentDetails(Payment p)
        {
            var holdersRepos  = _unitOfWork.FamilyMembers;
            var periodsRepos  = _unitOfWork.PeriodSettings;
            var sequenceRepos = _unitOfWork.PaymentSequences;
            var paymentsRepos = _unitOfWork.Payments;
            var detailsRepos  = _unitOfWork.PaymentTransactions;
            var historyRepos  = _unitOfWork.LoanPayments;
            var loansRepos    = _unitOfWork.Loans;

            IList <FamilyMember>       holders   = holdersRepos.GetAll();
            IList <PeriodSetting>      perods    = periodsRepos.GetAll();
            IList <PaymentSequence>    sequences = sequenceRepos.GetAll();
            IList <Payment>            payments  = paymentsRepos.GetAll();
            IList <PaymentTransaction> details   = detailsRepos.GetAll();
            //
            var results =
                from payment in payments
                join detail in details
                on payment.PaymentNo equals detail.PaymentNo
                join holder in holders
                on detail.MemberCode equals holder.Code
                join period in perods
                on payment.PayYear equals period.Id
                join sequ in sequences
                on payment.PaySequence equals sequ.Id
                where p.PaymentNo == payment.PaymentNo
                //new Added
                select new
            {
                detail.TransNo,
                ShareHolderCode = holder.Code,
                holder.FullName,
                PeriodSettingsId = period.Id,
                Year             = period.YearPart,
                SequenId         = sequ.Id,
                SequenDesc       = sequ.SequenceDescription,
                SharesNo         = detail.ShareNumbers,
                PaymentAmount    = payment.Amount,
                TotalPayments    = (payment.Amount * detail.ShareNumbers),
                LoansTatal       = detail.AmountDue,
                detail.NetPayments,
                MemberSex = holder.Sex
            };

            foreach (var result in results)
            {
                //var loans = loansRepos.Query(
                //     lo => lo.ShareHolder.Code == result.ShareHolderCode
                //         &&
                //         lo.PaymentSequence.Id == result.SequenId
                //         &&
                //         lo.PeriodSetting.Id == result.PeriodSettingsId
                //    ).ToList();

                var resultCopy = result; //Copy foreach variable to avoid accessing it in clousre
                List <LoanPayment> loansPaymentHistory = historyRepos.Query(
                    hist => hist.FamilyMember.Code == resultCopy.ShareHolderCode
                    &&
                    hist.PaymentTransaction.Payment.PaymentSequence.Id == resultCopy.SequenId
                    &&
                    hist.PaymentTransaction.Payment.PeriodSetting.Id == resultCopy.PeriodSettingsId).ToList();

                if (loansPaymentHistory.Count != 0)
                {
                    bool isFirstLine = true;
                    foreach (LoanPayment history in loansPaymentHistory)
                    {
                        if (isFirstLine)
                        {
                            //For Show
                            var pdrHeader = new PaymentDetailsReport
                                            (
                                result.TransNo, result.ShareHolderCode, result.FullName, result.Year,
                                result.SequenDesc, result.PaymentAmount, result.SharesNo,
                                result.TotalPayments, history.AmountPaid, history.Loan.LoanType.LoanDescription,
                                history.Loan.Remarks, result.LoansTatal, result.NetPayments, result.MemberSex
                                            );
                            PaymentDetails.Add(pdrHeader);
                            var spdHeader = new SearchablePaymentDetails
                                            (
                                result.TransNo, result.ShareHolderCode, result.FullName, result.Year,
                                result.SequenDesc, result.PaymentAmount, result.SharesNo,
                                result.TotalPayments, history.AmountPaid, history.Loan.LoanType.LoanDescription,
                                history.Loan.Remarks, result.LoansTatal, result.NetPayments, result.MemberSex, true
                                            );
                            _seacrhablePaymentDetails.Add(spdHeader);
                            isFirstLine = false;
                            continue;
                        }
                        var pdrDetail = new PaymentDetailsReport
                                        (
                            result.TransNo, history.AmountPaid,
                            history.Loan.LoanType.LoanDescription, history.Loan.Remarks, result.MemberSex
                                        );
                        PaymentDetails.Add(pdrDetail);

                        var spdDetail = new SearchablePaymentDetails
                                        (
                            result.TransNo, result.ShareHolderCode, result.FullName, result.Year,
                            result.SequenDesc, result.PaymentAmount, result.SharesNo,
                            result.TotalPayments, history.AmountPaid, history.Loan.LoanType.LoanDescription,
                            history.Loan.Remarks, result.LoansTatal, result.NetPayments, result.MemberSex, false
                                        );
                        _seacrhablePaymentDetails.Add(spdDetail);
                    }
                }
                else
                {
                    var pdr = new PaymentDetailsReport(
                        result.TransNo,
                        result.ShareHolderCode, result.FullName, result.Year,
                        result.SequenDesc, result.PaymentAmount, result.SharesNo,
                        result.TotalPayments, 0.00M, null,
                        null, result.LoansTatal, result.NetPayments, result.MemberSex
                        );
                    PaymentDetails.Add(pdr);
                    var spd = new SearchablePaymentDetails
                              (
                        result.TransNo,
                        result.ShareHolderCode, result.FullName, result.Year,
                        result.SequenDesc, result.PaymentAmount, result.SharesNo,
                        result.TotalPayments, 0.00M, null,
                        null, result.LoansTatal, result.NetPayments, result.MemberSex, true
                              );
                    _seacrhablePaymentDetails.Add(spd);
                }
            }
        }
Exemplo n.º 2
0
        private void ShowData(PaymentTransaction detail, bool isFirstLine, Tuple <double, double, string> progMetadata)
        {
            double p          = (progMetadata.Item1 / progMetadata.Item2) * 100;
            string currMember = progMetadata.Item3;

            //Action action = () =>
            //    {
            if (_uiLoansHistory.Count > 0)
            {
                foreach (LoanPayment history in _uiLoansHistory)
                {
                    if (isFirstLine)
                    {
                        //This for show.
                        var pdrHeader = new PaymentDetailsReport(
                            detail.TransNo, detail.FamilyMember.Code, detail.FamilyMember.FullName,
                            detail.Payment.PeriodSetting.YearPart, detail.Payment.PaymentSequence.SequenceDescription,
                            detail.Payment.Amount, detail.FamilyMember.Shares,
                            (detail.Payment.Amount * detail.FamilyMember.Shares),
                            history.AmountPaid, history.Loan.LoanType.LoanDescription,
                            history.Loan.Remarks, detail.AmountDue, detail.NetPayments, detail.FamilyMember.Sex);

                        PaymentDetails.Add(pdrHeader);
                        //This for search.
                        var spdHeader = new SearchablePaymentDetails
                                        (
                            detail.TransNo, detail.FamilyMember.Code, detail.FamilyMember.FullName,
                            detail.Payment.PeriodSetting.YearPart, detail.Payment.PaymentSequence.SequenceDescription,
                            detail.Payment.Amount, detail.FamilyMember.Shares,
                            (detail.Payment.Amount * detail.FamilyMember.Shares),
                            history.AmountPaid, history.Loan.LoanType.LoanDescription,
                            history.Loan.Remarks, detail.AmountDue, detail.NetPayments, detail.FamilyMember.Sex, true
                                        );
                        _seacrhablePaymentDetails.Add(spdHeader);
                        isFirstLine = false;
                        continue;
                    }
                    //This for show.
                    var pdrDetail = new PaymentDetailsReport
                                    (
                        detail.TransNo, history.AmountPaid,
                        history.Loan.LoanType.LoanDescription, history.Loan.Remarks, detail.FamilyMember.Sex
                                    );
                    PaymentDetails.Add(pdrDetail);
                    //This for search.
                    var spdDetail = new SearchablePaymentDetails
                                    (
                        detail.TransNo, detail.FamilyMember.Code, detail.FamilyMember.FullName,
                        detail.Payment.PeriodSetting.YearPart, detail.Payment.PaymentSequence.SequenceDescription,
                        detail.Payment.Amount, detail.FamilyMember.Shares,
                        (detail.Payment.Amount * detail.FamilyMember.Shares),
                        history.AmountPaid, history.Loan.LoanType.LoanDescription,
                        history.Loan.Remarks, detail.AmountDue, detail.NetPayments, detail.FamilyMember.Sex, false
                                    );
                    _seacrhablePaymentDetails.Add(spdDetail);
                }
                _uiLoansHistory.Clear();
            }
            else
            {
                var pdr = new PaymentDetailsReport
                          (
                    detail.TransNo, detail.FamilyMember.Code, detail.FamilyMember.FullName,
                    detail.Payment.PeriodSetting.YearPart, detail.Payment.PaymentSequence.SequenceDescription,
                    detail.Payment.Amount, detail.FamilyMember.Shares,
                    (detail.Payment.Amount * detail.FamilyMember.Shares), 0.00M, null,
                    null, detail.AmountDue, detail.NetPayments, detail.FamilyMember.Sex
                          );
                PaymentDetails.Add(pdr);
                var spd = new SearchablePaymentDetails
                          (
                    detail.TransNo, detail.FamilyMember.Code, detail.FamilyMember.FullName,
                    detail.Payment.PeriodSetting.YearPart, detail.Payment.PaymentSequence.SequenceDescription,
                    detail.Payment.Amount, detail.FamilyMember.Shares,
                    (detail.Payment.Amount * detail.FamilyMember.Shares), 0.00M, null,
                    null, detail.AmountDue, detail.NetPayments, detail.FamilyMember.Sex, true
                          );
                _seacrhablePaymentDetails.Add(spd);
            }
            ProgressCounter = p;
            ProgCurrent     = currMember;

            //};
            //Dispatcher.Invoke(action, null);
        }