Exemple #1
0
        private ErrorCodes CreateLines(List <string[]> lines, DebtorClient debtorClient)
        {
            var ols   = new List <DebtorOrderLineClient>();
            var items = _crudAPI.Query <InvItemClient>().Result;

            var order = new DebtorOrderClient();

            order.SetMaster(debtorClient);
            var orderres = _crudAPI.Insert(order).Result;

            foreach (string[] s in lines)
            {
                var item = items.First(i => i.Item == s[1]);

                var fp = new FindPrices(order, _crudAPI);
                fp.UseCustomerPrices = true;
                fp.loadPriceList();

                var ol = new DebtorOrderLineClient
                {
                    Qty  = double.Parse(s[2]),
                    Item = item.Item,
                    //Date = DateTime.Parse(s[3]),
                };
                ol.SetMaster(order);

                fp.SetPriceFromItem(ol, item);

                ols.Add(ol);
            }

            var result = _crudAPI.Insert(ols).Result;

            if (result == ErrorCodes.Succes)
            {
                openOrderLines(order);
            }

            return(result);
        }
Exemple #2
0
        private async void createLines(List <string[]> lines)
        {
            var orders = new List <DebtorOrderClient>();
            var ols    = new List <DebtorOrderLineClient>();
            var items  = await crudAPI.Query <InvItemClient>();

            var debtors = await crudAPI.Query <DebtorClient>();

            foreach (string[] s in lines)
            {
                DebtorOrderClient order;
                order = orders.Where(o => o.Account == s[0]).FirstOrDefault();
                if (order == null)
                {
                    order = new DebtorOrderClient();
                    order.SetMaster(debtors.Where(d => d.Account == s[0]).First());
                    orders.Add(order);
                    var orderres = await crudAPI.Insert(order);
                }

                var item = items.Where(i => i.Item == s[1]).First();

                var fp = new FindPrices(order, crudAPI);
                fp.UseCustomerPrices = true;
                fp.loadPriceList();

                var ol = new DebtorOrderLineClient
                {
                    Qty  = double.Parse(s[2]),
                    Item = item.Item,
                    Date = DateTime.Parse(s[3]),
                };
                ol.SetMaster(order);

                fp.SetPriceFromItem(ol, item);

                await crudAPI.Insert(ol);
            }
        }