Пример #1
0
        private void Initialize()
        {
            objPageHdr = new PrintReportHeader();
            tranApi    = new ReportAPI(api);

            localMenu.dataGrid = dgGLTran;
            dgGLTran.api       = api;
            if (!api.CompanyEntity.HasDecimals)
            {
                Debit.HasDecimals = Credit.HasDecimals = Amount.HasDecimals = AmountBase.HasDecimals = AmountVat.HasDecimals = false;
            }
            SetRibbonControl(localMenu, dgGLTran);
            gridControl.BusyIndicator       = busyIndicator;
            cmbShowDimOnPrimo.ItemsSource   = new string[] { Uniconta.ClientTools.Localization.lookup("OnePrimo"), Uniconta.ClientTools.Localization.lookup("PrimoPerDim"), Uniconta.ClientTools.Localization.lookup("NoPrimo") };
            cmbShowDimOnPrimo.SelectedIndex = setShowDimOnPrimoIndex;
            if (DefaultFromDate == DateTime.MinValue)
            {
                var Now = BasePage.GetSystemDefaultDate();
                DefaultToDate   = Now;
                DefaultFromDate = Now.AddDays(1 - Now.Day).AddMonths(-2);
            }
            cbxAscending.IsChecked = api.session.Preference.TransactionReport_isAscending;
            txtDateTo.DateTime     = DefaultToDate;
            txtDateFrm.DateTime    = DefaultFromDate;

            localMenu.OnItemClicked += localMenu_OnItemClicked;
            dgGLTran.RowDoubleClick += DgGLTran_RowDoubleClick;
            dgGLTran.ShowTotalSummary();
            InitialLoad();
        }
        static public void ExecuteDebtorCollection(CrudAPI Api, BusyIndicator busyIndicator, IEnumerable <DCTransOpen> dcTransOpenList, IEnumerable <double> feelist, IEnumerable <double> changelist, bool isCurrencyReport, DebtorEmailType emailType,
                                                   string emails = null, bool onlyThisEmail = false, bool isAddInterest = false)
        {
            var rapi = new ReportAPI(Api);

            var cwDateSelector = new CWDateSelector();

#if !SILVERLIGHT
            cwDateSelector.DialogTableId = 2000000025;
#endif
            cwDateSelector.Closed += async delegate
            {
                if (cwDateSelector.DialogResult == true)
                {
                    busyIndicator.IsBusy      = true;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    var result = await rapi.DebtorCollection(dcTransOpenList, feelist, changelist, cwDateSelector.SelectedDate, emailType, isCurrencyReport, emails, onlyThisEmail);

                    busyIndicator.IsBusy = false;

                    if (result == ErrorCodes.Succes)
                    {
                        UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("SendEmailMsgOBJ"), isAddInterest ? Uniconta.ClientTools.Localization.lookup("InterestNote") : Uniconta.ClientTools.Localization.lookup("CollectionLetter")),
                                                Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK);
                    }
                    else
                    {
                        UtilDisplay.ShowErrorCode(result);
                    }
                }
            };
            cwDateSelector.Show();
        }
Пример #3
0
        public ActionResult AddReport([FromBody] ReportAPI report)
        {
            var result = _reportService.Add(new ReportDTO {
                Name = report.Name
            });

            return(Ok(result));
        }
Пример #4
0
        void Init(GLClosingSheet sheet)
        {
            this.DataContext = this;
            InitializeComponent();
            cmbFromAccount.api = cmbToAccount.api = api;
            SetRibbonControl(localMenu, dgGLTrans);
            localMenu.OnItemClicked += LocalMenu_OnItemClicked;

            if (AccountStatement.DefaultFromDate == DateTime.MinValue)
            {
                var now = BasePage.GetSystemDefaultDate();
                AccountStatement.DefaultToDate   = now;
                AccountStatement.DefaultFromDate = now.AddDays(1 - now.Day).AddMonths(-2);
            }
            var Pref = api.session.Preference;

            cbxAscending.IsChecked = Pref.Debtor_isAscending;
            cbxSkipBlank.IsChecked = Pref.Debtor_skipBlank;
#if !SILVERLIGHT
            cbxPageBreak.IsChecked = pageBreak;
            dgGLTrans.PageBreak    = pageBreak;
#endif
            cmbShowDimOnPrimo.ItemsSource   = new string[] { Uniconta.ClientTools.Localization.lookup("OnePrimo"), Uniconta.ClientTools.Localization.lookup("PrimoPerDim"), Uniconta.ClientTools.Localization.lookup("NoPrimo") };
            cmbShowDimOnPrimo.SelectedIndex = setShowDimOnPrimoIndex;
            txtDateTo.DateTime  = AccountStatement.DefaultToDate;
            txtDateFrm.DateTime = AccountStatement.DefaultFromDate;
            GetMenuItem();

            var Comp = api.CompanyEntity;
            if (Comp.RoundTo100)
            {
                Debit.HasDecimals = Credit.HasDecimals = Amount.HasDecimals = AmountBase.HasDecimals = AmountVat.HasDecimals = false;
            }

            accountCache = Comp.GetCache(typeof(Uniconta.DataModel.GLAccount));
            InitialLoad();
            dgGLTrans.RowDoubleClick      += DgGLTrans_RowDoubleClick;
            dgGLTrans.SelectedItemChanged += DgGLTrans_SelectedItemChanged;
            dgGLTrans.MasterRowExpanded   += DgGLTrans_MasterRowExpanded;
            dgGLTrans.MasterRowCollapsed  += DgGLTrans_MasterRowCollapsed;
            dgGLTrans.ShowTotalSummary();
#if SILVERLIGHT
            childDgGLTrans.CurrentItemChanged += ChildDgDebtorTrans_CurrentItemChanged;
#endif
            transApi = new Uniconta.API.GeneralLedger.ReportAPI(api);
            transApi.SetClosingSheet(sheet);

            if (_master != null)
            {
                cmbFromAccount.EditValue = _master._Account;
                cmbToAccount.EditValue   = _master._Account;
                LoadGLTrans();
            }
        }
        public async override Task InitQuery()
        {
            if (reportApi == null)
            {
                reportApi = new ReportAPI(api);
            }

            dgInvStatsGrid.ItemsSource = null;
            busyIndicator.IsBusy       = true;
            var invStatsArray = (InvStatistickClient[])await reportApi.ItemAccountStat(new InvStatistickClient(), txtDateFrm.DateTime, txtDateTo.DateTime);

            dgInvStatsGrid.ItemsSource = invStatsArray.ToList();
            busyIndicator.IsBusy       = false;
            dgInvStatsGrid.Visibility  = Visibility.Visible;
        }
        private void Initialize(UnicontaBaseEntity master)
        {
            InitializeComponent();
            rApi        = new ReportAPI(api);
            this.master = new CreditorTransClient();
            StreamingManager.Copy(master, this.master);
            localMenu.dataGrid = dgSettlements;
            dgSettlements.api  = api;
            SetRibbonControl(localMenu, dgSettlements);
            localMenu.OnItemClicked    += localMenu_OnItemClicked;
            dgSettlements.BusyIndicator = busyIndicator;
            var Comp = api.CompanyEntity;

            if (Comp.RoundTo100)
            {
                Amount.HasDecimals = Remaining.HasDecimals = Debit.HasDecimals = Credit.HasDecimals = false;
            }
        }
Пример #7
0
 public GLAccountClosingSheetPage(UnicontaBaseEntity master)
     : base(master)
 {
     InitializeComponent();
     this.DataContext = this;
     masterRecord     = master as GLClosingSheet;
     postingApi       = new PostingAPI(api);
     rApi             = new Uniconta.API.GeneralLedger.ReportAPI(this.api);
     SetRibbonControl(localMenu, dgGLTable);
     dgGLTable.api      = api;
     localMenu.dataGrid = dgGLTable;
     dgGLTable.UpdateMaster(master);
     localMenu.OnItemClicked  += localMenu_OnItemClicked;
     dgGLTable.RowDoubleClick += dgGLTable_RowDoubleClick;
     dgGLTable.BusyIndicator   = busyIndicator;
     dgGLTable.View.DataControl.CurrentItemChanged += DataControl_CurrentItemChanged;
     ((TableView)dgGLTable.View).RowStyle           = Application.Current.Resources["RowStyle"] as Style;
 }
        public async override Task InitQuery()
        {
            if (reportApi == null)
            {
                reportApi = new ReportAPI(api);
            }

            dgInvStatsGrid.ItemsSource = null;
            busyIndicator.IsBusy       = true;
            InvStatistickClient[] invStatsArray;
            if (_master == null)
            {
                invStatsArray = (InvStatistickClient[])await reportApi.ItemStat(new InvStatistickClient(), txtDateFrm.DateTime, txtDateTo.DateTime);
            }
            else
            {
                invStatsArray = (InvStatistickClient[])await reportApi.ItemStatDate(new InvStatistickClient(), txtDateFrm.DateTime, txtDateTo.DateTime, (InvItemClient)_master);
            }
            dgInvStatsGrid.ItemsSource = invStatsArray?.ToList();
            busyIndicator.IsBusy       = false;
            dgInvStatsGrid.Visibility  = Visibility.Visible;
        }
Пример #9
0
        private async void LoadVatReport()
        {
            DateTime FromDate, ToDate;

            if (txtDateFrm.Text == string.Empty)
            {
                FromDate = DateTime.Today;
                FromDate = FromDate.AddDays(1 - FromDate.Day); // first day in current month
            }
            else
            {
                FromDate = localFromDate = txtDateFrm.DateTime.Date;
            }
            if (txtDateTo.Text == string.Empty)
            {
                ToDate = DateTime.Today.AddMonths(1);
                ToDate = ToDate.AddDays(-ToDate.Day); // last day in current month
            }
            else
            {
                ToDate = localToDate = txtDateTo.DateTime.Date;
            }

            busyIndicator.IsBusy = true;

            var    qapi    = api;
            var    country = qapi.CompanyEntity._CountryId;
            var    rapi    = new ReportAPI(qapi);
            string journal = cmbJournal.Text;
            var    vatTask = rapi.VatCodeSum(FromDate, ToDate, journal);

            SQLCache accounts = qapi.GetCache(typeof(Uniconta.DataModel.GLAccount)) ?? await qapi.LoadCache(typeof(Uniconta.DataModel.GLAccount));

            SQLCache vats = qapi.GetCache(typeof(Uniconta.DataModel.GLVat)) ?? await qapi.LoadCache(typeof(Uniconta.DataModel.GLVat));

            SQLCache vattypes = qapi.GetCache(typeof(Uniconta.DataModel.GLVatType)) ?? await qapi.LoadCache(typeof(Uniconta.DataModel.GLVatType));

            FinancialBalance[] sumVat = await vatTask;
            if (sumVat == null || accounts == null || vats == null || vattypes == null)
            {
                busyIndicator.IsBusy = false;
                UtilDisplay.ShowErrorCode(rapi.LastError);
                return;
            }

            Array.Sort(sumVat, new AccountSorter());

            VatReportLine v;
            var           lst = new List <VatReportLine>(sumVat.Length);

            int  decm       = 2;
            bool RoundTo100 = false;

            if (!qapi.CompanyEntity.HasDecimals)
            {
                CalculatedVAT.HasDecimals = PostedVAT.HasDecimals = WithoutVAT.HasDecimals = Accumulated.HasDecimals = false;
                RoundTo100 = true;
                decm       = 0;
            }

            var countrySelected = (CountryCode)Math.Max(0, vatCountry.SelectedIndex);

            var       AccsFound = new HashSet <int>();
            GLAccount Account;
            GLVat     Vat;
            int       i;
            bool      HasOffsetType0 = false, HasOffsetType1 = false;
            int       PrevAccount = 0;

            for (i = 0; (i < sumVat.Length); i++)
            {
                var sum = sumVat[i];
                Account = (GLAccount)accounts.Get(sum.AccountRowId);
                if (Account == null) // || Account._SystemAccount == (byte)SystemAccountTypes.SalesTaxOffset)
                {
                    continue;
                }
                //if (sum._Debit == 0 && sum._Credit == 0)
                //    continue;

                Vat = (GLVat)vats.Get(sum.VatRowId);
                if (Vat == null)
                {
                    continue;
                }

                var acStr = Account._Account;
                v = new VatReportLine();
                v.AmountWithVat = sum.Debit;
                v._PostedVAT    = sum.Credit;
                v._BaseVAT      = sum.AmountBase;

                v.AccountNumber = acStr;
                v.Account       = Account;
                v.AccountIsVat  = Account._SystemAccount == (byte)SystemAccountTypes.SalesTaxPayable || Account._SystemAccount == (byte)SystemAccountTypes.SalesTaxReceiveable ? (byte)1 : (byte)0;

                if (Vat._Account == acStr || Vat._OffsetAccount == acStr)
                {
                    if (Vat._Account == acStr)
                    {
                        v.AccountIsVat    = 1;
                        v.IsOffsetAccount = 0;
                    }
                    else
                    {
                        v.AccountIsVat    = 1;
                        v.IsOffsetAccount = 1;
                        if (Vat._VatType == 0)
                        {
                            HasOffsetType0 = true;
                        }
                        else
                        {
                            HasOffsetType1 = true;
                        }
                    }
                }
                else
                {
                    foreach (var va in (IEnumerable <GLVat>)vats.GetNotNullArray)
                    {
                        if (va._Account == acStr)
                        {
                            v.AccountIsVat    = 1;
                            v.IsOffsetAccount = 0;
                            break;
                        }
                        if (va._OffsetAccount == acStr)
                        {
                            v.AccountIsVat    = 1;
                            v.IsOffsetAccount = 1;
                            if (va._VatType == 0)
                            {
                                HasOffsetType0 = true;
                            }
                            else
                            {
                                HasOffsetType1 = true;
                            }
                            // do not break in case we foind the same account as _Account
                        }
                    }
                }

                v.Vat     = Vat;
                v.VatType = (byte)Vat._VatType;
                if (v.IsOffsetAccount == 1 && Vat._OffsetVatOperation != null)
                {
                    v._VatOperation = (byte)vattypes.Get(Vat._OffsetVatOperation).RowId;
                }
                else
                {
                    v._VatOperation = sum.VatOperation != 0 ? sum.VatOperation : Vat._VatOperationCode;
                }
                v._CalculatedVAT = Vat.VatAmount1(v.AmountWithVat, FromDate, RoundTo100, GLVatCalculationMethod.Netto);

                v.FromDate = FromDate;
                v.CalcRate(RoundTo100);

                var vattp = (GLVatType)vattypes.Get(v._VatOperation);
                if (vattp != null)
                {
                    v.VatOpr       = vattp;
                    v.vatOperation = vattp._Code;
                    v.BaseVatText  = vattp._Name;
                }
                lst.Add(v);

                if (PrevAccount != sum.AccountRowId)
                {
                    PrevAccount = sum.AccountRowId;
                    AccsFound.Add(sum.AccountRowId);
                }
            }

            foreach (var acc in (GLAccount[])accounts.GetNotNullArray)
            {
                if (acc._Vat != null)
                {
                    Vat = (GLVat)vats.Get(acc._Vat);
                    if (Vat == null)
                    {
                        continue;
                    }
                    if (countrySelected != 0 && countrySelected != (Vat._VatCountry != 0 ? Vat._VatCountry : country))
                    {
                        continue;
                    }
                    AccsFound.Add(acc.RowId);
                }
            }

            List <int> AccLst = AccsFound.ToList();

            AccsFound.Clear();

            FinancialBalance[] AccTotals = await rapi.GenerateTotal(AccLst, FromDate, ToDate, journal, null, 0, true, false);

            SQLCacheTemplate <FinancialBalance> AccLookup = null;

            if (AccTotals != null && AccTotals.Length > 0)
            {
                AccLookup = new SQLCacheTemplate <FinancialBalance>(AccTotals, false);
            }

            lst.Sort(new VatAccountSort());

            FinancialBalance AccTotal;
            int           AccountRowId = 0;
            double        AmountDif    = 0d;
            VatReportLine vDif         = new VatReportLine();

            for (i = lst.Count; (--i >= 0);)
            {
                v = lst[i];
                if (v.Account.RowId != AccountRowId)
                {
                    if (AmountDif > 0.005d || AmountDif < -0.005d)
                    {
                        vDif.AmountWithout = GLVat.Round(AmountDif);
                        lst.Add(vDif);
                        vDif = new VatReportLine();
                    }

                    AccountRowId = v.Account.RowId;
                    AccTotal     = AccLookup?.Get(AccountRowId);
                    if (AccTotal != null)
                    {
                        AmountDif = (AccTotal._Debit - AccTotal._Credit) / 100d;
                    }
                    else
                    {
                        AmountDif = 0d;
                    }

                    AccsFound.Add(AccountRowId);
                }
                AmountDif           -= v.AmountWithVat;
                vDif.Account         = v.Account;
                vDif.AccountNumber   = v.AccountNumber;
                vDif.VatType         = v.VatType;
                vDif.AccountIsVat    = v.AccountIsVat;
                vDif.IsOffsetAccount = v.IsOffsetAccount;
            }

            if (AmountDif > 0.005d || AmountDif < -0.005d)
            {
                vDif.AmountWithout = GLVat.Round(AmountDif);
                lst.Add(vDif);
            }

            if (AccLookup != null)
            {
                // Add account, that has a VAT-code but no transactios with VAT.
                for (i = 0; (i < AccTotals.Length); i++)
                {
                    AccTotal = AccTotals[i];
                    if (!AccsFound.Contains(AccTotal.RowId) && (AccTotal._Debit - AccTotal._Credit) != 0)
                    {
                        Account = (GLAccount)accounts.Get(AccTotal.RowId);
                        if (Account?._Vat == null)
                        {
                            continue;
                        }
                        Vat = (GLVat)vats.Get(Account._Vat);
                        if (Vat == null)
                        {
                            continue;
                        }

                        vDif = new VatReportLine();
                        vDif.AmountWithout = (AccTotal._Debit - AccTotal._Credit) / 100d;
                        vDif.Account       = Account;
                        vDif.AccountNumber = Account._Account;
                        vDif.VatType       = (byte)Vat._VatType;
                        lst.Add(vDif);
                    }
                }
            }

            if (countrySelected != 0)
            {
                for (i = lst.Count; (--i >= 0);)
                {
                    Vat = (GLVat)vats.Get(lst[i].VatCode);
                    if (Vat != null)
                    {
                        if (countrySelected != (Vat._VatCountry != 0 ? Vat._VatCountry : country))
                        {
                            lst.RemoveAt(i);
                            continue;
                        }
                    }
                }
            }

            vDif = null;

            for (int k = 0; (k < 4); k++)
            {
                string helptext;
                if (k == 0)
                {
                    helptext = "sales";
                }
                else if (k == 1)
                {
                    helptext = "buy";
                }
                else if (k == 2)
                {
                    helptext = "sales vat";
                }
                else
                {
                    helptext = "buy vat";
                }

                for (int n = 0; n < 3; n++)
                {
                    vDif              = new VatReportLine();
                    vDif.helptext     = helptext;
                    vDif.Order        = (n > 0) ? n : -1; // header, total, empty
                    vDif.VatType      = (byte)(k % 2);
                    vDif.AccountIsVat = (byte)(k / 2);
                    vDif.isvatotal    = (k >= 2 && n == 1);
                    lst.Add(vDif);

                    if (vDif.AccountIsVat == 1)
                    {
                        if ((HasOffsetType0 && vDif.VatType == 0) || (HasOffsetType1 && vDif.VatType == 1))
                        {
                            vDif                 = new VatReportLine();
                            vDif.helptext        = "import vat";
                            vDif.Order           = (n > 0) ? n : -1; // header, total, empty
                            vDif.VatType         = (byte)(k % 2);
                            vDif.AccountIsVat    = 1;
                            vDif.IsOffsetAccount = 1;
                            vDif.isvatotal       = true;
                            lst.Add(vDif);
                        }
                    }
                }
            }
            vDif = null;

            lst.Sort(new VatTotalsSort());
            double d1 = 0d, d2 = 0d, d3 = 0d, d4 = 0d;

            double[] VatOperationValues = new double[256];
            double[] VatOperationBases  = new double[256];

            double[] VatValues          = new double[256];
            double[] VatBases           = new double[256];

            VatSumOperationReport[] vatReportSum = new VatSumOperationReport[127];

            for (i = 0; (i < lst.Count); i++)
            {
                v = lst[i];

                if (v.Order == 1) // total
                {
                    v.AmountWithVat = Math.Round(d1, decm);
                    var AmountWithout = Math.Round(d2, decm);
                    v.AmountWithout  = AmountWithout;
                    v._CalculatedVAT = Math.Round(d3, decm);
                    v._PostedVAT     = Math.Round(d4, decm);
                    d1 = d2 = d3 = d4 = 0d;

                    if (country == CountryCode.Denmark && AmountWithout != 0 && v.AccountIsVat == 1)
                    {
                        if (v.IsOffsetAccount == 0)
                        {
                            // here we sum up the amount without vatcodes
                            if (v.VatType == 0)
                            {
                                var sumLine = CreateSum(vatReportSum, 33);
                                sumLine._Amount -= AmountWithout;
                            }
                            else
                            {
                                var sumLine = CreateSum(vatReportSum, 23);
                                sumLine._Amount += AmountWithout;
                                sumLine          = CreateSum(vatReportSum, 31);
                                sumLine._Amount += AmountWithout;
                            }
                        }
                        else
                        {
                            if (v.VatType == 1)
                            {
                                var sumLine = CreateSum(vatReportSum, 34);
                                sumLine._Amount -= AmountWithout;
                            }
                        }
                    }
                }
                else
                {
                    d1 += v.AmountWithVat;
                    d2 += v.AmountWithout;
                    d3 += v._CalculatedVAT;
                    d4 += v._PostedVAT;

                    if (v.AccountIsVat == 1)
                    {
                        if (v.IsOffsetAccount == 0)
                        {
                            VatOperationValues[v._VatOperation] += v.AmountWithVat;
                            if (v.Vat != null)
                            {
                                VatValues[v.Vat.RowId] += v.AmountWithVat;
                            }
                        }
                    }
                    else
                    {
                        VatOperationBases[v._VatOperation] += v.AmountWithVat;
                        if (v.Vat != null)
                        {
                            VatBases[v.Vat.RowId] += v.AmountWithVat;
                        }
                    }
                }
            }

            vDif      = new VatReportLine();
            vDif.Text = string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("FinalVatStatus"), Uniconta.ClientTools.Localization.lookup("AmountBase"), Uniconta.ClientTools.Localization.lookup("VATamount"));
            lst.Add(vDif);

            foreach (var c in (GLVatType[])vattypes.GetNotNullArray)
            {
                if (c == null)
                {
                    continue;
                }

                vDif = new VatReportLine();
                vDif.vatOperation  = c._Code;
                vDif._Rate         = c._Pct1;
                vDif.Text          = string.Concat(c._Code, ", ", c._Name);
                vDif.AmountWithVat = VatOperationBases[c._RowNo];
                vDif._PostedVAT    = VatOperationValues[c._RowNo];
                vDif.AccountIsVat  = 1;
                lst.Add(vDif);

                int pos = c._Position1;
                if (pos > 0)
                {
                    UpdateSum(vatReportSum, vDif, pos, c._Position2, c._Position3);
                }
                pos = c._Position4;
                if (pos > 0)
                {
                    UpdateSum(vatReportSum, vDif, pos, c._Position5, c._Position6);
                }
                pos = c._Position7;
                if (pos > 0)
                {
                    UpdateSum(vatReportSum, vDif, pos, c._Position8, c._Position9);
                }
                pos = c._Position10;
                if (pos > 0)
                {
                    UpdateSum(vatReportSum, vDif, pos, c._Position11, c._Position12);
                }
                pos = c._Position13;
                if (pos > 0)
                {
                    UpdateSum(vatReportSum, vDif, pos, c._Position14, c._Position15);
                }
            }

            List <VatReportLine> vatlst = new List <VatReportLine>();

            this.vatlst = vatlst;

            for (int k = 0; (k < 2); k++)
            {
                vDif      = new VatReportLine();
                vDif.Text = string.Empty;
                lst.Add(vDif);

                vDif              = new VatReportLine();
                vDif.VatType      = (byte)k;
                vDif.Order        = -1;
                vDif.AccountIsVat = 1;
                lst.Add(vDif);

                foreach (var c in (GLVat[])vats.GetNotNullArray)
                {
                    if (c != null && (int)c._VatType == k)
                    {
                        if (countrySelected != 0 && countrySelected != (c._VatCountry != 0 ? c._VatCountry : country))
                        {
                            continue;
                        }

                        vDif               = new VatReportLine();
                        vDif.Vat           = c;
                        vDif.Text          = string.Concat(c._Vat, ", ", c._Name);
                        vDif.AmountWithVat = VatBases[c.RowId];
                        vDif._PostedVAT    = VatValues[c.RowId];
                        vDif.AccountIsVat  = 1;
                        vDif.FromDate      = FromDate;
                        vDif.CalcRate(RoundTo100);
                        lst.Add(vDif);
                        vatlst.Add(vDif);
                    }
                }
            }

            dgVatReport.ItemsSource = lst;
            if (lst.Count > 0)
            {
                SetMenuItem();
            }

            if (country == CountryCode.Denmark)
            {
                AccLst.Clear();
                foreach (var acc in (GLAccount[])accounts.GetNotNullArray)
                {
                    if (acc._SystemAccount == (byte)SystemAccountTypes.OtherTax)
                    {
                        AccLst.Add(acc.RowId);
                    }
                }
                if (AccLst != null && AccLst.Count > 0)
                {
                    AccTotals = await rapi.GenerateTotal(AccLst, FromDate, ToDate);

                    if (AccTotals != null && AccTotals.Length > 0)
                    {
                        var otherTaxList = new ReportDataDenmark[AccTotals.Length];
                        i = 14;
                        foreach (var acTot in AccTotals)
                        {
                            var Acc = accounts.Get(acTot.AccountRowId);
                            var lin = new VatSumOperationReport()
                            {
                                _Text   = Acc.KeyName,
                                _Amount = (acTot._Debit - acTot._Credit) / 100d,
                                _Line   = i
                            };
                            vatReportSum[i] = lin;
                            i++;
                            if (i == 19)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            for (i = vatReportSumSize + 1; (--i >= 1);)
            {
                if (vatReportSum[i] == null)
                {
                    vatReportSum[i] = new VatSumOperationReport()
                    {
                        _Line = i
                    }
                }
            }
            ;

            this.vatReportSum = vatReportSum.Where(r => r != null).ToList();

            dgVatReport.Visibility = Visibility.Visible;
            busyIndicator.IsBusy   = false;
        }
Пример #10
0
        private async Task LoadInvSeriesBatch()
        {
            setExpandAndCollapse(true);
            statementlist.Clear();
            busyIndicator.IsBusy = true;

            var ItemCache = api.GetCache(typeof(Uniconta.DataModel.InvItem)) ?? await api.LoadCache(typeof(Uniconta.DataModel.InvItem));

            var tranApi   = new ReportAPI(api);
            var lstEntity = await tranApi.GetSeriaBatchInBOM(master as InvTransClient, new InvSerieBatchClient());

            if (lstEntity != null)
            {
                string curItem = " ";
                InvItemTransStatementList  ob = null;
                List <InvSeriesBatchTotal> tlst = null;
                double SumCost = 0d, SumQty = 0d;
                foreach (var s in lstEntity)
                {
                    var master = s.Master as InvTransClient;
                    if (master._Item != curItem)
                    {
                        var ac = (InvItem)ItemCache.Get(master._Item);
                        if (ac == null)
                        {
                            continue;
                        }

                        ob             = new InvItemTransStatementList();
                        curItem        = ac._Item;
                        ob.ItemNumber  = ac._Item;
                        ob.Name        = ac._Name;
                        ob.ItemType    = AppEnums.ItemType.ToString(ac._ItemType);
                        tlst           = new List <InvSeriesBatchTotal>(s.Details.Length);
                        ob.ChildRecord = tlst;
                        SumCost        = SumQty = 0d;
                        foreach (var detail in s.Details)
                        {
                            var child  = detail as InvSerieBatchClient;
                            var child1 = new InvSeriesBatchTotal();
                            UserMenuClientList userMenu = new UserMenuClientList();
                            StreamingManager.Copy(child, child1);
                            child._Item = curItem;
                            var costLine = (child._CostPrice * child._Qty);
                            SumCost        += costLine;
                            child1._SumCost = costLine;

                            SumQty        += child._Qty;
                            child1._SumQty = child._Qty;
                            tlst.Add(child1);
                            if (ob._SerialNumbers == null)
                            {
                                ob._SerialNumbers = child._Number;
                            }
                            else
                            {
                                ob._SerialNumbers = string.Format("{0}, {1}", ob._SerialNumbers, child._Number);
                            }
                        }
                        ob._SumCost = SumCost;
                        ob._SumQty  = SumQty;
                        statementlist.Add(ob);
                    }
                }
            }

            dgInvSeriesBatch.ItemsSource = statementlist;
            dgInvSeriesBatch.Visibility  = Visibility.Visible;
            busyIndicator.IsBusy         = false;
        }