Example #1
0
 internal static IActionResult Validate(this ExportDto dto)
 {
     return(null
            ?? CheckParam(dto.AccountName, nameof(ExportDto.AccountName))
            ?? CheckParam(dto.Login, nameof(ExportDto.Login))
            ?? CheckParam(dto.Key, nameof(ExportDto.Key))
            ?? CheckParam(dto.Month, nameof(ExportDto.Month), i => dto.Quarter.HasValue || (i.HasValue && i >= 1 && i <= 12))
            ?? CheckParam(dto.Quarter, nameof(ExportDto.Quarter), i => dto.Month.HasValue || (i.HasValue && i >= 1 && i <= 4))
            ?? CheckParam(dto.Year, nameof(ExportDto.Year), i => i >= 2000 && i <= 2030));
 }
Example #2
0
        private static IActionResult GetReport(ExportDto exportDto, TraceWriter log)
        {
            log.Info("Function started");
            IActionResult check = exportDto.Validate();

            if (check != null)
            {
                return(check);
            }

            var setup = new ExportSetup()
            {
                Year       = exportDto.Year,
                Period     = exportDto.Quarter ?? exportDto.Month.GetValueOrDefault(),
                ExportMode = exportDto.Quarter.HasValue ? ExportMode.Quarter : ExportMode.Month,

                OfficeDepartmentNo = exportDto.OfficeDepartmentId.ToString(),
                OfficeNo           = exportDto.OfficeNo.ToString(),
            };

            var connectConfig = new FakturoidConfiguration()
            {
                AccountName = exportDto.AccountName,
                Key         = exportDto.Key,
                Login       = exportDto.Login
            };


            var exporter = new XmlGenerator();

            log.Info("Export started");
            var exportedData = new FakturoidVATExportAdapter(connectConfig).GetExportForPeriod(setup);

            log.Info("Data exported");

            string xml = exporter.Generate(exportedData);

            log.Info("Report generated");

            return(new OkObjectResult(xml));
        }