示例#1
0
        private string toJson(CfopToUsageMap map)
        {
            string result = string.Empty;

            dynamic record = new ExpandoObject();

            record.Code            = map.RecId;
            record.Name            = map.RecId;
            record.U_CFOP          = map.Cfop;
            record.U_LGCYUSAGE     = map.UsageLegacy;
            record.U_USAGE         = map.Usage;
            record.U_TAXCODE       = map.TaxCode;
            record.U_DOCTYPE       = map.DocumentType;
            record.U_SERVICEITEM   = map.ServiceItem;
            record.U_WAREHOUSE     = map.Warehouse;
            record.U_CONTAPN       = map.ContaPN;
            record.U_CONTADEBITO   = map.ContaDebito;
            record.U_CONTACREDITO  = map.ContaCredito;
            record.U_CONTACONTROLE = map.ContaControle;
            record.U_CONTATAXA     = map.ContaTaxa;
            record.U_OBSERVACOES   = map.Observacoes;
            result = JsonConvert.SerializeObject(record);

            return(result);
        }
示例#2
0
        public void CT1_Insert()
        {
            Assert.That(async() => await _service.Insert(_map), Throws.Nothing);

            Task.Delay(2000);

            CfopToUsageMap map = readMap();

            Assert.IsNotNull(map);
        }
示例#3
0
        public void CT3_Delete()
        {
            CfopToUsageMap map = readMap();

            Assert.That(async() => await _service.Delete(map), Throws.Nothing);

            map = readMap();

            Assert.IsNull(map);
        }
示例#4
0
        async public Task Delete(CfopToUsageMap entity)
        {
            ServiceLayerResponse response = await _serviceLayerConnector.Delete($"{SL_TABLE_NAME}('{entity.RecId}')", "");

            if (!response.success)
            {
                string message = $"Erro ao excluir registro de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}";
                Console.WriteLine(message);
                throw new ApplicationException(message);
            }
        }
示例#5
0
        async public Task Insert(CfopToUsageMap entity)
        {
            string record = toJson(entity);

            ServiceLayerResponse response = await _serviceLayerConnector.Post(SL_TABLE_NAME, record);

            if (!response.success)
            {
                string message = $"Erro ao enviar registro de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}";
                Console.WriteLine(message);
                throw new ApplicationException(message);
            }
        }
示例#6
0
        async public Task Update(CfopToUsageMap entity)
        {
            string record = toJson(entity);

            ServiceLayerResponse response = await _serviceLayerConnector.Put($"{SL_TABLE_NAME}('{entity.RecId}')", record);

            if (!response.success)
            {
                string message = $"Erro ao atualizar registro de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}";
                Console.WriteLine(message);
                throw new ApplicationException(message);
            }
        }
示例#7
0
        public void CT2_Update()
        {
            CfopToUsageMap map = readMap();

            map.Usage = 11;

            Assert.That(async() => await _service.Update(map), Throws.Nothing);

            CfopToUsageMap newMap = readMap();

            Assert.IsNotNull(newMap);
            Assert.AreEqual(map.Usage, newMap.Usage);
        }
示例#8
0
        async public Task <CfopToUsageMap> Find(List <Criteria> criterias)
        {
            string recid = criterias[0].Value;
            string query = Global.BuildQuery($"{SL_TABLE_NAME}('{recid}')");

            string data = await _serviceLayerConnector.getQueryResult(query);

            ExpandoObject record = Global.parseQueryToObject(data);

            CfopToUsageMap result = null;

            if (record != null)
            {
                result = toRecord(record);
            }

            return(result);
        }
示例#9
0
        private CfopToUsageMap toRecord(dynamic record)
        {
            CfopToUsageMap map = new CfopToUsageMap();

            map.RecId        = Guid.Parse(record.Code);
            map.Cfop         = Convert.ToInt64(record.U_CFOP);
            map.UsageLegacy  = record.U_LGCYUSAGE;
            map.Usage        = Convert.ToInt64(record.U_USAGE);
            map.TaxCode      = record.U_TAXCODE;
            map.DocumentType = (CfopToUsageMap.DocumentTypeEnum)Convert.ToInt64(record.U_DOCTYPE);
            map.ServiceItem  = record.U_SERVICEITEM;
            map.Warehouse    = Convert.ToInt64(record.U_WAREHOUSE);

            map.ContaPN       = record.U_CONTAPN;
            map.ContaDebito   = record.U_CONTADEBITO;
            map.ContaCredito  = record.U_CONTACREDITO;
            map.ContaControle = record.U_CONTACONTROLE;
            map.ContaTaxa     = record.U_CONTATAXA;
            map.Observacoes   = record.U_OBSERVACOES;
            return(map);
        }
示例#10
0
        public void Setup()
        {
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.AddJsonFile(".\\appSettingsB1.json");

            ILoggerFactory    factory = new LoggerFactory();
            ILogger <Service> logger  = factory.CreateLogger <Service>();

            _configuration = builder.Build();
            _service       = new Service(_configuration, logger);

            doLogin();

            _map = new CfopToUsageMap()
            {
                Cfop         = 1102,
                UsageLegacy  = "001",
                DocumentType = CfopToUsageMap.DocumentTypeEnum.PurchInvoice,
                Usage        = 10,
                TaxCode      = "1102001",
                ServiceItem  = "1001"
            };
        }