Esempio n. 1
0
        public FileDto GetUniversalPSASToExport(GetPSASParamsDto input)
        {
            //var psasMain = GetPSASMain(input);
            var psasMain      = GetPsasMainToExport(input);
            var psasPrice     = _ipriceAppService.GetUniversalPrice(input);
            var psasPayment   = GetPaymentByBookCode(input);
            var paramSchedule = new GetPSASScheduleParamDto()
            {
                bookCode = input.bookCode,
                coCode   = "All",
                unitCode = input.unitCode,
                unitNo   = input.unitNo
            };
            var psasSchedule = GetSchedule(paramSchedule);

            var dataToExport = new GetUniversalPsasDto()
            {
                psasMain     = psasMain,
                psasPayment  = psasPayment,
                psasPrice    = psasPrice,
                psasSchedule = psasSchedule
            };

            return(_printBookingProfileExcelExporter.GenerateExcelBookingProfile(dataToExport));
        }
Esempio n. 2
0
        private List <GetPSASMainScheduleDto> GetSchedule(GetPSASScheduleParamDto input)
        {
            var getInput = new GetPSASParamsDto()
            {
                bookCode = input.bookCode,
                unitCode = input.unitCode,
                unitNo   = input.unitNo
            };
            var getParamsPSAS = _ipriceAppService.GetParameter(getInput);

            var checkScheduleData = (from x in _contextProp.TR_BookingDetailSchedule
                                     join a in _contextProp.TR_BookingDetail on x.bookingDetailID equals a.Id
                                     join b in _contextProp.TR_BookingHeader on a.bookingHeaderID equals b.Id
                                     join c in _contextProp.LK_Alloc on x.allocID equals c.Id
                                     join d in _contextProp.TR_PenaltySchedule on new { A = b.Id, B = (int)x.schedNo, C = c.allocCode } equals new { A = d.bookingHeaderID, B = d.ScheduleTerm, C = d.ScheduleAllocCode } into pen
                                     from d in pen.DefaultIfEmpty()
                                     where b.Id == getParamsPSAS.bookingHeaderID
                                     select new
            {
                x.schedNo,
                x.dueDate,
                x.allocID,
                x.netAmt,
                x.vatAmt,
                x.remarks,
                a.pctTax,
                a.coCode,
                x.netOut,
                x.vatOut,
                penaltyAge = d == null ? 0 : d.penaltyAging,
                penaltyAmount = d == null ? 0 : d.penaltyAmount
            });

            List <GetPSASMainScheduleDto> dataSchedule = new List <GetPSASMainScheduleDto>();

            if (checkScheduleData.Any())
            {
                var dataSchedules = (from x in checkScheduleData
                                     where (input.coCode == "All") || (input.coCode != "All" && x.coCode == input.coCode)
                                     group x by new
                {
                    x.schedNo,
                    x.dueDate,
                    x.allocID,
                    x.remarks,
                    x.penaltyAge,
                    x.penaltyAmount
                } into G
                                     select new GetPSASMainScheduleDto
                {
                    allocID = G.Key.allocID,
                    allocCode = (from da in _contextProp.LK_Alloc where da.Id == G.Key.allocID select da.allocCode).FirstOrDefault(),
                    netAmount = G.Sum(d => d.netAmt),
                    VATAmount = G.Sum(d => d.vatAmt),
                    totalAmount = G.Sum(d => d.netAmt) + G.Sum(d => d.vatAmt),
                    netOutstanding = G.Sum(d => d.netOut),
                    VATOutstanding = G.Sum(d => d.vatOut),
                    totalOutstanding = G.Sum(d => d.netOut) + G.Sum(d => d.vatOut),
                    dueDate = G.Key.dueDate,
                    schedNo = G.Key.schedNo,
                    remarks = G.Key.remarks,
                    paymentAmount = (G.Sum(d => d.netAmt) + G.Sum(d => d.vatAmt)) - (G.Sum(d => d.netOut) + G.Sum(d => d.vatOut)),
                    penaltyAge = G.Key.penaltyAge,
                    penaltyAmount = G.Key.penaltyAmount
                }).ToList();

                foreach (var dataSched in dataSchedules)
                {
                    var dataPayment = (from pda in _contextProp.TR_PaymentDetailAlloc
                                       join pd in _contextProp.TR_PaymentDetail on pda.paymentDetailID equals pd.Id
                                       join ph in _contextProp.TR_PaymentHeader on pd.paymentHeaderID equals ph.Id
                                       join pt in _contextProp.LK_PayType on pd.payTypeID equals pt.Id
                                       where ph.bookingHeaderID == getParamsPSAS.bookingHeaderID && pda.schedNo == dataSched.schedNo
                                       select new DataPaymentListDto
                    {
                        clearDate = ph.clearDate,
                        transNo = ph.transNo,
                        payNo = pd.payNo,
                        otherType = pd.othersTypeCode,
                        payType = pt.payTypeCode,
                        netAmountPayment = pda.netAmt,
                        vatAmountPayment = pda.vatAmt,
                        totalAmountPayment = pda.netAmt + pda.vatAmt
                    }).ToList();

                    var dataSchedPush = new GetPSASMainScheduleDto
                    {
                        allocID          = dataSched.allocID,
                        allocCode        = dataSched.allocCode,
                        netAmount        = dataSched.netAmount,
                        VATAmount        = dataSched.VATAmount,
                        totalAmount      = dataSched.totalAmount,
                        dueDate          = dataSched.dueDate,
                        schedNo          = dataSched.schedNo,
                        paymentAmount    = dataSched.paymentAmount,
                        netOutstanding   = dataSched.netOutstanding,
                        VATOutstanding   = dataSched.VATOutstanding,
                        totalOutstanding = dataSched.totalOutstanding,
                        remarks          = dataSched.remarks,
                        penaltyAge       = dataSched.penaltyAge,
                        penaltyAmount    = dataSched.penaltyAmount,
                        dataPayment      = dataPayment
                    };

                    dataSchedule.Add(dataSchedPush);
                }

                dataSchedule.OrderBy(x => x.allocID).ThenBy(x => x.dueDate);
            }

            return(dataSchedule);
        }