示例#1
0
        /// <summary>
        /// Apply the cost center currency to the current object properties
        /// </summary>
        /// <param name="associateCurrency">the associate currency</param>
        protected override void ApplyCostCenterCurrency(int associateCurrency, CurrencyConverter converter)
        {
            CostCenter currentCostCenter = new CostCenter(this.CurrentConnectionManager);

            currentCostCenter.Id = IdCostCenter;
            int idCurrency = currentCostCenter.GetCostCenterCurrency().Id;

            if (_ValuedHours != ApplicationConstants.DECIMAL_NULL_VALUE)
            {
                _ValuedHours = converter.GetConversionValue(_ValuedHours, associateCurrency, new YearMonth(YearMonth), idCurrency);
            }

            _Sales = converter.GetConversionValue(_Sales, associateCurrency, new YearMonth(YearMonth), idCurrency);
        }
示例#2
0
        private void ApplyCostCenterCurrency(int idCostCenter, int associateCurrency, CurrencyConverter converter)
        {
            CostCenter currentCostCenter = new CostCenter(this.CurrentConnectionManager);

            currentCostCenter.Id = idCostCenter;
            int idCurrency = currentCostCenter.GetCostCenterCurrency().Id;

            _CostVal = converter.GetConversionValue(_CostVal, associateCurrency, new YearMonth(YearMonth), idCurrency);
        }
        /// <summary>
        /// Apply the cost center currency to the current object properties
        /// </summary>
        /// <param name="associateCurrency">the associate currency</param>
        protected override void ApplyCostCenterCurrency(int associateCurrency, CurrencyConverter converter)
        {
            CostCenter currentCostCenter = new CostCenter(this.CurrentConnectionManager);

            currentCostCenter.Id = IdCostCenter;
            int idCurrency = currentCostCenter.GetCostCenterCurrency().Id;

            _New = converter.GetConversionValue(_New, associateCurrency, new YearMonth(YearMonth), idCurrency);
        }
示例#4
0
        private void ApplyCurrencyForCostCenterTable(DataSet sourceDS, int associateCurrency, CurrencyConverter converter, int dsIndex)
        {
            DataTable sourceTable = sourceDS.Tables[2];

            //Cycle through each row of the cost center table
            foreach (DataRow row in sourceTable.Rows)
            {
                //Get the cost center currency for the current row
                int costCenterCurrency = (int)row["IdCurrency"];
                //If both currencies are the same, do nothing
                if (costCenterCurrency == associateCurrency)
                {
                    continue;
                }

                BudgetColumnsCalculationsList columns = this.GetCalculatedColumns(dsIndex);
                foreach (KeyValuePair <string, EBudgetCalculationMethod> entry in columns)
                {
                    //Get the current calculated column name
                    string columnName = entry.Key;
                    if (sourceTable.Columns[columnName].DataType == typeof(decimal))
                    {
                        //Gets the current value of the column
                        decimal val = (decimal)row[columnName];
                        //Get the parrent datarow
                        DataRow wpRow = GetParentWPRow(sourceTable.DataSet, row);
                        //Get the start year month and end year month for the currenct cost center
                        YearMonth startYearMonth = new YearMonth((int)wpRow["StartYearMonth"]);
                        YearMonth endYearMonth   = new YearMonth((int)wpRow["EndYearMonth"]);
                        //Calculate the existing value for each month in the date interval
                        int       numberOfMonths  = endYearMonth.GetMonthsDiffrence(startYearMonth) + 1;
                        decimal[] yearMonthValues = Rounding.Divide(val, numberOfMonths);
                        decimal   newValue        = 0;
                        //Calculates the new value for each month and sum it
                        for (YearMonth currentYearMonth = new YearMonth(startYearMonth.Value); currentYearMonth.Value <= endYearMonth.Value; currentYearMonth.AddMonths(1))
                        {
                            int valueIterator = currentYearMonth.GetMonthsDiffrence(startYearMonth);
                            newValue += converter.GetConversionValue(yearMonthValues[valueIterator], costCenterCurrency, currentYearMonth, associateCurrency);
                        }
                        //Updates the value
                        row[columnName] = Rounding.Round(newValue);
                    }
                }
            }
        }