Exemplo n.º 1
0
        public async Task <IActionResult> GeneralLedger([FromBody] ReportModel reportModel)
        {
            ServiceResponseModel <LedgerReportModel> response = new ServiceResponseModel <LedgerReportModel>();

            try
            {
                if (string.IsNullOrWhiteSpace(reportModel.CompCode))
                {
                    throw new ArgumentNullException("CompCode is required");
                }
                if (string.IsNullOrWhiteSpace(reportModel.AccYear))
                {
                    throw new ArgumentNullException("AccYear is required");
                }
                if (reportModel.FinishDate.CompareTo(reportModel.StartDate) < 0)
                {
                    throw new ArgumentNullException("Invalid StartDate Or Finish date");
                }
                if (string.IsNullOrWhiteSpace(reportModel.StartAccount))
                {
                    throw new ArgumentNullException("Start Account is required");
                }
                if (string.IsNullOrWhiteSpace(reportModel.FinishAccount))
                {
                    throw new ArgumentNullException("Finish Account is required");
                }

                response = await _ledgerService.GeneralLedger(reportModel);

                if (response.Data == null)
                {
                    return(NotFound(response));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.StackTrace);
                response.Success = false;
                response.Message = ex.Message;
            }
            return(Ok(response));
        }