예제 #1
0
        public async Task <IActionResult> Get(long sinumber, string certificateid)
        {
            var request = new GetCertificatesPayableAmountRequest()
            {
                SiNumber = sinumber,
                Id       = certificateid
            };
            var response = await _service.GetCertificatesPayableAmountsAsync(request);

            if (response.BusinessMessages != null && response.BusinessMessages.Length > 0)
            {
                return(BadRequest(response.BusinessMessages));
            }

            var mappedModels = _mapper.Map <IEnumerable <ThabPayableAmount> >(response?.Value?.PayableAmounts);

            return(Ok(mappedModels));
        }
예제 #2
0
        public async Task <IActionResult> GetFOD(long sinumber, [FromQuery] string insz)
        {
            var certificates = await _thabcertificateService.SearchAsync(new ThabCertificateSearch { SiNumber = sinumber, Insz = insz });

            List <ThabPayment> payments = new List <ThabPayment>();

            foreach (var cert in certificates.Where(c => c.IsMigrated && c.DecisionDate.HasValue && c.BeginDate.HasValue))
            {
                int diff = GetMonthDifference(cert.BeginDate.Value, cert.DecisionDate.Value);
                diff++; //Decisionmonth also payed by FOD
                //amount
                var amountResponse = await _service.GetCertificatesPayableAmountsAsync(new GetCertificatesPayableAmountRequest()
                {
                    SiNumber = sinumber,
                    Id       = cert.CertificateId
                });

                for (int i = 0; i < diff; i++)
                {
                    DateTime beginDate = cert.BeginDate.Value.AddMonths(i);
                    decimal? amount    = amountResponse.Value?.PayableAmounts?.OrderByDescending(pa => pa.Start)?
                                         .FirstOrDefault(pa => pa.Start <= beginDate && (!pa.End.HasValue || beginDate <= pa.End.Value))?
                                         .Amount;
                    payments.Add(new ThabPayment()
                    {
                        BeginDate     = beginDate,
                        EndDate       = beginDate.AddMonths(1).AddDays(-1),
                        Amount        = amount ?? 0,
                        CertificateId = cert.CertificateId,
                        Currency      = "EUR"
                    });
                }
            }

            return(Ok(payments));
        }