예제 #1
0
        static public void SetGLNnumber(DCInvoice InvClient, DCAccount client, QueryAPI api)
        {
            var installation = (WorkInstallation)api.GetCache(typeof(WorkInstallation))?.Get(InvClient._Installation);
            var dctype       = InvClient.__DCType();
            var dccache      = api.GetCache((dctype == 2 || dctype == 9) ? typeof(Uniconta.DataModel.Creditor) : typeof(Uniconta.DataModel.Debtor));
            var debtor       = client ?? (DCAccount)dccache?.Get(InvClient._DCAccount);
            var contact      = (Contact)api.GetCache(typeof(Contact))?.Get(InvClient._ContactRef);

            InvClient._EAN = installation?._GLN ?? contact?._EAN ?? debtor?._EAN;
        }
예제 #2
0
        static public void SetDeliveryAdress(DCInvoice InvClient, DCAccount client, QueryAPI api)
        {
            SetGLNnumber(InvClient, client, api);

            if (InvClient._DeliveryAddress1 != null)
            {
                return;
            }

            if (InvClient._Installation != null)
            {
                var wInsCache    = api.GetCache(typeof(WorkInstallation)) ?? api.LoadCache(typeof(WorkInstallation)).GetAwaiter().GetResult();
                var installation = (WorkInstallation)wInsCache.Get(InvClient._Installation);
                if (installation == null)
                {
                    wInsCache    = api.LoadCache(typeof(WorkInstallation), true).GetAwaiter().GetResult();
                    installation = (WorkInstallation)wInsCache.Get(InvClient._Installation);
                }
                if (installation != null)
                {
                    InvClient._DeliveryName     = installation._Name;
                    InvClient._DeliveryAddress1 = installation._Address1;
                    InvClient._DeliveryAddress2 = installation._Address2;
                    InvClient._DeliveryAddress3 = installation._Address3;
                    InvClient._DeliveryZipCode  = installation._ZipCode;
                    InvClient._DeliveryCity     = installation._City;
                    if (api.CompanyEntity._Country != (byte)installation._Country)
                    {
                        InvClient._DeliveryCountry = installation._Country;
                    }
                }
            }
            else
            {
                DCAccount deb = null;
                string    ac;
                bool      UseDebAddress;
                if (InvClient._DeliveryAccount != null)
                {
                    ac            = InvClient._DeliveryAccount;
                    UseDebAddress = true;
                }
                else
                {
                    UseDebAddress = false;
                    if (client != null)
                    {
                        deb = client;
                        ac  = null;
                    }
                    else
                    {
                        ac = InvClient._DCAccount;
                    }
                }
                if (ac != null)
                {
                    var dctype  = InvClient.__DCType();
                    var t       = (dctype == 2 || dctype == 9) ? typeof(Uniconta.DataModel.Creditor) : typeof(Uniconta.DataModel.Debtor);
                    var dcCache = api.GetCache(t) ?? api.LoadCache(t).GetAwaiter().GetResult();
                    deb = (DCAccount)dcCache.Get(ac);
                    if (deb == null)
                    {
                        dcCache = api.LoadCache(t, true).GetAwaiter().GetResult();
                        deb     = (DCAccount)dcCache.Get(ac);
                    }
                }
                if (deb != null)
                {
                    if (deb._DeliveryAddress1 != null)
                    {
                        InvClient._DeliveryName     = deb._DeliveryName;
                        InvClient._DeliveryAddress1 = deb._DeliveryAddress1;
                        InvClient._DeliveryAddress2 = deb._DeliveryAddress2;
                        InvClient._DeliveryAddress3 = deb._DeliveryAddress3;
                        InvClient._DeliveryZipCode  = deb._DeliveryZipCode;
                        InvClient._DeliveryCity     = deb._DeliveryCity;
                        InvClient._DeliveryCountry  = deb._DeliveryCountry;
                    }
                    else if (UseDebAddress)
                    {
                        InvClient._DeliveryName     = deb._Name;
                        InvClient._DeliveryAddress1 = deb._Address1;
                        InvClient._DeliveryAddress2 = deb._Address2;
                        InvClient._DeliveryAddress3 = deb._Address3;
                        InvClient._DeliveryZipCode  = deb._ZipCode;
                        InvClient._DeliveryCity     = deb._City;
                        if (api.CompanyEntity._Country != (byte)deb._Country)
                        {
                            InvClient._DeliveryCountry = deb._Country;
                        }
                    }
                }
            }
        }