internal void GenerateXmlReport(List<EUSaleWithoutVAT> invStats, CrudAPI api)
        {
            var declaration = new VD_deklaratsioon_Type();
            declaration.deklareerijaKood = api.CompanyEntity._VatNumber;
            var f = invStats[invStats.Count - 1];
            declaration.perioodAasta = NumberConvert.ToString(f.Date.Year);
            declaration.perioodKuu = NumberConvert.ToString(f.Date.Month);

            declaration.aruandeRead = GenerateReportLines(invStats);
            CreateXml(declaration);
        }
Ejemplo n.º 2
0
        async void MoveToVoucherAtIndex(int index, bool setFocus = false)
        {
            if (index < 0 || envelopes == null || index > envelopes.Length - 1)
            {
                return;
            }
            btnPrev.IsEnabled = btnNext.IsEnabled = true;
            if (selectedIndex == 0)
            {
                btnPrev.IsEnabled = false;
            }
            if (selectedIndex == envelopes.Length - 1)
            {
                btnNext.IsEnabled = false;
            }
            this.documentViewer.Children.Clear();
            currentBlk.Text = NumberConvert.ToString(index + 1);

            try
            {
                VouchersClient vClient = envelopes[selectedIndex];
                if (vClient._Data != null)
                {
                    VoucherCache.SetGlobalVoucherCache(vClient);
                }
                else
                {
                    await UtilDisplay.GetData(vClient, api);
                }

                this.documentViewer.Children.Add(UtilDisplay.LoadControl(vClient, false, setFocus));
            }
            catch (Exception ex)
            {
                brdMetaInfo.Visibility = System.Windows.Visibility.Visible;
                this.documentViewer.Children.Add((UtilDisplay.LoadDefaultControl(string.Format("{0}. \n{1} : {2}", Uniconta.ClientTools.Localization.lookup("InvalidDocSave"),
                                                                                               Uniconta.ClientTools.Localization.lookup("ViewerFailed"), ex.Message))));
            }
            SetMetaInfo(voucherClient);
        }
Ejemplo n.º 3
0
        private DataColumn[] GenerateColumnHeader(List <string> firstLineValues, out bool showColumnHeaders)
        {
            DataColumn[] dataColumns;
            showColumnHeaders = ValidateColumnHeaderValues(firstLineValues);
            if (!showColumnHeaders)
            {
                int maxIndex = 20;
                dataColumns = new DataColumn[maxIndex];
                for (int icol = 0; icol < maxIndex; icol++)
                {
                    dataColumns[icol] = new DataColumn(string.Concat("Column ", NumberConvert.ToString(icol + 1)));
                }

                dgBankStmt.View.ShowColumnHeaders = showColumnHeaders;
            }
            else
            {
                int maxIndex = firstLineValues.Count;
                dataColumns = new DataColumn[maxIndex];
                string[] tempValues = new string[maxIndex];
                for (int icol = 0; icol < maxIndex; icol++)
                {
                    var col = firstLineValues[icol];
                    tempValues[icol] = col;

                    if (tempValues.Where(c => c == col).Count() > 1)
                    {
                        col = string.Concat(col, "_", NumberConvert.ToString(icol));
                    }

                    dataColumns[icol] = new DataColumn(col);
                }
                dgBankStmt.View.ShowColumnHeaders = showColumnHeaders;
            }
            hasHeaderColumnGenerated = true;

            return(dataColumns);
        }
        public static string InternalMessage(string messageFormat, CreditorTransPayment rec, Company company, Uniconta.DataModel.Creditor creditor)
        {
            var sbAdvText = StringBuilderReuse.Create();

            var advText = string.Empty;
            var country = company._CountryId;
            var tuple   = MessageLabel(country);

            if (messageFormat != null)
            {
                sbAdvText.Append(messageFormat);

                if (rec.invoiceNumbers != null && rec.MergePaymId != MERGEID_SINGLEPAYMENT)
                {
                    sbAdvText.Remove("Fak:%1").Trim(); //Removes invoicenumbers for merge payment due to limitation of characters
                    sbAdvText.Remove("Fak: %1").Trim();
                    sbAdvText.Remove("%1").Trim();
                }

                sbAdvText.Replace("%1", "{0}").Replace("%2", "{1}").Replace("%3", "{2}").Replace("%4", "{3}").Replace("%5", "{4}");
                advText = string.Format(sbAdvText.ToStringAndRelease(), rec.InvoiceAN, creditor?._Account, creditor?._Name, NumberConvert.ToStringNull(rec.Voucher), NumberConvert.ToStringNull(rec.PaymentRefId));
            }
            else //Default message
            {
                BuildBankAdviceText(sbAdvText, NumberConvert.ToString(rec.PaymentEndToEndId), tuple.Item3);
                if (rec.invoiceNumbers == null || rec.MergePaymId == MERGEID_SINGLEPAYMENT)
                {
                    BuildBankAdviceText(sbAdvText, rec.InvoiceAN ?? string.Empty, tuple.Item2);
                }

                BuildBankAdviceText(sbAdvText, creditor?._Account, tuple.Item1);

                advText = sbAdvText.ToStringAndRelease();
            }

            return(advText);
        }
        private void frmRibbon_OnItemClicked(string ActionType)
        {
            switch (ActionType)
            {
            case "SaveAndOrderLines":
                saveFormAndOpenControl(TabControls.DebtorOfferLines);
                break;

            case "Delete":
                if (editrow._OrderTotal != 0)
                {
                    var msg  = Uniconta.ClientTools.Localization.lookup("NumberOfLines") + ": " + NumberConvert.ToString(editrow._Lines);
                    var msg2 = msg + "\r\n" + string.Format(Uniconta.ClientTools.Localization.lookup("ConfirmDeleteOBJ"), editrow._OrderNumber);
                    CWConfirmationBox dialog = new CWConfirmationBox(msg2, Uniconta.ClientTools.Localization.lookup("Confirmation"), false);
                    dialog.Closing += delegate
                    {
                        if (dialog.ConfirmationResult == CWConfirmationBox.ConfirmationResultEnum.Yes)
                        {
                            frmRibbon_BaseActions(ActionType);
                        }
                    };
                    dialog.Show();
                }
                else
                {
                    frmRibbon_BaseActions(ActionType);
                }
                break;

            default:
                frmRibbon_BaseActions(ActionType);
                break;
            }
        }
Ejemplo n.º 6
0
 protected override void SyncEntityMasterRowChanged(UnicontaBaseEntity args)
 {
     dgProjInvProjectLineGrid.UpdateMaster(args);
     invoiceProposal = dgProjInvProjectLineGrid.masterRecord as ProjectInvoiceProposal;
     if (invoiceProposal != null)
     {
         api.Read(invoiceProposal);
         SetHeader(string.Concat(Uniconta.ClientTools.Localization.lookup("ProjectAdjustments"), ": ", NumberConvert.ToString(invoiceProposal._OrderNumber)));
     }
     InitQuery();
 }
Ejemplo n.º 7
0
        async private void JournalPosted(ProjectTransClient selectedItem)
        {
            var pairPostedJour = new PropValuePair[]
            {
                PropValuePair.GenereteWhereElements(nameof(ProjectJournalPostedClient.GLJournalPostedId), typeof(int), NumberConvert.ToString(selectedItem._JournalPostedId))
            };
            var result = await api.Query <ProjectJournalPostedClient>(pairPostedJour);

            if (result != null && result.Length == 1)
            {
                CWProjPostedClientFormView cwPostedClient = new CWProjPostedClientFormView(result[0]);
                cwPostedClient.Show();
            }
        }
        private void frmRibbon_OnItemClicked(string ActionType)
        {
            switch (ActionType)
            {
            case "SaveAndOrderLines":
                saveFormAndOpenControl(TabControls.DebtorOrderLines);
                break;

            case "RefVoucher":
                var _refferedVouchers = new List <int>();
                if (editrow._DocumentRef != 0)
                {
                    _refferedVouchers.Add(editrow._DocumentRef);
                }
                setVoucher = true;
                AddDockItem(TabControls.AttachVoucherGridPage, new object[] { _refferedVouchers }, true);
                break;

            case "ViewVoucher":
                ViewVoucher(TabControls.VouchersPage3, editrow);
                break;

            case "ImportVoucher":
                Utility.ImportVoucher(editrow, api, new VouchersClient()
                {
                    _Content = ContentTypes.Invoice
                });
                break;

            case "RemoveVoucher":
                RemoveVoucher(editrow);
                break;

            case "Save":
                if (Utility.IsExecuteWithBlockedAccount(editrow.Debtor))
                {
                    frmRibbon_BaseActions(ActionType);
                }
                break;

            case "Delete":
                if (editrow._OrderTotal != 0)
                {
                    var msg  = Uniconta.ClientTools.Localization.lookup("NumberOfLines") + ": " + NumberConvert.ToString(editrow._Lines);
                    var msg2 = msg + "\r\n" + string.Format(Uniconta.ClientTools.Localization.lookup("ConfirmDeleteOBJ"), editrow._OrderNumber);
                    CWConfirmationBox dialog = new CWConfirmationBox(msg2, Uniconta.ClientTools.Localization.lookup("Confirmation"), false);
                    dialog.Closing += delegate
                    {
                        if (dialog.ConfirmationResult == CWConfirmationBox.ConfirmationResultEnum.Yes)
                        {
                            frmRibbon_BaseActions(ActionType);
                        }
                    };
                    dialog.Show();
                }
                else
                {
                    frmRibbon_BaseActions(ActionType);
                }
                break;

            default:
                frmRibbon_BaseActions(ActionType);
                break;
            }
        }
        private async void ReadFromBilagscan(UnicontaBaseEntity selectedItem)
        {
#if !SILVERLIGHT
            if (!readingFromBilagscan)
            {
                readingFromBilagscan = true;

                bool processLines = false;
                var  accessToken  = await Bilagscan.Account.GetBilagscanAccessToken(api);

                var noOfVouchers    = 0;
                var companySettings = await api.Query <CompanySettingsClient>();

                var orgNo = companySettings.FirstOrDefault()._OrgNumber;

                var journal = dgGldailyJournal.SelectedItem as GLDailyJournalClient;

                //  UnicontaBaseEntity[] baseEntityArray = new UnicontaBaseEntity[1] { selectedItem };

                using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
                    var response = await client.GetAsync($"https://api.bilagscan.dk/v1/organizations/" + orgNo.ToString() + "/vouchers?seen=false&count=100&offset=0&sorts=-upload_date&status=successful");

                    var content = await response.Content.ReadAsStringAsync();

                    var vouchers = Bilagscan.Voucher.GetVouchers(content);

                    var credCache = api.CompanyEntity.GetCache(typeof(Uniconta.DataModel.Creditor)) ?? await api.CompanyEntity.LoadCache(typeof(Uniconta.DataModel.Creditor), api);

                    var offsetCache = api.CompanyEntity.GetCache(typeof(Uniconta.DataModel.GLAccount)) ?? await api.CompanyEntity.LoadCache(typeof(Uniconta.DataModel.GLAccount), api);

                    var vouchersSeen = new CommaDelimitedStringCollection();

                    var master = new List <UnicontaBaseEntity>
                    {
                        journal
                    };

                    var newLines       = new List <UnicontaBaseEntity>();
                    var updateCreditor = new List <UnicontaBaseEntity>();

                    if (vouchers?.data != null)
                    {
                        var creditors = credCache.GetKeyStrRecords as Uniconta.DataModel.Creditor[];

                        foreach (var voucher in vouchers.data)
                        {
                            vouchersSeen.Add(NumberConvert.ToString(voucher.id));
                            var journalLine = new GLDailyJournalLineClient()
                            {
                                Approved        = false,
                                ForceSettlement = false
                            };

                            var postingType = BilagscanVoucherType.Invoice;

                            var hint = Bilagscan.Voucher.GetHint(voucher.note);

                            var bilagscanRefID = voucher.id;
                            journalLine.ReferenceNumber = bilagscanRefID != 0 ? NumberConvert.ToString(bilagscanRefID) : null;

                            var bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "voucher_number", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                journalLine.Invoice = bsItem.value;
                            }

                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "voucher_type", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                switch (bsItem.value)
                                {
                                case "invoice": postingType = BilagscanVoucherType.Invoice; break;

                                case "creditnote": postingType = BilagscanVoucherType.Creditnote; break;

                                case "receipt": postingType = BilagscanVoucherType.Receipt; break;
                                }
                            }

                            var creditorCVR = string.Empty;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "company_vat_reg_no", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                creditorCVR = bsItem.value;
                            }

                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "total_amount_incl_vat", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                journalLine.Amount = Math.Abs(NumberConvert.ToDoubleNoThousandSeperator(bsItem.value));

                                if (postingType != BilagscanVoucherType.Creditnote)
                                {
                                    journalLine.Amount = -journalLine.Amount;
                                }
                            }

                            CountryCode countryCode = CountryCode.Denmark;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "country", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                CountryISOCode countryISO;
                                countryCode = CountryCode.Denmark; //default
                                if (Enum.TryParse(bsItem.value, true, out countryISO))
                                {
                                    countryCode = (CountryCode)countryISO;
                                }
                            }

                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "invoice_date", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                var invoiceDate = bsItem.value == string.Empty ? GetSystemDefaultDate() : StringSplit.DateParse(bsItem.value, DateFormat.ymd);
                                journalLine.Date = invoiceDate;

                                if (journalLine.Date == DateTime.MinValue)
                                {
                                    journalLine.Date = GetSystemDefaultDate();
                                }
                            }

                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "payment_date", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                var paymentDate = bsItem.value == string.Empty ? DateTime.MinValue : StringSplit.DateParse(bsItem.value, DateFormat.ymd);
                                journalLine._DueDate = paymentDate;
                            }

                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "currency", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                Currencies currencyISO;
                                if (!Enum.TryParse(bsItem.value, true, out currencyISO))
                                {
                                    currencyISO = Currencies.DKK; //default
                                }
                                journalLine._Currency = (byte)currencyISO;
                            }

                            string bbanAcc = null;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "payment_account_number", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                bbanAcc = bsItem.value;
                            }

                            string bbanRegNum = null;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "payment_reg_number", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                bbanRegNum = bsItem.value;
                            }

                            string ibanNo = null;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "payment_iban", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                ibanNo = bsItem.value;
                            }

                            string swiftNo = null;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "payment_swift_bic", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                swiftNo = bsItem.value;
                            }

                            string paymentCodeId = null;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "payment_code_id", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                paymentCodeId = bsItem.value;
                            }

                            string paymentId = null;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "payment_id", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                paymentId = bsItem.value;
                            }

                            string jointPaymentId = null;
                            bsItem = voucher.header_fields.Where(hf => string.Compare(hf.code, "joint_payment_id", true) == 0).FirstOrDefault();
                            if (bsItem != null)
                            {
                                jointPaymentId = bsItem.value;
                            }

                            var paymentMethod = PaymentTypes.VendorBankAccount;
                            switch (paymentCodeId)
                            {
                            case "71": paymentMethod = PaymentTypes.PaymentMethod3; break;

                            case "73": paymentMethod = PaymentTypes.PaymentMethod4; break;

                            case "75": paymentMethod = PaymentTypes.PaymentMethod5; break;

                            case "04":
                            case "4": paymentMethod = PaymentTypes.PaymentMethod6; break;
                            }

                            if (paymentMethod != PaymentTypes.VendorBankAccount && (paymentId != null || jointPaymentId != null))
                            {
                                journalLine._PaymentMethod = paymentMethod;
                                journalLine._PaymentId     = string.Format("{0} +{1}", paymentId, jointPaymentId);
                            }
                            else if (bbanRegNum != null && bbanAcc != null)
                            {
                                journalLine._PaymentMethod = PaymentTypes.VendorBankAccount;
                                journalLine._PaymentId     = string.Format("{0}-{1}", bbanRegNum, bbanAcc);
                            }
                            else if (swiftNo != null && ibanNo != null)
                            {
                                journalLine._PaymentMethod = PaymentTypes.IBAN;
                                journalLine._PaymentId     = ibanNo;
                            }

                            journalLine.SettleValue = "Voucher";

                            Uniconta.DataModel.Creditor creditor = null;

                            if (hint != null)
                            {
                                journalLine._DocumentRef = hint.RowId;
                                //if (hint.CreditorAccount != null)
                                //    creditor = (Uniconta.DataModel.Creditor)credCache.Get(hint.CreditorAccount);
                                //if (hint.Amount != 0)
                                //    journalLine.Amount = hint.Amount;
                                //if (hint.Currency != null && hint.Currency != "-")
                                //    journalLine.Currency = hint.Currency;
                                //if (hint.PaymentId != null)
                                //{
                                //    journalLine._PaymentId = hint.PaymentId;
                                //    journalLine.PaymentMethod = hint.PaymentMethod;
                                //}
                            }

                            journalLine._AccountType = 2;

                            var creditorCVRNum = Regex.Replace(creditorCVR, "[^0-9]", string.Empty);

                            if (creditorCVRNum != string.Empty)
                            {
                                creditor = creditors.Where(s => (Regex.Replace(s._LegalIdent ?? string.Empty, "[^0-9.]", "") == creditorCVRNum)).FirstOrDefault();
                            }

                            if (creditorCVRNum == string.Empty)
                            {
                                journalLine.Text = Uniconta.ClientTools.Localization.lookup("NotValidVatNo");
                            }
                            else if (creditor == null)
                            {
                                var newCreditor = new CreditorClient()
                                {
                                    _Account       = creditorCVR,
                                    _LegalIdent    = creditorCVR,
                                    _PaymentMethod = journalLine._PaymentMethod,
                                    _PaymentId     = journalLine._PaymentId,
                                    _SWIFT         = swiftNo
                                };

                                CompanyInfo companyInformation = null;
                                try
                                {
                                    companyInformation = await CVR.CheckCountry(creditorCVR, countryCode);
                                }
                                catch (Exception ex)
                                {
                                    UnicontaMessageBox.Show(ex);
                                    return;
                                }

                                if (companyInformation != null)
                                {
                                    if (companyInformation.life != null)
                                    {
                                        newCreditor._Name = companyInformation.life.name;
                                    }

                                    if (companyInformation.address != null)
                                    {
                                        newCreditor._Address1 = companyInformation.address.CompleteStreet;
                                        newCreditor._ZipCode  = companyInformation.address.zipcode;
                                        newCreditor._City     = companyInformation.address.cityname;
                                        newCreditor._Country  = companyInformation.address.Country;
                                    }

                                    if (companyInformation.contact != null)
                                    {
                                        newCreditor._Phone        = companyInformation.contact.phone;
                                        newCreditor._ContactEmail = companyInformation.contact.email;
                                    }

                                    journalLine.Text = newCreditor.Name;
                                }
                                else
                                {
                                    newCreditor.Name = Uniconta.ClientTools.Localization.lookup("NotValidVatNo");
                                }

                                await api.Insert(newCreditor);

                                journalLine.Account = creditorCVR;
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(creditor._PostingAccount))
                                {
                                    var account = (GLAccountClient)offsetCache.Get(creditor._PostingAccount);
                                    if (!string.IsNullOrEmpty(account.Vat))
                                    {
                                        var dailyJournal = (GLDailyJournalClient)master[0];
                                        if (dailyJournal.TwoVatCodes)
                                        {
                                            journalLine._OffsetVat = account.Vat;
                                        }
                                        else
                                        {
                                            journalLine._Vat = account.Vat;
                                        }
                                    }

                                    journalLine._OffsetAccount = creditor._PostingAccount;
                                }
                                else
                                {
                                    journalLine.Vat = creditor._Vat;
                                }


                                if (journalLine._DueDate == DateTime.MinValue && creditor._Payment != string.Empty)
                                {
                                    var paymentTermsCache = api.GetCache(typeof(PaymentTerm)) ?? await api.LoadCache(typeof(PaymentTerm));

                                    var paymentTerm = (PaymentTerm)paymentTermsCache.Get(creditor._Payment);

                                    if (paymentTerm != null)
                                    {
                                        journalLine._DueDate = paymentTerm.GetDueDate(journalLine.DueDate);
                                    }
                                }

                                journalLine.Account = creditor._Account;
                                journalLine.Text    = creditor._Name;

                                if (creditor._SWIFT == null && swiftNo != null)
                                {
                                    creditor._SWIFT = swiftNo;
                                    updateCreditor.Add(creditor);
                                }
                            }

                            journalLine.SetMaster(master[0]);
                            newLines.Add(journalLine);

                            noOfVouchers += 1;
                        }
                    }
                    var errorCode = await api.Insert(newLines);

                    api.UpdateNoResponse(updateCreditor);

                    if (vouchersSeen.Count != 0)
                    {
                        // Mark voucher as seen
                        string serializedRequest = "{ \"vouchers\": [ " + vouchersSeen.ToString() + " ] }";
                        var    vContent          = new StringContent(serializedRequest, Encoding.UTF8, "application/json");
                        response = await client.PostAsync($"https://api.bilagscan.dk/v1/organizations/" + NumberConvert.ToString(orgNo) + "/vouchers/seen", vContent);

                        var res = await response.Content.ReadAsStringAsync();
                    }
                }

                if (noOfVouchers == 0)
                {
                    UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("StillProcessingTryAgain"), Uniconta.ClientTools.Localization.lookup("Bilagscan")), Uniconta.ClientTools.Localization.lookup("Bilagscan"), MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    var messageText = string.Concat(string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("NumberOfImportedVouchers"), noOfVouchers),
                                                    Environment.NewLine, Environment.NewLine,
                                                    string.Format(Uniconta.ClientTools.Localization.lookup("GoTo"), Uniconta.ClientTools.Localization.lookup("Journallines")), "?");
                    if (UnicontaMessageBox.Show(messageText, Uniconta.ClientTools.Localization.lookup("BilagscanRead"), MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.OK)
                    {
                        AddDockItem(TabControls.GL_DailyJournalLine, journal, null, null, true);
                    }
                }
                readingFromBilagscan = false;
            }
#endif
        }
Ejemplo n.º 10
0
        void localMenu_OnItemClicked(string ActionType)
        {
            var fromDate = txtDateFrm.DateTime;
            var toDate   = txtDateTo.DateTime;
            var lin      = dgVatReport.SelectedItem as VatReportLine;

            switch (ActionType)
            {
            case "VatReportSpain":
            {
                List <VatReportLine> lst = (List <VatReportLine>)dgVatReport.ItemsSource;
                if (lst == null)
                {
                    return;
                }
                var array = UnicontaClient.Pages.GL.Reports.VatSpain.calc(lst.ToArray());
                AddDockItem(TabControls.VatReportSpain, new object[] { api, array }, "Modelo 303", null, closeIfOpened: true);
                break;
            }

            case "VatReportNorway":
                if (vatReportSum != null)
                {
                    AddDockItem(TabControls.VatReportNorway, new object[] { vatReportSum, fromDate, toDate }, "Mva skattemeldingen", null, closeIfOpened: true);
                }
                break;

            case "VatReportDenmark":
                if (vatReportSum != null)
                {
                    AddDockItem(TabControls.VatReportDenmark, new object[] { api, this.vatReportSum, fromDate, toDate }, "Momsopgørelse", null, closeIfOpened: true);
                }
                break;

            case "VatReportHolland":
                if (vatReportSum != null)
                {
                    AddDockItem(TabControls.VatReportHolland, new object[] { vatReportSum, fromDate, toDate }, "BTW Aangifte", null, closeIfOpened: true);
                }
                break;

            case "VatReportEstonia":
                if (vatReportSum != null)
                {
                    AddDockItem(TabControls.VatReportEstonia, new object[] { vatReportSum, fromDate, toDate }, "KM avaldus", null, closeIfOpened: true);
                }
                break;

            case "VatReportUnitedKingdom":
                if (vatReportSum != null)
                {
                    AddDockItem(TabControls.VatReportUnitedKingdom, new object[] { vatReportSum, fromDate, toDate }, "VAT statement", null, closeIfOpened: true);
                }
                break;

            case "Transactions":
                if (lin?.Account != null)
                {
                    if (string.IsNullOrEmpty(cmbJournal.Text))
                    {
                        var dt = PropValuePair.GenereteWhereElements("Date", fromDate, CompareOperator.GreaterThanOrEqual);
                        dt.OrList[0].SecundaryValue = NumberConvert.ToString(toDate.Ticks);
                        var filter = new PropValuePair[]
                        {
                            dt,
                            PropValuePair.GenereteWhereElements("Account", lin.AccountNumber, CompareOperator.Equal),
                            PropValuePair.GenereteWhereElements("Vat", lin.Vat != null ? lin.Vat._Vat : "null", CompareOperator.Equal)
                        };
                        AddDockItem(TabControls.AccountsTransaction, new object[] { api, filter }, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Transactions"), lin.AccountNumber));
                    }
                    else
                    {
                        string header            = string.Concat(Uniconta.ClientTools.Localization.lookup("AccountStatement"), "/", lin.Account.AccountNumber);
                        var    transactionReport = dockCtrl.AddDockItem(TabControls.TransactionReport, this.ParentControl, new object[] { lin.Account, IdObject.get(true) }, header) as TransactionReport;
                        if (transactionReport != null)
                        {
                            transactionReport.SetControlsAndLoadGLTrans(fromDate, toDate, null, null, null, null, null, cmbJournal.Text);
                        }
                    }
                }
                break;

            case "VatReportIceland":
                if (vatReportSum != null)
                {
                    AddDockItem(TabControls.VatReportIceland, new object[] { vatReportSum, fromDate, toDate }, "VAT statement", null, closeIfOpened: true);
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Ejemplo n.º 11
0
        async private void ShowDocument(IEnumerable <DebtorInvoiceClient> debtorInvoices, bool isInvoice)
        {
            busyIndicator.IsBusy      = true;
            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");

            try
            {
                var docList = debtorInvoices.ToList();
#if !SILVERLIGHT
                var    failedPrints = new List <long>();
                var    count = docList.Count;
                string dockName = null, reportName = null;
                bool   exportAsPdf = false;
                System.Windows.Forms.FolderBrowserDialog folderDialogSaveInvoice = null;
                hasLookups = false;
                if (count > 1)
                {
                    hasLookups = true;
                    if (count > StandardPrintReportPage.MAX_PREVIEW_REPORT_LIMIT)
                    {
                        var confirmMsg = string.Format(Uniconta.ClientTools.Localization.lookup("PreivewRecordsExportMsg"), count);
                        if (UnicontaMessageBox.Show(confirmMsg, Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                        {
                            exportAsPdf = true;
                        }
                    }
                    else if (isInvoice)
                    {
                        dockName = string.Concat(Uniconta.ClientTools.Localization.lookup("Preview"), ": ", Uniconta.ClientTools.Localization.lookup("Debtor"),
                                                 " ", Uniconta.ClientTools.Localization.lookup("Invoices"));
                        reportName = string.Concat(Uniconta.ClientTools.Localization.lookup("Debtor"), Uniconta.ClientTools.Localization.lookup("Invoices"));
                    }
                    else
                    {
                        dockName   = string.Concat(Uniconta.ClientTools.Localization.lookup("Preview"), ": ", Uniconta.ClientTools.Localization.lookup("Packnote"));
                        reportName = Uniconta.ClientTools.Localization.lookup("Packnote");
                    }

                    ribbonControl.DisableButtons(new [] { "ShowInvoice", "ShowPackNote" });
                }
#elif SILVERLIGHT
                int top = 200, left = 300;
                int count = docList.Count;

                if (count > 1)
                {
#endif
                foreach (var debtInvoice in docList)
                {
#if !SILVERLIGHT
                    IsGeneratingDocument = true;
                    IPrintReport printReport = isInvoice ? await PrintInvoice(debtInvoice) : await PrintPackNote(debtInvoice);

                    if (printReport?.Report != null)
                    {
                        var docNumber = isInvoice ? debtInvoice._InvoiceNumber : debtInvoice._PackNote;
                        if (count > 1 && IsGeneratingDocument)
                        {
                            if (exportAsPdf)
                            {
                                string docName       = isInvoice ? Uniconta.ClientTools.Localization.lookup("Invoice") : Uniconta.ClientTools.Localization.lookup("Packnote");
                                string directoryPath = string.Empty;
                                if (folderDialogSaveInvoice == null)
                                {
                                    folderDialogSaveInvoice = UtilDisplay.LoadFolderBrowserDialog;
                                    var dialogResult = folderDialogSaveInvoice.ShowDialog();
                                    if (dialogResult == System.Windows.Forms.DialogResult.OK || dialogResult == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        directoryPath = folderDialogSaveInvoice.SelectedPath;
                                    }
                                }
                                else
                                {
                                    directoryPath = folderDialogSaveInvoice.SelectedPath;
                                }

                                Utility.ExportReportAsPdf(printReport.Report, directoryPath, docName, NumberConvert.ToString(docNumber));
                            }
                            else
                            {
                                if (standardViewerPageForDocument == null)
                                {
                                    standardViewerPageForDocument = dockCtrl.AddDockItem(api?.CompanyEntity, TabControls.StandardPrintReportPage, ParentControl, new object[] { printReport, reportName }, dockName) as StandardPrintReportPage;
                                }
                                else
                                {
                                    standardViewerPageForDocument.InsertToMasterReport(printReport.Report);
                                }
                            }
                        }
                        else
                        {
                            var docType = isInvoice ? CompanyLayoutType.Invoice : CompanyLayoutType.Packnote;
                            reportName = await Utility.GetLocalizedReportName(api, debtInvoice, docType);

                            dockName = string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("Preview"), string.Format("{0}: {1}", isInvoice ? Uniconta.ClientTools.Localization.lookup("Invoice") :
                                                                                                                                   Uniconta.ClientTools.Localization.lookup("Packnote"), NumberConvert.ToString(docNumber)));

                            AddDockItem(TabControls.StandardPrintReportPage, new object[] { new List <IPrintReport> {
                                                                                                printReport
                                                                                            }, reportName }, dockName);
                            break;
                        }
                    }
                    else
                    {
                        failedPrints.Add(debtInvoice.InvoiceNumber);
                    }
                }

                IsGeneratingDocument = false;
                ribbonControl?.EnableButtons(new [] { "ShowInvoice", "ShowPackNote" });

                if (failedPrints.Count > 0)
                {
                    var failedList = string.Join(",", failedPrints);
                    UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("FailedPrintmsg") + failedList, Uniconta.ClientTools.Localization.lookup("Error"), MessageBoxButton.OK);
                }
#elif SILVERLIGHT
                    DefaultPrint(debtInvoice, true, new Point(top, left));
                    left = left - left / count;
                    top  = top - top / count;
                }
            }
            else
            {
                DefaultPrint(debtorInvoices.First());
            }
#endif
            }
Ejemplo n.º 12
0
        private static DataColumn[] GenerateColumnHeader(List <string> firstLineValues, out bool showColumnHeaders)
        {
            DataColumn[] dataColumns;
            showColumnHeaders = ValidateColumnHeaderValues(firstLineValues);
            if (!showColumnHeaders)
            {
                int maxIndex = 35;
                dataColumns = new DataColumn[maxIndex];
                for (int icol = 0; icol < maxIndex; icol++)
                {
                    dataColumns[icol] = new DataColumn(string.Concat("Column ", NumberConvert.ToString(icol + 1)));
                }
            }
            else
            {
                int maxIndex = firstLineValues.Count;
                dataColumns = new DataColumn[maxIndex];
                string[] tempValues = new string[maxIndex];
                for (int icol = 0; icol < maxIndex; icol++)
                {
                    var col = firstLineValues[icol];
                    tempValues[icol] = col;

                    if (tempValues.Where(c => c == col).Count() > 1)
                    {
                        col = string.Concat(col, "_", NumberConvert.ToString(icol));
                    }
                    if (col.CompareTo("LMnr") == 0)
                    {
                        col = "Item";
                    }
                    if (col.CompareTo("EANnr") == 0)
                    {
                        col = "EAN";
                    }
                    if (col.CompareTo("AlternativNr") == 0)
                    {
                        col = "AlternativeItem";
                    }
                    if (col.CompareTo("Varebetegnelse") == 0)
                    {
                        col = "Name";
                    }
                    if (col.CompareTo("LeverandørTypenr") == 0)
                    {
                        col = "SupplierItemId";
                    }
                    if (col.CompareTo("LeverandørNavn") == 0)
                    {
                        col = "Supplier";
                    }
                    if (col.CompareTo("Enhed") == 0)
                    {
                        col = "Unit";
                    }
                    if (col.CompareTo("ListeprisPrEnhed") == 0)
                    {
                        col = "SalesPrice";
                    }
                    if (col.CompareTo("RabatHirakiNavn") == 0)
                    {
                        col = "DiscountGroup";
                    }
                    if (col.CompareTo("VaregruppeNavn") == 0)
                    {
                        col = "ItemGroup";
                    }
                    if (col.CompareTo("Deeplink") == 0)
                    {
                        col = "WebArg";
                    }
                    dataColumns[icol] = new DataColumn(col);
                }
            }
            hasHeaderColumnGenerated = true;
            return(dataColumns);
        }
Ejemplo n.º 13
0
        async private void _LoadInitMaster(UnicontaBaseEntity corasauMaster, VouchersClient voucherClient, int RowId, bool setFocus)
        {
            try
            {
                if (voucherClient == null)
                {
                    if (RowId != 0)
                    {
                        voucherClient = new VouchersClient();
                        voucherClient.SelectRowId(RowId);
                        // we will now enter api.read
                    }
                    else
                    {
                        busyIndicator.IsBusy = true;
                        var voucher = await api.Query <VouchersClient>(corasauMaster);

                        voucherClient = voucher?.FirstOrDefault();
                        if (voucherClient?._Data != null)
                        {
                            VoucherCache.SetGlobalVoucherCache(voucherClient);
                        }
                    }
                }

                if (voucherClient._Data == null)
                {
                    busyIndicator.IsBusy = true;
                    var result = await UtilDisplay.GetData(voucherClient, api);

                    if (result != 0)
                    {
                        busyIndicator.IsBusy = false;
                        UtilDisplay.ShowErrorCode(result);
                        return;
                    }
                }

                this.documentViewer.Children.Clear();

                brdMetaInfo.Visibility = Visibility.Visible;
                if (voucherClient._Envelope)
                {
                    btnPrev.IsEnabled    = false;
                    busyIndicator.IsBusy = true;
                    var dapi = new DocumentAPI(api);
                    envelopes = (VouchersClient[])await dapi.GetEnvelopeContent(voucherClient, true);

                    gridPrevNext.Visibility = Visibility.Visible;
                    if (envelopes != null && envelopes.Length > 0)
                    {
                        totalBlk.Text = NumberConvert.ToString(envelopes.Length);
                        MoveToVoucherAtIndex(selectedIndex, setFocus);

                        /*
                         * currentBlk.Text = NumberConvert.ToString(selectedIndex + 1);
                         * var doc = envelopes[selectedIndex];
                         * this.documentViewer.Children.Add(UtilDisplay.LoadControl(doc.Buffer, doc._Fileextension, false, setFocus));
                         */
                    }
                    else
                    {
                        totalBlk.Text   = "0";
                        currentBlk.Text = "0";
                    }
                    busyIndicator.IsBusy = false;
                }
                else
                {
                    busyIndicator.IsBusy = false;
                    this.documentViewer.Children.Add(UtilDisplay.LoadControl(voucherClient, false, setFocus));
                }
            }
            catch (Exception ex)
            {
                brdMetaInfo.Visibility = Visibility.Visible;
                this.documentViewer.Children.Add((UtilDisplay.LoadDefaultControl(string.Format("{0}. {1} : {2}", Uniconta.ClientTools.Localization.lookup("InvalidDocSave"),
                                                                                               Uniconta.ClientTools.Localization.lookup("ViewerFailed"), ex.Message))));
                busyIndicator.IsBusy = false;
            }
            SetMetaInfo(voucherClient);
        }
Ejemplo n.º 14
0
        void localMenu_OnItemClicked(string ActionType)
        {
            var fromDate = txtDateFrm.DateTime;
            var toDate   = txtDateTo.DateTime;
            var lin      = dgVatReport.SelectedItem as VatReportLine;

            object[] param;
            switch (ActionType)
            {
            case "VatReportSpain":
            {
                List <VatReportLine> lst = (List <VatReportLine>)dgVatReport.ItemsSource;
                if (lst == null)
                {
                    return;
                }
                var array = UnicontaClient.Pages.GL.Reports.VatSpain.calc(lst.ToArray());
                param = new object[] { api, array };
                AddDockItem(TabControls.VatReportSpain, param, "Modelo 303", null, closeIfOpened: true);
                break;
            }

            case "VatReportNorway":
            {
                if (vatReportSum == null)
                {
                    return;
                }
                param = new object[] { vatReportSum, fromDate, toDate };
                AddDockItem(TabControls.VatReportNorway, param, "Mva skattemeldingen", null, closeIfOpened: true);
                break;
            }

            case "VatReportDenmark":
            {
                if (vatReportSum == null)
                {
                    return;
                }
                param = new object[] { api, this.vatReportSum, fromDate, toDate };
                AddDockItem(TabControls.VatReportDenmark, param, "Momsopgørelse", null, closeIfOpened: true);
                break;
            }

            case "VatReportHolland":
            {
                if (vatReportSum == null)
                {
                    return;
                }
                param = new object[] { vatReportSum, fromDate, toDate };
                AddDockItem(TabControls.VatReportHolland, param, "BTW Aangifte", null, closeIfOpened: true);
                break;
            }

            case "VatReportEstonia":
            {
                if (vatReportSum == null)
                {
                    return;
                }
                param = new object[] { vatReportSum, fromDate, toDate };
                AddDockItem(TabControls.VatReportEstonia, param, "KM avaldus", null, closeIfOpened: true);
                break;
            }

            case "VatReportUnitedKingdom":
            {
                if (vatReportSum == null)
                {
                    return;
                }
                param = new object[] { vatReportSum, fromDate, toDate };
                AddDockItem(TabControls.VatReportUnitedKingdom, param, "VAT statement", null, closeIfOpened: true);
                break;
            }

            case "Transactions":
                if (lin?.Account != null)
                {
                    var dt = PropValuePair.GenereteWhereElements("Date", fromDate, CompareOperator.GreaterThanOrEqual);
                    dt.OrList[0].SecundaryValue = NumberConvert.ToString(toDate.Ticks);
                    var filter = new PropValuePair[]
                    {
                        dt,
                        PropValuePair.GenereteWhereElements("Account", lin.AccountNumber, CompareOperator.Equal),
                        PropValuePair.GenereteWhereElements("Vat", lin.Vat != null ? lin.Vat._Vat : "null", CompareOperator.Equal)
                    };
                    AddDockItem(TabControls.AccountsTransaction, new object[] { api, filter }, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Transactions"), lin.AccountNumber));
                }
                break;

            case "VatReportIceland":
            {
                if (vatReportSum == null)
                {
                    return;
                }
                param = new object[] { vatReportSum, fromDate, toDate };
                AddDockItem(TabControls.VatReportIceland, param, "VAT statement", null, closeIfOpened: true);
                break;
            }

            default:
                break;
            }
            gridRibbon_BaseActions(ActionType);
        }
        async Task LoadGrid()
        {
            fromDate = FromDate.DateTime;
            toDate   = ToDate.DateTime;

            List <PropValuePair> filter = new List <PropValuePair>();

            if (includeSubProject)
            {
                var propValuePairFolder = PropValuePair.GenereteParameter("IncludeSubProject", typeof(string), "1");
                filter.Add(propValuePairFolder);
            }
            if (InvoicedTrans > 0)
            {
                var propValuePairFolder = PropValuePair.GenereteParameter("InvoicedTrans", typeof(string), NumberConvert.ToString(InvoicedTrans));
                filter.Add(propValuePairFolder);
            }
            if (fromDate != DateTime.MinValue)
            {
                var propValuePairFolder = PropValuePair.GenereteParameter("FromDate", typeof(string), NumberConvert.ToString(fromDate.Ticks));
                filter.Add(propValuePairFolder);
            }
            if (toDate != DateTime.MinValue)
            {
                var propValuePairFolder = PropValuePair.GenereteParameter("ToDate", typeof(string), NumberConvert.ToString(toDate.Ticks));
                filter.Add(propValuePairFolder);
            }

            var api       = this.api;
            var CompanyId = api.CompanyId;

            var cats = api.CompanyEntity.GetCache(typeof(PrCategory)) ?? await api.CompanyEntity.LoadCache(typeof(PrCategory), api);

            var transTask = api.Query(new ProjectTransCategorySumClientLocal(), dgProjectTransCategorySum.masterRecords, filter);

            var trans = await transTask;

            if (trans == null)
            {
                dgProjectTransCategorySum.SetSource(null);
                return;
            }

            var len  = trans.Length;
            var sort = new ProjectTransCategorySort();

            Array.Sort(trans, sort);

            List <ProjectTransCategorySumClientLocal> extras = null, sums = new List <ProjectTransCategorySumClientLocal>();

            if (showBudget)
            {
                var budget = await api.Query(new ProjectBudgetCategorySumClient(), dgProjectTransCategorySum.masterRecords, filter);

                var key = new ProjectTransCategorySumClientLocal();
                foreach (var bc in budget)
                {
                    key._Project    = bc._Project;
                    key._PrCategory = bc._PrCategory;
                    var idx = Array.BinarySearch(trans, key, sort);
                    if (idx >= 0 && idx < len)
                    {
                        var t = trans[idx];
                        t._BudgetSales += bc._Sales;
                        t._BudgetCost  += bc._Cost;
                        t._BudgetQty   += bc._Qty;
                    }
                    else
                    {
                        var prTrans = new ProjectTransCategorySumClientLocal()
                        {
                            _CompanyId = CompanyId, _BudgetSales = bc._Sales, _BudgetCost = bc._Cost, _BudgetQty = bc._Qty, _PrCategory = bc._PrCategory, _Project = bc._Project
                        };

                        var cat = (PrCategory)cats.Get(bc._PrCategory);
                        prTrans._CatType = cat._CatType;
                        if (cat._CatType == CategoryType.Sum || cat._CatType == CategoryType.Header)
                        {
                            sums.Add(prTrans);
                        }
                        else
                        {
                            if (extras == null)
                            {
                                extras = new List <ProjectTransCategorySumClientLocal>();
                            }
                            extras.Add(prTrans);
                        }
                    }
                }
                if (extras != null)
                {
                    Array.Resize(ref trans, len + extras.Count);
                    foreach (var sum in extras)
                    {
                        trans[len++] = sum;
                    }
                    Array.Sort(trans, sort);
                    extras = null;
                }
            }

            foreach (var t in trans)
            {
                var cat = (PrCategory)cats.Get(t._PrCategory);
                if (cat != null && (cat._CatType == CategoryType.Revenue || cat._CatType == CategoryType.OnAccountInvoicing))
                {
                    t._InvoicedQty       = -t._Qty;
                    t._Invoiced          = -t._Sales;
                    t._BudgetInvoicedQty = -t._BudgetQty;
                    t._BudgetInvoiced    = -t._BudgetSales;

                    t._Qty         = 0;
                    t._BudgetQty   = 0;
                    t._Cost        = 0;
                    t._Sales       = 0;
                    t._BudgetCost  = 0;
                    t._BudgetSales = 0;
                }
            }

            int start = 0;

            while (start < len)
            {
                int    end;
                string ProjectNumber;
                if (master == null)
                {
                    ProjectNumber = trans[start]._Project;
                    for (end = start; (end < len && trans[end]._Project == ProjectNumber); end++)
                    {
                        ;
                    }
                }
                else
                {
                    ProjectNumber = ((Uniconta.DataModel.Project)master)._Number;
                    end           = len;
                }

                int headerAddedLast = 0;
                foreach (var cat in (PrCategory[])cats.GetKeyStrRecords)
                {
                    if (cat != null && (cat._CatType == CategoryType.Sum || cat._CatType == CategoryType.Header))
                    {
                        PropValuePair SumList = AccountSum.Generate(cat._Sum);
                        if (SumList != null)
                        {
                            double Sales = 0, Cost = 0, Qty = 0, BudgetSales = 0, BudgetQty = 0, BudgetCost = 0, Invoiced = 0, InvoicedBudget = 0, InvoicedQty = 0, InvoicedBudgetQty = 0;
                            for (int j = start; j < end; j++)
                            {
                                var Acc2 = trans[j];
                                if (AccountSum.IsIncluded(SumList, Acc2._PrCategory))
                                {
                                    Sales       += Acc2._Sales;
                                    Cost        += Acc2._Cost;
                                    Qty         += Acc2._Qty;
                                    BudgetCost  += Acc2._BudgetCost;
                                    BudgetSales += Acc2._BudgetSales;
                                    BudgetQty   += Acc2._BudgetQty;

                                    Invoiced          += Acc2._Invoiced;
                                    InvoicedBudget    += Acc2._BudgetInvoiced;
                                    InvoicedQty       += Acc2._InvoicedQty;
                                    InvoicedBudgetQty += Acc2._BudgetInvoicedQty;
                                }
                            }

                            var sum = new ProjectTransCategorySumClientLocal()
                            {
                                _CompanyId = CompanyId, _Project = ProjectNumber, _PrCategory = cat._Number, _CatType = cat._CatType
                            };

                            sum._Qty               = Math.Round(Qty, 2);
                            sum._BudgetQty         = Math.Round(BudgetQty, 2);
                            sum._Sales             = Math.Round(Sales, 2);
                            sum._Cost              = Math.Round(Cost, 2);
                            sum._BudgetSales       = Math.Round(BudgetSales, 2);
                            sum._BudgetCost        = Math.Round(BudgetCost, 2);
                            sum._Invoiced          = Math.Round(Invoiced, 2);
                            sum._BudgetInvoiced    = Math.Round(InvoicedBudget, 2);
                            sum._InvoicedQty       = Math.Round(InvoicedQty, 2);
                            sum._BudgetInvoicedQty = Math.Round(InvoicedBudgetQty, 2);
                            if (sum._Qty != 0 || sum._BudgetQty != 0 || sum._Sales != 0 || sum._Cost != 0 || sum._BudgetSales != 0 ||
                                sum._BudgetCost != 0 || sum._Invoiced != 0 || sum._BudgetInvoiced != 0 || sum._InvoicedQty != 0 || sum._BudgetInvoicedQty != 0)
                            {
                                sums.Add(sum);
                                headerAddedLast = 0;
                            }
                            else if (cat._CatType == CategoryType.Header)
                            {
                                sums.Add(sum);
                                headerAddedLast++;
                            }
                        }
                        else if (cat._CatType == CategoryType.Header)
                        {
                            sums.Add(new ProjectTransCategorySumClientLocal()
                            {
                                _CompanyId = CompanyId, _Project = ProjectNumber, _PrCategory = cat._Number, _CatType = CategoryType.Header
                            });
                            headerAddedLast++;
                        }
                    }
                }
                if (headerAddedLast > 0)
                {
                    sums.RemoveRange(sums.Count - headerAddedLast, headerAddedLast);
                }
                start = end;
            }

            if (sums.Count > 0)
            {
                Array.Resize(ref trans, len + sums.Count);
                foreach (var sum in sums)
                {
                    trans[len++] = sum;
                }
                Array.Sort(trans, sort);
            }

            dgProjectTransCategorySum.SetSource(trans);
        }
Ejemplo n.º 16
0
 void setColNameAndNumber(SelectedCriteria Selectedcol, int colnum)
 {
     Selectedcol.ColNo         = colnum;
     Selectedcol.ColNameNumber = string.Concat(Uniconta.ClientTools.Localization.lookup("Name"), " (", NumberConvert.ToString(colnum), ")");
 }
Ejemplo n.º 17
0
 protected override void SyncEntityMasterRowChanged(UnicontaBaseEntity args)
 {
     dgDebtorOrderProjectLineGrid.UpdateMaster(args);
     debtorOrder = dgDebtorOrderProjectLineGrid.masterRecord as Uniconta.DataModel.DCOrder;
     if (debtorOrder != null)
     {
         api.Read((UnicontaBaseEntity)debtorOrder);
         SetHeader(string.Concat(Uniconta.ClientTools.Localization.lookup("ProjectAdjustments"), ": ", NumberConvert.ToString(debtorOrder._OrderNumber)));
     }
     InitQuery();
 }
Ejemplo n.º 18
0
        private void ProductionMultiOrderLine_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var rec = sender as ProductionOrderLineClient;

            switch (e.PropertyName)
            {
            case "Item":
                if (items != null)
                {
                    var selectedItem = (InvItem)items.Get(rec._Item);
                    if (selectedItem != null)
                    {
                        if (selectedItem._AlternativeItem != null && selectedItem._UseAlternative == UseAlternativeItem.Always)
                        {
                            var altItem = (InvItem)items.Get(selectedItem._AlternativeItem);
                            if (altItem != null && altItem._AlternativeItem == null)
                            {
                                rec.Item = selectedItem._AlternativeItem;
                                return;
                            }
                        }
                        var lookup = SetPriceLookup(rec);
                        if (lookup != null)
                        {
                            lookup.UseCustomerPrices = false;
                        }
                        if (selectedItem._SalesQty != 0d)
                        {
                            rec.Qty = selectedItem._SalesQty;
                        }
                        else if (api.CompanyEntity._PurchaseLineOne)
                        {
                            rec.Qty = 1d;
                        }
                        rec.SetItemValues(selectedItem, api.CompanyEntity._PurchaseLineStorage);
                        if (lookup != null)
                        {
                            lookup.UseCustomerPrices = true;
                            lookup.SetPriceFromItem(rec, selectedItem);
                        }
                        else if (selectedItem._PurchasePrice != 0)
                        {
                            rec.Price = selectedItem._PurchasePrice;
                        }
                        else
                        {
                            rec.Price = selectedItem._CostPrice;
                        }
                        TableField.SetUserFieldsFromRecord(selectedItem, rec);
                        if (selectedItem._Blocked)
                        {
                            UtilDisplay.ShowErrorCode(ErrorCodes.ItemIsOnHold, null);
                        }
                    }
                }
                break;

            case "OrderNumber":
                var order = (ProductionOrder)productionOrders?.Get(NumberConvert.ToString(rec._OrderNumber));
                if (order != null)
                {
                    rec.SetMaster(order);
                    SetPriceLookup(rec);
                }
                break;

            case "Qty":
                UpdatePrice(rec);
                break;

            case "Warehouse":
                if (warehouse != null)
                {
                    var selected = (InvWarehouse)warehouse.Get(rec._Warehouse);
                    SetLocation(selected, rec);
                }
                break;

            case "Location":
                if (string.IsNullOrEmpty(rec._Warehouse))
                {
                    rec._Location = null;
                }
                break;

            case "EAN":
                UnicontaClient.Pages.DebtorOfferLines.FindOnEAN(rec, this.items, api);
                break;

            case "Variant1":
            case "Variant2":
            case "Variant3":
            case "Variant4":
            case "Variant5":
                UpdatePrice(rec);
                break;
            }
        }
Ejemplo n.º 19
0
        public void SaveBalance()
        {
            if (objBalance == null || objBalance.RowId == 0 || objBalance.CompanyId != api.CompanyId /* For balance copy from other company */)
            {
                if (itemsBalance == null)
                {
                    itemsBalance = new ObservableCollection <Balance>();
                }
                if (objBalance == null)
                {
                    objBalance = new Balance();
                    itemsBalance.Add(objBalance);
                }

                setbalanceFields(objBalance);
                SetBalanceDimUsed(objBalance);
                // if we can't save it, we still generate the colums, so he can run it
                balanceCollist = null;
                var cols = new List <BalanceColumn>(objCriteria.selectedCriteria.Count);
                int i    = 0;
                foreach (var crit in objCriteria.selectedCriteria)
                {
                    cols.Add(CreateCriteraColumn(crit, i++));
                }

                cbBalance.SelectedIndex = itemsBalance.Count - 1;
                objBalance.ColumnList   = cols;

                if (objBalance._Name == null)
                {
                    objBalance._Name = Uniconta.ClientTools.Localization.lookup("Balance") + NumberConvert.ToString(itemsBalance.Count);
                }

                objBalance.SetMaster(api.CompanyEntity);
                api.InsertNoResponse(objBalance);
                UpdateBalancelist(cbBalance.SelectedIndex);
            }
            else
            {
                update();
                UpdateBalancelist(cbBalance.SelectedIndex);
            }
        }