예제 #1
0
        public IList<F98001Model> getAllData()
        {
            Mapper.CreateMap<F98001, F98001Model>();
            objF98001 = new F98001Repository();

            IList<F98001> objEntity = objF98001.GetAll().ToList();
            IList<F98001Model> objResult = new List<F98001Model>();

            objResult = Mapper.Map(objEntity, objResult);

            return objResult;
        }
예제 #2
0
        public IList<F98001Model> getAllData(string SystemID, string UDCType)
        {
            Mapper.CreateMap<F98001, F98001Model>();
            objF98001 = new F98001Repository();

            IList<F98001> objEntity = objF98001.GetAll(u=>u.SystemID.Equals(SystemID) && u.UDCType.Equals(UDCType)).ToList();
            IList<F98001Model> objResult = new List<F98001Model>();

            objResult = Mapper.Map(objEntity, objResult);

            return objResult;
        }
        public IList<ARTrackingListModel> getARTrackingList(int Month, int Year, string filterCustomerID = "")
        {
            #region "Declaration"

            objF01030 = new F01030Repository();
            objF98001 = new F98001Repository();

            objF98090 = new F98090Repository();
            objGLAcc = new GLAccRepository();

            objAR = new ARManager();
            IList<ARTrackingListModel> objResult = new List<ARTrackingListModel>();

            DateTime FilterGLDate = new DateTime(Year, Month, DateTime.DaysInMonth(Year, Month));
            //DateTime FilterGLDate = new DateTime(Year, Month, DateTime.DaysInMonth(Year, Month)).AddDays(1);

            #endregion

            #region "Get AR Aging Detail Result"

            IEnumerable<ARAgingDetailModel> objARDetail = objAR.getARAgingDetail(FilterGLDate, filterCustomerID)
                .Where(x => x.OutBalance != 0 && x.OutBalanceLocal != 0);

            #endregion

            #region "Minus CR Values"

            var ARCrTranType = (from argl in objF98090.GetAll()
                                join glacc in objGLAcc.GetAll()
                                on argl.COA equals glacc.GLAID
                                where argl.ProgramModule.Equals("AR") && argl.COAType.Equals("ARMNU") && argl.DRCR.Equals("CR")
                                select new
                                {
                                    argl.TransType
                                }).Distinct();

            List<ARAgingDetailModel> updatedARAging = new List<ARAgingDetailModel>();

            foreach (ARAgingDetailModel data in objARDetail)
            {
                if (ARCrTranType.Any(t2 => t2.TransType == data.TransType))
                {
                    ARAgingDetailModel agm = new ARAgingDetailModel();

                    agm = data;
                    agm.AmountC *= -1;
                    agm.AmountLocal *= -1;
                    agm.OutBalance *= -1;
                    agm.OutBalanceLocal *= -1;

                    updatedARAging.Add(agm);
                }
                else
                {
                    updatedARAging.Add(data);
                }

            }

            #endregion

            #region "Get Distinct Customer List from ARAgingDetail info"

            var objARCustList = (from ardetail in updatedARAging select new { CustomerID = ardetail.CustomerID }).Distinct();

            #endregion

            #region "Get Customer Info"

            IQueryable<F01030> CustMain = objF01030.GetQuery();
            if (filterCustomerID != "")
                CustMain = CustMain.Where(c => c.CustomerID.Equals(filterCustomerID));

            #endregion

            #region "Get UDC Info"

            //var entUDCSM = objF98001.GetAll(u => u.SystemID.Equals("03") && u.UDCType.Equals("C04"));
            //var entUDCPTerm = objF98001.GetAll(u => u.SystemID.Equals("03") && u.UDCType.Equals("PBC"));

            #endregion

            #region "Get FinalResult Info by Joining All Infos"

            var objResultJoin = from c in CustMain.AsEnumerable()
                                join ARDetail in objARCustList.AsEnumerable() on c.CustomerID equals ARDetail.CustomerID
                                select new
                                {
                                    c.CustomerID,
                                    c.CustomerName,
                                    c.CCatCode04,
                                    c.PInst,
                                    c.CreditLimit,
                                    c.PaymentABC,
                                    c.PTerm,
                                    c.CreditMessage,
                                    c.HoldCode,
                                    c.CurrCode
                                };
            #endregion

            #region "Assign to result object from result"

            foreach (var data in objResultJoin)
            {
                ARTrackingListModel objSingle = new ARTrackingListModel();

                objSingle.Link = data.CustomerID;
                objSingle.CustomerID = data.CustomerID;
                objSingle.CustomerName = data.CustomerName;
                objSingle.CCatCode04 = data.CCatCode04;

                var pabc=objF98001.GetAll(u => u.SystemID.Equals("03") && u.UDCType.Equals("PBC") && u.Code.Equals(data.PaymentABC)).FirstOrDefault();
                if (pabc!=null)
                    objSingle.PaymentABC = pabc.Desc1;
                else
                    objSingle.PaymentABC = "";

                var sm=objF98001.GetAll(u => u.SystemID.Equals("03") && u.UDCType.Equals("C04") && u.Code.Equals(data.CCatCode04)).FirstOrDefault();
                if (sm!=null)
                    objSingle.SMName = sm.Desc1;
                else
                    objSingle.SMName = "";

                objSingle.PInst = data.PInst;
                objSingle.CreditLimit = data.CreditLimit;
                objSingle.PTerm = data.PTerm;
                objSingle.HoldCode = data.HoldCode;
                objSingle.CurrCode = data.CurrCode;
                objSingle.CreditRating = data.CreditMessage;

                var tmpAR = updatedARAging.Where(x => x.CustomerID.Equals(data.CustomerID)).OrderBy(x => x.InvoiceDate).Distinct();

                foreach (var ar in tmpAR)
                {
                    if (ar.ARAgingDay > 90)
                    {
                        objSingle.TotOutstanding += Math.Round(ar.OutBalanceLocal, 2);
                        if (ar.ARAgingDay > 120)
                        {
                            objSingle.Over120 += Math.Round(ar.OutBalanceLocal, 2);
                        }
                        else
                        {
                            objSingle.Over90 += Math.Round(ar.OutBalanceLocal, 2);
                        }
                    }
                    else
                    {
                        objSingle.TotOutstanding += Math.Round(ar.OutBalanceLocal, 2);
                    }
                }

                if (objSingle.Over90 < 0)
                    objSingle.Over90 = 0;
                if (objSingle.Over120 < 0)
                    objSingle.Over120 = 0;

                objSingle.EarliestInvDate = updatedARAging.Where(x => x.CustomerID.Equals(data.CustomerID)).Min(x => x.InvoiceDate);
                objSingle.LastReceiptDate = updatedARAging.Where(x => x.CustomerID.Equals(data.CustomerID)).FirstOrDefault().LastReceiptDate;
                objSingle.LastReceiptAmt = updatedARAging.Where(x => x.CustomerID.Equals(data.CustomerID)).FirstOrDefault().LastReceiptAmt;

                objResult.Add(objSingle);

            }

            #endregion

            return objResult;
        }