Esempio n. 1
0
        public TMPlanningCheckPage(BaseAPI Api) :
            base(Api, string.Empty)
        {
            InitializeComponent();
            SetRibbonControl(localMenu, dgTMPlanningCheckGrid);
            dgTMPlanningCheckGrid.api = api;
            localMenu.OnItemClicked  += LocalMenu_OnItemClicked;

            dgTMPlanningCheckGrid.BusyIndicator = busyIndicator;


            projects         = api.GetCache <Uniconta.DataModel.Project>();
            debtors          = api.GetCache <Uniconta.DataModel.Debtor>();
            budgetGrpCache   = api.GetCache(typeof(Uniconta.DataModel.ProjectBudgetGroup));
            prWorkSpaceCache = api.GetCache <Uniconta.DataModel.PrWorkSpace>();

            cmbBudgetGroup.api = cmbWorkSpace.api = api;
            SetBudgetGroup();
            cmbBudgetGroup.Text      = budgetGroup;
            cmbWorkSpace.ItemsSource = prWorkSpaceCache;
            cmbWorkSpace.Text        = workSpace;

            if (!api.CompanyEntity.ProjectTask)
            {
                cmbWorkSpace.Visibility = Visibility.Collapsed;
                lblWorkSpace.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 2
0
        private void InitPage(UnicontaBaseEntity master = null)
        {
            SetRibbonControl(localMenu, dgProjectBudgetGrid);
            dgProjectBudgetGrid.api = api;
            if (master == null)
            {
                Project.Visible = true;
            }
            else
            {
                Project.Visible = false;
                dgProjectBudgetGrid.UpdateMaster(master);
            }
            dgProjectBudgetGrid.BusyIndicator = busyIndicator;
            localMenu.OnItemClicked          += localMenu_OnItemClicked;

            projectCache     = api.GetCache <Uniconta.ClientTools.DataModel.ProjectClient>();
            payrollCache     = api.GetCache <Uniconta.DataModel.EmpPayrollCategory>();
            prCategoryCache  = api.GetCache <Uniconta.DataModel.PrCategory>();
            projGroupCache   = api.GetCache <Uniconta.DataModel.ProjectGroup>();
            budgetGroupCache = api.GetCache <Uniconta.DataModel.ProjectBudgetGroup>();

            employeeCache = api.GetCache <Uniconta.DataModel.Employee>();

            StartLoadCache();
        }
Esempio n. 3
0
        private void InitPage()
        {
            InitializeComponent();
            localMenu.dataGrid = dgEUSalesWithoutVATGrid;
            SetRibbonControl(localMenu, dgEUSalesWithoutVATGrid);
            localMenu.OnItemClicked              += localMenu_OnItemClicked;
            dgEUSalesWithoutVATGrid.api           = api;
            dgEUSalesWithoutVATGrid.BusyIndicator = busyIndicator;
            dgEUSalesWithoutVATGrid.ShowTotalSummary();
            txtDateFrm.DateTime           = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 01);
            txtDateTo.DateTime            = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month));
            TriangularTradeAmount.Visible = false;
            companyRegNo     = Regex.Replace(api.CompanyEntity._Id ?? string.Empty, "[^0-9]", "");
            companyCountryId = api.CompanyEntity._CountryId;

            euSalesHelper = new CreateEUSaleWithoutVATFile(api, companyRegNo, companyCountryId);

            if (DefaultFromDate == DateTime.MinValue)
            {
                var now = BasePage.GetSystemDefaultDate();

                var fromDate = new DateTime(now.Year, now.Month, 1);
                fromDate = fromDate.AddMonths(-1);

                DefaultFromDate = fromDate;
                DefaultToDate   = fromDate.AddMonths(1).AddDays(-1);
            }

            txtDateTo.DateTime  = DefaultToDate;
            txtDateFrm.DateTime = DefaultFromDate;
            SetDateTime(txtDateFrm, txtDateTo);

            glVatCache = api.GetCache <Uniconta.DataModel.GLVat>();
            StartLoadCache();
        }
Esempio n. 4
0
        private void InitPage()
        {
            InitializeComponent();
            localMenu.dataGrid = dgVatOSSGrid;
            SetRibbonControl(localMenu, dgVatOSSGrid);
            localMenu.OnItemClicked   += localMenu_OnItemClicked;
            dgVatOSSGrid.api           = api;
            dgVatOSSGrid.BusyIndicator = busyIndicator;
            dgVatOSSGrid.ShowTotalSummary();
            txtDateFrm.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 01);
            txtDateTo.DateTime  = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month));

            cmbVatOSSReportType.ItemsSource   = new string[] { Uniconta.ClientTools.Localization.lookup("UnionSchemeOSS"), Uniconta.ClientTools.Localization.lookup("NonUnionSchemeOSS"), Uniconta.ClientTools.Localization.lookup("ImportSchemeOSS") };
            cmbVatOSSReportType.SelectedIndex = 0;

            vatOSSHelper = new CreateVatOSSFile(api);

            if (DefaultFromDate == DateTime.MinValue)
            {
                var now = BasePage.GetSystemDefaultDate();

                var fromDate = new DateTime(now.Year, now.Month, 1);
                fromDate = fromDate.AddMonths(-1);

                DefaultFromDate = fromDate;
                DefaultToDate   = fromDate.AddMonths(1).AddDays(-1);
            }

            txtDateTo.DateTime  = DefaultToDate;
            txtDateFrm.DateTime = DefaultFromDate;
            SetDateTime(txtDateFrm, txtDateTo);

            glVatCache = api.GetCache <Uniconta.DataModel.GLVat>();
        }
Esempio n. 5
0
        protected override async void LoadCacheInBackGround()
        {
            var api = this.api;

            if (projectCache == null)
            {
                projectCache = await api.LoadCache <Uniconta.ClientTools.DataModel.ProjectClient>().ConfigureAwait(false);
            }
            if (payrollCache == null)
            {
                payrollCache = await api.LoadCache <Uniconta.DataModel.EmpPayrollCategory>().ConfigureAwait(false);
            }
            if (prCategoryCache == null)
            {
                prCategoryCache = await api.LoadCache <Uniconta.DataModel.PrCategory>().ConfigureAwait(false);
            }
            if (projGroupCache == null)
            {
                projGroupCache = await api.LoadCache <Uniconta.DataModel.ProjectGroup>().ConfigureAwait(false);
            }
            if (employeeCache == null)
            {
                employeeCache = await api.LoadCache <Uniconta.DataModel.Employee>().ConfigureAwait(false);
            }
            if (budgetGroupCache == null)
            {
                budgetGroupCache = await api.LoadCache <Uniconta.DataModel.ProjectBudgetGroup>().ConfigureAwait(false);
            }
        }
Esempio n. 6
0
        protected override async void LoadCacheInBackGround()
        {
            if (glVatCache == null)
            {
                glVatCache = await api.LoadCache <Uniconta.DataModel.GLVat>().ConfigureAwait(false);
            }

            LoadType(new Type[] { typeof(Uniconta.DataModel.Debtor), typeof(Uniconta.DataModel.InvGroup) });
        }
Esempio n. 7
0
        protected async override void LoadCacheInBackGround()
        {
            projects = projects ?? await api.LoadCache <Uniconta.DataModel.Project>().ConfigureAwait(false);

            debtors = debtors ?? await api.LoadCache <Uniconta.DataModel.Debtor>().ConfigureAwait(false);

            budgetGrpCache = budgetGrpCache ?? await api.LoadCache(typeof(Uniconta.DataModel.ProjectBudgetGroup)).ConfigureAwait(false);

            prWorkSpaceCache = prWorkSpaceCache ?? await api.LoadCache <Uniconta.DataModel.PrWorkSpace>().ConfigureAwait(false);
        }
 protected override async void LoadCacheInBackGround()
 {
     if (prCategoryCache == null)
     {
         prCategoryCache = await api.LoadCache <Uniconta.DataModel.PrCategory>().ConfigureAwait(false);
     }
     if (employeeCache == null)
     {
         employeeCache = await api.LoadCache <Uniconta.DataModel.Employee>().ConfigureAwait(false);
     }
 }
Esempio n. 9
0
        public List <TMJournalLineError> PreValidate(TMJournalActionType actionType, double valNormHours, double valRegHours, SQLTableCache <Uniconta.DataModel.EmpPayrollCategory> empPayrollCatList)
        {
            checkErrors = new List <TMJournalLineError>();

            this.empPayrollCatList = empPayrollCatList;

            PreValidateEmployee();
            PreValidateCalendar(valNormHours, valRegHours, actionType);
            PreValidatePayrollCategory();

            return(checkErrors);
        }
        protected async override void LoadCacheInBackGround()
        {
            Employees = Employees ?? await api.LoadCache <Uniconta.DataModel.Employee>().ConfigureAwait(false);

            Projects = Projects ?? await api.LoadCache <Uniconta.DataModel.Project>().ConfigureAwait(false);

            Payrolls = Payrolls ?? await api.LoadCache(typeof(Uniconta.DataModel.EmpPayrollCategory)).ConfigureAwait(false);

            if (this.priceLookup == null)
            {
                priceLookup = new Uniconta.API.Project.FindPricesEmpl(api);
            }
        }
        private void Init(UnicontaBaseEntity _master)
        {
            prCategoryCache = api.GetCache <Uniconta.DataModel.PrCategory>();
            employeeCache   = api.GetCache <Uniconta.DataModel.Employee>();
            StartLoadCache();

            InitializeComponent();
            pivotDgProjectPlanning.ShowColumnGrandTotals = true;
            pivotDgProjectPlanning.ShowRowTotals         = false;
            master = _master;
            SetPageControl(pivotDgProjectPlanning, chartControl);
            layoutControl = layoutItems;
            pivotDgProjectPlanning.BusyIndicator = busyIndicator;
            ribbonControl = localMenu;
            pivotDgProjectPlanning.BeginUpdate();
            pivotDgProjectPlanning.AllowCrossGroupVariation = false;
            pivotDgProjectPlanning.api       = api;
            pivotDgProjectPlanning.TableType = typeof(ProjectTransPivotClient);
            localMenu.OnItemClicked         += LocalMenu_OnItemClicked;
            cmbBudgetGroup.api = api;
            SetBudgetGroup();
            localMenu.OnChecked += LocalMenu_OnChecked;
            pivotDgProjectPlanning.CellDoubleClick += PivotGridControl_CellDoubleClick;
            GetMenuItem();
            txtFromDate.DateTime                         = fromDate == DateTime.MinValue ? GetSystemDefaultDate() : fromDate;
            txtToDate.DateTime                           = toDate == DateTime.MinValue ? GetSystemDefaultDate() : toDate;
            cmbBudgetGroup.Text                          = budgetGroup;
            chkGroupWeek.IsChecked                       = grpWeek;
            chkGroupPrevYear.IsChecked                   = grpPrevYear;
            pivotDgProjectPlanning.CellClick            += PivotDgProjectPlanning_CellClick;
            pivotDgProjectPlanning.CustomCellAppearance += PivotDgProjectPlanning_CustomCellAppearance;
            fieldQtyActualBudDiff.Caption                = ProjectTransPivotClientText.QtyActualBudDiff;
            fieldQtyNormBudDiff.Caption                  = ProjectTransPivotClientText.QtyNormBudDiff;
            fieldQtyActualNormDiff.Caption               = ProjectTransPivotClientText.QtyActualNormDiff;
            fieldSalesActualBudgetDiff.Caption           = ProjectTransPivotClientText.SalesActualBudgetDiff;
            fieldCostActualBudgetDiff.Caption            = ProjectTransPivotClientText.CostActualBudgetDiff;
            fieldQtyActualPrevBudDiff.Caption            = ProjectTransPivotClientText.QtyActualPrevBudDiff;
            fieldSalesActualPrevBudgetDiff.Caption       = ProjectTransPivotClientText.SalesActualPrevBudgetDiff;
            fieldCostActualPrevBudgetDiff.Caption        = ProjectTransPivotClientText.CostActualPrevBudgetDiff;
            fieldQtyActualAnchorBudDiff.Caption          = ProjectTransPivotClientText.QtyActualAnchorBudDiff;
            fieldQtyNormAnchorBudDiff.Caption            = ProjectTransPivotClientText.QtyNormAnchorBudDiff;
            fieldSalesActualAnchorBudgetDiff.Caption     = ProjectTransPivotClientText.SalesActualAnchorBudgetDiff;
            fieldCostActualAnchorBudgetDiff.Caption      = ProjectTransPivotClientText.CostActualAnchorBudgetDiff;
            fieldQtyActualPrevAnchorBudDiff.Caption      = ProjectTransPivotClientText.QtyActualPrevAnchorBudDiff;
            fieldSalesActualPrevAnchorBudgetDiff.Caption = ProjectTransPivotClientText.SalesActualPrevAnchorBudgetDiff;
            fieldCostActualPrevAnchorBudgetDiff.Caption  = ProjectTransPivotClientText.CostActualPrevAnchorBudgetDiff;
            fieldQtyAnchorBudBudDiff.Caption             = ProjectTransPivotClientText.QtyAnchorBudBudDiff;
            fieldSalesAnchorBudBudDiff.Caption           = ProjectTransPivotClientText.SalesAnchorBudBudDiff;
            fieldCostAnchorBudBudDiff.Caption            = ProjectTransPivotClientText.CostAnchorBudBudDiff;
        }
        void InitializePage(UnicontaBaseEntity _master)
        {
            this.DataContext = this;
            InitializeComponent();
            master = _master;
            SetRibbonControl(localMenu, dgProjectTransaction);
            RibbonBase rb = (RibbonBase)localMenu.DataContext;

            if (master != null)
            {
                dgProjectTransaction.UpdateMaster(master);
                ribbonControl.DisableButtons("Save");
            }
            else
            {
                UtilDisplay.RemoveMenuCommand(rb, new string[] { "EditAll", "Save" });
            }

            if (master is Uniconta.DataModel.Project)
            {
                iIncludeSubProBase           = UtilDisplay.GetMenuCommandByName(rb, "InclSubProjects");
                iIncludeSubProBase.IsChecked = includeSubProject;
            }
            else
            {
                UtilDisplay.RemoveMenuCommand(rb, "InclSubProjects");
            }

            if (api.CompanyEntity.TimeManagement)
            {
                iIncludeTimeJournalBase           = UtilDisplay.GetMenuCommandByName(rb, "InclTimeJournals");
                iIncludeTimeJournalBase.IsChecked = InclTimeJournals;
            }
            else
            {
                InclTimeJournals = false;
                UtilDisplay.RemoveMenuCommand(rb, "InclTimeJournals");
            }

            dgProjectTransaction.api           = api;
            dgProjectTransaction.BusyIndicator = busyIndicator;
            dgProjectTransaction.ShowTotalSummary();
            localMenu.OnItemClicked += LocalMenu_OnItemClicked;
            localMenu.OnChecked     += LocalMenu_OnChecked;

            Employees = api.GetCache <Uniconta.DataModel.Employee>();
            Projects  = api.GetCache <Uniconta.DataModel.Project>();
            Payrolls  = api.GetCache(typeof(Uniconta.DataModel.EmpPayrollCategory));
        }
Esempio n. 13
0
        public List <TMJournalLineError> ValidateLinesMileage(IEnumerable <TMJournalLineClientLocal> lines,
                                                              DateTime startDate,
                                                              DateTime endDate,
                                                              IList <EmpPayrollCategoryEmployeeClient> empPriceLst,
                                                              SQLTableCache <Uniconta.DataModel.EmpPayrollCategory> empPayrollCatList,
                                                              SQLTableCache <Uniconta.ClientTools.DataModel.ProjectClient> projCache,
                                                              SQLTableCache <Uniconta.DataModel.ProjectGroup> projGroupList,
                                                              Uniconta.DataModel.Employee employee)
        {
            checkErrors = new List <TMJournalLineError>();

            this.empPayrollCatList = empPayrollCatList;
            this.projGroupList     = projGroupList;
            this.projCache         = projCache;
            this.comp        = api.CompanyEntity;
            this.empPriceLst = empPriceLst;
            this.employee    = employee;
            var approveDate = employee._TMApproveDate;

            this.startDate = approveDate >= startDate?approveDate.AddDays(1) : startDate;

            this.endDate = endDate;

            foreach (var rec in lines)
            {
                rec.ErrorInfo = string.Empty;
                err           = false;

                ValidateMileageGeneral(rec);
                ValidateMileageProject(rec);
                ValidateMileageProjectCategory(rec);

                if (!err)
                {
                    rec.ErrorInfo = VALIDATE_OK;
                }
            }

            if (!err)
            {
                ValidateHoursPrice(lines);
            }

            return(checkErrors);
        }
Esempio n. 14
0
        async Task LoadBaseData(QueryAPI api)
        {
            this.comp = api.CompanyEntity;

            payrollCategoryCache = api.GetCache <Uniconta.DataModel.EmpPayrollCategory>() ?? await api.LoadCache <Uniconta.DataModel.EmpPayrollCategory>().ConfigureAwait(false);

            projectCache = comp.GetCache(typeof(Uniconta.DataModel.Project)) ?? await api.LoadCache(typeof(Uniconta.DataModel.Project)).ConfigureAwait(false);

            employeeCache = comp.GetCache(typeof(Uniconta.DataModel.Employee)) ?? await api.LoadCache(typeof(Uniconta.DataModel.Employee)).ConfigureAwait(false);

            projectGrpCache = comp.GetCache(typeof(Uniconta.DataModel.ProjectGroup)) ?? await api.LoadCache(typeof(Uniconta.DataModel.ProjectGroup)).ConfigureAwait(false);

            prCategoryCache = comp.GetCache(typeof(Uniconta.DataModel.PrCategory)) ?? await api.LoadCache(typeof(Uniconta.DataModel.PrCategory)).ConfigureAwait(false);

            prTaskCache = comp.GetCache(typeof(Uniconta.DataModel.ProjectTask)) ?? await api.LoadCache(typeof(Uniconta.DataModel.ProjectTask)).ConfigureAwait(false);

            LoadingTask = null; // we are done
        }
Esempio n. 15
0
        protected override async void LoadCacheInBackGround()
        {
            var api = this.api;

            if (ProjectCache == null)
            {
                ProjectCache = await api.LoadCache(typeof(Uniconta.DataModel.Project)).ConfigureAwait(false);
            }
            if (ItemsCache == null)
            {
                ItemsCache = await api.LoadCache(typeof(Uniconta.DataModel.InvItem)).ConfigureAwait(false);
            }
            if (CreditorCache == null)
            {
                CreditorCache = await api.LoadCache(typeof(Uniconta.DataModel.Creditor)).ConfigureAwait(false);
            }
            if (CategoryCache == null)
            {
                CategoryCache = await api.LoadCache(typeof(Uniconta.DataModel.PrCategory)).ConfigureAwait(false);
            }
            if (EmployeeCache == null)
            {
                EmployeeCache = await api.LoadCache(typeof(Uniconta.DataModel.Employee)).ConfigureAwait(false);
            }
            if (PrStandardCache == null)
            {
                PrStandardCache = await api.LoadCache(typeof(Uniconta.DataModel.PrStandard)).ConfigureAwait(false);
            }
            if (api.CompanyEntity.Payroll)
            {
                PayrollCache = api.GetCache(typeof(Uniconta.DataModel.EmpPayrollCategory)) ?? await api.LoadCache(typeof(Uniconta.DataModel.EmpPayrollCategory)).ConfigureAwait(false);
            }
            if (api.CompanyEntity.Warehouse)
            {
                WarehouseCache = api.GetCache(typeof(Uniconta.DataModel.InvWarehouse)) ?? await api.LoadCache(typeof(Uniconta.DataModel.InvWarehouse)).ConfigureAwait(false);
            }
            WorkspaceCache = WorkspaceCache ?? await api.LoadCache <Uniconta.DataModel.PrWorkSpace>().ConfigureAwait(false);

            TimePriceLookup = new Uniconta.API.Project.FindPricesEmpl(api);

            dgProjectJournalLinePageGrid.WorkSpaceDefault = WorkspaceCache.FirstOrDefault(s => s._Default)?._Number;;
        }
Esempio n. 16
0
        void Init()
        {
            InitializeComponent();
            localMenu.dataGrid = dgProjectJournalLinePageGrid;
            SetRibbonControl(localMenu, dgProjectJournalLinePageGrid);
            dgProjectJournalLinePageGrid.api           = api;
            dgProjectJournalLinePageGrid.BusyIndicator = busyIndicator;
            localMenu.OnItemClicked += localMenu_OnItemClicked;
            dgProjectJournalLinePageGrid.View.DataControl.CurrentItemChanged += DataControl_CurrentItemChanged;
            postingApi        = new UnicontaAPI.Project.API.PostingAPI(api);
            dictPriceLookup   = new Dictionary <string, Uniconta.API.DebtorCreditor.FindPrices>();
            this.BeforeClose += JournalLine_BeforeClose;
            dgProjectJournalLinePageGrid.ShowTotalSummary();

            ProjectCache    = api.GetCache(typeof(Uniconta.DataModel.Project));
            ItemsCache      = api.GetCache(typeof(Uniconta.DataModel.InvItem));
            CreditorCache   = api.GetCache(typeof(Uniconta.DataModel.Creditor));
            CategoryCache   = api.GetCache(typeof(Uniconta.DataModel.PrCategory));
            EmployeeCache   = api.GetCache(typeof(Uniconta.DataModel.Employee));
            PrStandardCache = api.GetCache(typeof(Uniconta.DataModel.PrStandard));
            WorkspaceCache  = api.GetCache <Uniconta.DataModel.PrWorkSpace>();
        }
Esempio n. 17
0
        public async void GetInvoiceEuSale(DateTime fromDate, DateTime toDate)
        {
            SetDateTime(txtDateFrm, txtDateTo);

            busyIndicator.IsBusy = true;
            List <PropValuePair> propValPair = new List <PropValuePair>();

            if (fromDate != DateTime.MinValue || toDate != DateTime.MinValue)
            {
                string filter;
                if (fromDate != DateTime.MinValue)
                {
                    filter = String.Format("{0:d}..", fromDate);
                }
                else
                {
                    filter = "..";
                }
                if (toDate != DateTime.MinValue)
                {
                    filter += String.Format("{0:d}", toDate);
                }
                var prop = PropValuePair.GenereteWhereElements("Date", typeof(DateTime), filter);
                propValPair.Add(prop);
            }

            if (glVatCache == null)
            {
                glVatCache = await api.LoadCache <Uniconta.DataModel.GLVat>();
            }

            var vatEUList = glVatCache.Where(s => s._TypeSales == "s3" || s._TypeSales == "s4" || s._TypeSales == "s7").Select(x => x._Vat).Distinct();

            if (vatEUList != null && vatEUList.Count() > 0)
            {
                var strLst = string.Join(";", vatEUList);
                propValPair.Add(PropValuePair.GenereteWhereElements(nameof(DebtorInvoiceLines.Vat), typeof(string), strLst));
            }
            var listOfDebInvLines = await api.Query <DebtorInvoiceLines>(propValPair);

            List <EUSaleWithoutVAT> listdeb;

            if (listOfDebInvLines != null && listOfDebInvLines.Length != 0)
            {
                listdeb = UpdateValues(listOfDebInvLines);
            }
            else
            {
                listdeb = new List <EUSaleWithoutVAT>();
            }

            busyIndicator.IsBusy = false;

            if (listdeb.Count == 0)
            {
                UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("zeroRecords"), Uniconta.ClientTools.Localization.lookup("Warning"));
            }

            dgEUSalesWithoutVATGrid.ItemsSource = listdeb;
            dgEUSalesWithoutVATGrid.Visibility  = Visibility.Visible;
        }
Esempio n. 18
0
        public async void GetVatOSS(DateTime fromDate, DateTime toDate)
        {
            SetDateTime(txtDateFrm, txtDateTo);

            busyIndicator.IsBusy = true;
            List <PropValuePair> propValPair = new List <PropValuePair>();

            if (fromDate != DateTime.MinValue || toDate != DateTime.MinValue)
            {
                string filter;
                if (fromDate != DateTime.MinValue)
                {
                    filter = String.Format("{0:d}..", fromDate);
                }
                else
                {
                    filter = "..";
                }
                if (toDate != DateTime.MinValue)
                {
                    filter += String.Format("{0:d}", toDate);
                }
                var prop = PropValuePair.GenereteWhereElements("Date", typeof(DateTime), filter);
                propValPair.Add(prop);
            }

            if (glVatCache == null)
            {
                glVatCache = await api.LoadCache <Uniconta.DataModel.GLVat>();
            }

            var vatEUList = glVatCache.Where(s => s._TypeSales == CreateVatOSSFile.VATTYPE_MOSS).Select(x => x._Vat).Distinct();

            if (vatEUList != null && vatEUList.Count() > 0)
            {
                var strLst = string.Join(";", vatEUList);
                propValPair.Add(PropValuePair.GenereteWhereElements(nameof(DebtorInvoiceLines.Vat), typeof(string), strLst));
            }
            var listOfDebInvLines = await api.Query <DebtorInvoiceLines>(propValPair);

            List <VatOSSTable> vatOSSlst = new List <VatOSSTable>();

            if (listOfDebInvLines != null && listOfDebInvLines.Length != 0)
            {
                vatOSSlst            = UpdateValues(listOfDebInvLines);
                busyIndicator.IsBusy = false;
            }
            else
            {
                var vatOSS = new VatOSSTable();
                vatOSS._CompanyId    = api.CompanyId;
                vatOSS._Date         = DefaultFromDate;
                vatOSS.MOSSType      = vatOSSReportType == 0 ? CreateVatOSSFile.MOSSTYPE_008 : vatOSSReportType == 1 ? CreateVatOSSFile.MOSSTYPE_021 : CreateVatOSSFile.MOSSTYPE_031;
                vatOSS._MOSSTypeName = GetMOSSTypeName(vatOSS.MOSSType);
                vatOSS.Compressed    = true;
                vatOSSlst.Add(vatOSS);

                busyIndicator.IsBusy = false;
                compressed           = true;
            }

            var sort = new VatOSSTableTypeSort();

            vatOSSlst.Sort(sort);
            dgVatOSSGrid.ItemsSource = vatOSSlst;
            dgVatOSSGrid.Visibility  = Visibility.Visible;
        }
Esempio n. 19
0
        public Tuple <double, double> GetEmplPrice(IList <EmpPayrollCategoryEmployeeClient> empPriceLst,
                                                   SQLTableCache <Uniconta.DataModel.EmpPayrollCategory> empPayrollCatLst,
                                                   SQLTableCache <Uniconta.DataModel.ProjectGroup> projGroupLst,
                                                   Uniconta.DataModel.Employee employee,
                                                   Uniconta.DataModel.Project project,
                                                   DateTime priceDate,
                                                   string payrollCategory = null)
        {
#if !SILVERLIGHT
            if (employee == null)
            {
                return(new Tuple <double, double>(0, 0));
            }

            this.empPriceLst = empPriceLst;
            var projGroup = projGroupLst.Get(project._Group);

            EmpPayrollCategory payrollCat;
            bool isMileagePrice;
            bool invoiceable;
            if (payrollCategory == null)
            {
                payrollCat      = null;
                isMileagePrice  = false;
                invoiceable     = projGroup._Invoiceable;
                payrollCategory = string.Empty;
            }
            else
            {
                payrollCat     = empPayrollCatLst.Get(payrollCategory);
                isMileagePrice = payrollCat._InternalType == InternalType.Mileage;
                invoiceable    = projGroup._Invoiceable && payrollCat._Invoiceable;
            }


            if (empPriceLst != null && empPriceLst.Count > 0 && empPriceLst.Any(s => s._Employee != employee._Number)) // it contains other employees, remove them
            {
                empPriceLst = empPriceLst.Where(s => s._Employee == employee._Number).ToList();
            }

            if (isMileagePrice)
            {
                invoiceable = projGroup._Invoiceable;
            }

            double salesPrice = 0, costPrice = 0;

            if (empPriceLst != null && empPriceLst.Count > 0)
            {
                var defaultPayrollCategory = empPayrollCatLst.Where(s => s._PrCategory == null && s.KeyStr == "Default").FirstOrDefault();

                var prices = PriceMatrix(priceDate, 1, project, payrollCategory);

                if (prices != null && prices._Project == null && prices._DCAccount == null)
                {
                    prices = PriceMatrix(priceDate, 1, project, defaultPayrollCategory?.KeyStr, true) ?? prices;
                }
                else if (prices == null && defaultPayrollCategory != null)
                {
                    prices = PriceMatrix(priceDate, 1, project, defaultPayrollCategory.KeyStr);
                }

                if (prices != null)
                {
                    salesPrice = prices._SalesPrice;
                    costPrice  = prices._CostPrice;
                }
            }

            if (payrollCat != null)
            {
                if (salesPrice == 0)
                {
                    salesPrice = payrollCat._SalesPrice;
                }
                if (costPrice == 0)
                {
                    costPrice = payrollCat._Rate;
                }
            }

            if (!isMileagePrice)  //Always fallback to Employee for cost and sales prices
            {
                if (salesPrice == 0)
                {
                    salesPrice = employee._SalesPrice;
                }
                if (costPrice == 0)
                {
                    costPrice = employee._CostPrice;
                }
            }

            return(new Tuple <double, double>(costPrice, invoiceable ? salesPrice : 0));
#endif
            return(new Tuple <double, double>(0, 0));
        }
Esempio n. 20
0
        public void SetEmplPrice(IEnumerable <TMJournalLineClientLocal> lst,
                                 IList <EmpPayrollCategoryEmployeeClient> empPriceLst,
                                 SQLTableCache <Uniconta.DataModel.EmpPayrollCategory> empPayrollCatLst,
                                 SQLTableCache <Uniconta.ClientTools.DataModel.ProjectClient> projLst,
                                 DateTime startDate,
                                 DateTime endDate,
                                 Uniconta.DataModel.Employee employee,
                                 bool validate = false)
        {
#if !SILVERLIGHT
            bool foundErr;

            this.employee    = employee;
            this.empPriceLst = empPriceLst;
            int dayOfWeekStart = startDate.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)startDate.DayOfWeek;
            int dayOfWeekEnd   = endDate.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)endDate.DayOfWeek;

            var defaultPayrollCategory = empPayrollCatLst.Where(s => s._PrCategory == null && s.KeyStr == "Default").FirstOrDefault();

            if (empPriceLst != null && empPriceLst.Any(s => s._Employee != employee._Number)) // it contains other employees, remove them
            {
                empPriceLst = empPriceLst.Where(s => s._Employee == employee._Number).ToList();
            }

            foreach (var trans in lst)
            {
                var isMileageTrans = trans._RegistrationType == RegistrationType.Mileage ? true : false;
                if (isMileageTrans)
                {
                    var projGroup = projGroupList.Get(trans.ProjectRef.Group);
                    if (projGroup != null)
                    {
                        trans._Invoiceable = projGroup._Invoiceable;
                    }
                }

                var payrollCat = empPayrollCatLst.Get(trans._PayrollCategory);
                var Proj       = projLst.Get(trans._Project);

                foundErr = false;
                for (int x = dayOfWeekStart; x <= dayOfWeekEnd; x++)
                {
                    if (trans.GetHoursDayN(x) == 0)
                    {
                        continue;
                    }

                    double salesPrice = 0, costPrice = 0;

                    EmpPayrollCategoryEmployeeClient prices = null;
                    if (empPriceLst != null && empPriceLst.Count > 0)
                    {
                        prices = PriceMatrix(startDate, x, Proj, trans._PayrollCategory);

                        if (prices != null && prices._Project == null && prices._DCAccount == null && !isMileageTrans)
                        {
                            prices = PriceMatrix(startDate, x, Proj, defaultPayrollCategory?.KeyStr, true) ?? prices;
                        }
                        else if (prices == null && defaultPayrollCategory != null && !isMileageTrans)
                        {
                            prices = PriceMatrix(startDate, x, Proj, defaultPayrollCategory.KeyStr);
                        }

                        if (prices != null)
                        {
                            salesPrice = prices._SalesPrice;
                            costPrice  = prices._CostPrice;
                        }
                    }

                    if (payrollCat != null)
                    {
                        if (salesPrice == 0)
                        {
                            salesPrice = payrollCat._SalesPrice;
                        }
                        if (costPrice == 0)
                        {
                            costPrice = payrollCat._Rate;
                        }
                    }

                    if (!isMileageTrans) //Always fallback to Employee for cost and sales prices
                    {
                        if (salesPrice == 0)
                        {
                            salesPrice = employee._SalesPrice;
                        }
                        if (costPrice == 0)
                        {
                            costPrice = employee._CostPrice;
                        }
                    }

                    trans.SetPricesDayN(x, trans._Invoiceable ? salesPrice : 0, costPrice);

                    if (validate && !foundErr)
                    {
                        if (salesPrice == 0 && costPrice == 0)
                        {
                            if (startDate.AddDays(x - 1) >= employee._Hired)
                            {
                                checkErrors.Add(new TMJournalLineError()
                                {
                                    Message = Uniconta.ClientTools.Localization.lookup("NoRatesEmployee"),
                                    RowId   = trans.RowId
                                });

                                trans.ErrorInfo = string.Empty;
                                err             = true;
                                foundErr        = true;
                            }
                        }
                        else
                        {
                            if (!foundErr && salesPrice == 0 && trans._Invoiceable && !isMileageTrans)
                            {
                                checkErrors.Add(new TMJournalLineError()
                                {
                                    Message = string.Format("{0} ({1}: {2})",
                                                            Uniconta.ClientTools.Localization.lookup("NoSalesPrice"),
                                                            Uniconta.ClientTools.Localization.lookup("Date"),
                                                            startDate.AddDays(x - 1).ToString("dd.MM.yyyy")),
                                    RowId = trans.RowId
                                });

                                trans.ErrorInfo = string.Empty;
                                err             = true;
                                foundErr        = true;
                            }
                        }
                    }
                }
            }
#endif
        }
Esempio n. 21
0
        async void LoadGrid()
        {
            budgetGroup = cmbBudgetGroup.Text;
            workSpace   = cmbWorkSpace.Text;

            if (string.IsNullOrEmpty(budgetGroup))
            {
                var msgText = string.Concat(Uniconta.ClientTools.Localization.lookup("FieldCannotBeEmpty"), " (", Uniconta.ClientTools.Localization.lookup("Field"), ": ", Uniconta.ClientTools.Localization.lookup("BudgetGroup"), ")");
                UnicontaMessageBox.Show(msgText, Uniconta.ClientTools.Localization.lookup("Warning"), MessageBoxButton.OK);
                return;
            }

            busyIndicator.IsBusy = true;

            if (projects == null)
            {
                projects = await api.LoadCache <Uniconta.DataModel.Project>();
            }

            if (debtors == null)
            {
                debtors = await api.LoadCache <Uniconta.DataModel.Debtor>();
            }

            var projArr = projects.ToArray();

            var lst = new List <TMPlanningCheckLocal>(1000);

            var search = new Uniconta.DataModel.Project();
            var sort   = new SortProjectDebtor();
            int pos;

            Array.Sort(projArr, sort);

            foreach (var rec in debtors)
            {
                if (rec._Blocked)
                {
                    continue;
                }

                search._DCAccount = rec._Account;
                pos = Array.BinarySearch(projArr, search, sort);
                if (pos < 0)
                {
                    pos = ~pos;
                }

                bool found = false;
                while (pos < projArr.Length)
                {
                    var s = projArr[pos++];
                    if (s._DCAccount != rec._Account)
                    {
                        break;
                    }

                    if (s._Blocked || s._Phase == ProjectPhase.Completed || s._Phase == ProjectPhase.ReportedAsFinished || s._Phase == ProjectPhase.Paused)
                    {
                        continue;
                    }

                    found = true;
                    break;
                }

                if (!found)
                {
                    var cur = new TMPlanningCheckLocal()
                    {
                        _CompanyId = api.CompanyId, _Debtor = rec._Account, _ErrorInfo = string.Concat("1. ", Uniconta.ClientTools.Localization.lookup("DebtorNoActiveProjects"))
                    };
                    lst.Add(cur);
                }
            }

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

            pairBudget.Add(PropValuePair.GenereteWhereElements(nameof(ProjectBudget._Group), typeof(string), budgetGroup));
            var projBudgetArr = await api.Query <ProjectBudget>(pairBudget);

            var master        = budgetGrpCache.Get(budgetGroup) as ProjectBudgetGroup;
            var budgetLineArr = await api.Query <ProjectBudgetLine>(master);

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

            pairTask.Add(PropValuePair.GenereteWhereElements(nameof(ProjectTaskClient.WorkSpace), typeof(string), workSpace));

            var projTaskArr = await api.Query <ProjectTaskClient>(pairTask);

            var searchBud = new ProjectBudget();
            var sortBud   = new SortProjectBudget();

            Array.Sort(projBudgetArr, sortBud);

            var searchBudLine = new ProjectBudgetLine();
            var sortBudLine   = new SortProjectBudgetLine();
            int posBudLine;

            Array.Sort(budgetLineArr, sortBudLine);

            var searchTask = new ProjectTask();
            var sortTask   = new SortProjectTask();
            int posTask;

            Array.Sort(projTaskArr, sortTask);

            foreach (var rec in projects)
            {
                if (rec._Blocked || rec._Phase == ProjectPhase.Completed || rec._Phase == ProjectPhase.ReportedAsFinished || rec._Phase == ProjectPhase.Paused)
                {
                    continue;
                }

                searchBud._Project = rec._Number;
                pos = Array.BinarySearch(projBudgetArr, searchBud, sortBud);
                if (pos < 0)
                {
                    pos = ~pos;
                }

                bool found = false;
                while (pos < projBudgetArr.Length)
                {
                    var s = projBudgetArr[pos++];
                    if (s._Project != rec._Number)
                    {
                        break;
                    }

                    #region BudgetLine
                    searchBudLine._Project = rec._Number;
                    posBudLine             = Array.BinarySearch(budgetLineArr, searchBudLine, sortBudLine);
                    if (posBudLine < 0)
                    {
                        posBudLine = ~posBudLine;
                    }

                    bool foundLine = false;
                    while (posBudLine < budgetLineArr.Length)
                    {
                        var sLine = budgetLineArr[posBudLine++];
                        if (sLine._Project != rec._Number)
                        {
                            break;
                        }

                        foundLine = true;
                        break;
                    }

                    if (!foundLine)
                    {
                        var cur = new TMPlanningCheckLocal()
                        {
                            _CompanyId = api.CompanyId, _Project = rec._Number, _ErrorInfo = string.Concat("2. ", Uniconta.ClientTools.Localization.lookup("ProjectMissingBudget"))
                        };
                        lst.Add(cur);
                    }
                    #endregion

                    found = true;
                }

                if (api.CompanyEntity.ProjectTask && workSpace != null)
                {
                    searchTask._Project = rec._Number;
                    posTask             = Array.BinarySearch(projTaskArr, searchTask, sortTask);
                    if (posTask < 0)
                    {
                        posTask = ~posTask;
                    }

                    bool foundLine = false;
                    while (posTask < projTaskArr.Length)
                    {
                        var projTask = projTaskArr[posTask++];
                        if (projTask._Project != rec._Number)
                        {
                            break;
                        }

                        foundLine = true;
                        break;
                    }

                    if (!foundLine)
                    {
                        var cur = new TMPlanningCheckLocal()
                        {
                            _CompanyId = api.CompanyId, _Project = rec._Number, _ErrorInfo = string.Concat("3. ", Uniconta.ClientTools.Localization.lookup("ProjectNoActiveTasks"))
                        };
                        lst.Add(cur);
                    }
                }
            }

            dgTMPlanningCheckGrid.ItemsSource = lst;

            if (dgTMPlanningCheckGrid.tableView != null)
            {
                dgTMPlanningCheckGrid.ShowTotalSummary();
                dgTMPlanningCheckGrid.GroupBy("ErrorInfo");
                dgTMPlanningCheckGrid.Visibility = Visibility.Visible;
            }

            busyIndicator.IsBusy = false;
        }