Exemplo n.º 1
0
        private void calculate_pem_total(ActivityRates activityRates)
        {
            if (objectListView_documents.Items.Count > 0 && activityRates.LanguageRateName.Trim() != string.Empty)
            {
                numericUpDown_pem_rate_total.Value = 0;
                label_rate_currency.Text           = activityRates.LanguageRateCurrency;

                var tcc = new TextComparer {
                    Type = TextComparer.ComparisonType.Words
                };


                var dictTcas = new Dictionary <string, List <DocumentActivity> >();
                foreach (var documentActivity in DocumentActivities)
                {
                    if (!dictTcas.ContainsKey(documentActivity.DocumentId))
                    {
                        dictTcas.Add(documentActivity.DocumentId, new List <DocumentActivity> {
                            documentActivity
                        });
                    }
                    else
                    {
                        dictTcas[documentActivity.DocumentId].Add(documentActivity);
                    }
                }


                foreach (var kvp in dictTcas)
                {
                    var mergedDocuments = new MergedDocuments(kvp.Value, Activity, tcc, activityRates);


                    if (mergedDocuments.LanguageRate != null)
                    {
                        var exactWordsPem = mergedDocuments.LanguageRate.Rate100 * mergedDocuments.ExactWords;
                        var p99WordsPem   = mergedDocuments.LanguageRate.Rate95 * mergedDocuments.Fuzzy99Words;
                        var p94WordsPem   = mergedDocuments.LanguageRate.Rate85 * mergedDocuments.Fuzzy94Words;
                        var p84WordsPem   = mergedDocuments.LanguageRate.Rate75 * mergedDocuments.Fuzzy84Words;
                        var p74WordsPem   = mergedDocuments.LanguageRate.Rate50 * mergedDocuments.Fuzzy74Words;
                        var newWordsPem   = mergedDocuments.LanguageRate.RateNew * mergedDocuments.NewWords;

                        var totalWordsPem = exactWordsPem + p99WordsPem + p94WordsPem + p84WordsPem + p74WordsPem + newWordsPem;

                        numericUpDown_pem_rate_total.Value += totalWordsPem;
                    }
                }
            }
            else
            {
                numericUpDown_pem_rate_total.Value = 0;
                label_rate_currency.Text           = Tracked.Settings.GetGeneralProperty("defaultCurrency").Value;
            }

            check_activity_rate_total();
        }
Exemplo n.º 2
0
        private void comboBox_pem_rates_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (IsLoading)
            {
                return;
            }

            var cbi = (ComboboxItem)comboBox_pem_rates.SelectedItem;

            if (cbi.Value != null)
            {
                if (cbi.Value.GetType() == typeof(ActivityRates))
                {
                    var prg = (ActivityRates)cbi.Value;
                    ActivityRates = prg.Clone() as ActivityRates;
                }
                else if (cbi.Value.GetType() == typeof(LanguageRateGroup))
                {
                    var prg = (LanguageRateGroup)cbi.Value;
                    SetActivityRateFromLanguageRate(prg);

                    Activity.LanguageRateChecked = checkBox_language_rate.Checked;
                    //if the pem rate is specified, then the curreny associated with this rate takes precedence
                    //you cannot have multiple currencies related to one activity
                    ActivityRates.HourlyRateCurrency = prg.Currency;
                }
                else
                {
                    SetActivityRateFromLanguageRate(null);
                }

                calculate_pem_total(ActivityRates);

                if (ActivityRates != null)
                {
                    label_hourly_rate_curency.Text = ActivityRates.LanguageRateCurrency;
                }

                linkLabel_pem_rate_view_details.Enabled = true;
            }
            else
            {
                numericUpDown_pem_rate_total.Value = 0;
                label_rate_currency.Text           = Tracked.Settings.GetGeneralProperty("defaultCurrency").Value;

                linkLabel_pem_rate_view_details.Enabled = false;
            }
        }
Exemplo n.º 3
0
        private void InitializeRatesTab()
        {
            var acc = new Accordion
            {
                CheckBoxMargin   = new Padding(2),
                ContentMargin    = new Padding(15, 5, 15, 5),
                ContentPadding   = new Padding(1),
                Insets           = new Padding(5),
                ControlBackColor = Color.White,
                ContentBackColor = Color.CadetBlue
            };

            panel_activity_rates_parent.Controls.Add(acc);

            panel_language_rate.Dock = DockStyle.Fill;
            panel_hourly_rate.Dock   = DockStyle.Fill;
            panel_custom_rate.Dock   = DockStyle.Fill;

            acc.Add(panel_language_rate, "Language Rate", PluginResources.Select_a_language_rate, 0, true, contentBackColor: Color.Transparent);
            acc.Add(panel_hourly_rate, "Hourly Rate", PluginResources.Specify_an_hourly_rate, 1, true, contentBackColor: Color.Transparent);
            acc.Add(panel_custom_rate, "Custom Rate", PluginResources.Specify_a_custom_rate, 0, false, contentBackColor: Color.Transparent);


            checkBox_hourly_rate_CheckedChanged(null, null);
            checkBox_pem_rate_CheckedChanged(null, null);
            checkBox_custome_rate_CheckedChanged(null, null);


            checkBox_custom_rate.Checked          = Activity.CustomRateChecked;
            textBox_custom_rate_description.Text  = Activity.DocumentActivityRates.CustomRateDescription;
            numericUpDown_custom_rate_total.Value = Convert.ToDecimal(Activity.DocumentActivityRates.CustomRateTotal);

            textBox_hourly_rate_description.Text   = Activity.DocumentActivityRates.HourlyRateDescription;
            textBox_language_rate_description.Text = Activity.DocumentActivityRates.LanguageRateDescription;

            if (objectListView_documents.Items.Count > 0)
            {
                checkBox_language_rate.Enabled = true;
            }
            else
            {
                checkBox_language_rate.Enabled = false;
                checkBox_language_rate.Checked = false;
            }


            ActivityRates = Activity.DocumentActivityRates.Clone() as ActivityRates;


            #region  |  PEM combobox  |

            comboBox_pem_rates.BeginUpdate();

            comboBox_pem_rates.Items.Clear();
            var _cbi = new ComboboxItem(@"<empty>", null);
            comboBox_pem_rates.Items.Add(_cbi);

            if (IsEdit)
            {
                if (Activity.DocumentActivityRates.LanguageRateId > -1 && Activity.DocumentActivityRates.LanguageRateName.Trim() != string.Empty)
                {
                    var cbi = new ComboboxItem(Activity.DocumentActivityRates.LanguageRateName + @" <saved version>", Activity.DocumentActivityRates.Clone() as ActivityRates);
                    comboBox_pem_rates.Items.Add(cbi);
                }
            }

            foreach (var prg in Tracked.Settings.LanguageRateGroups)
            {
                var cbi = new ComboboxItem(prg.Name, prg.Clone() as LanguageRateGroup);
                comboBox_pem_rates.Items.Add(cbi);
            }
            comboBox_pem_rates.Sorted = true;
            comboBox_pem_rates.EndUpdate();

            #endregion


            if (!IsEdit)
            {
                #region  |  hourly  rate  |

                linkLabel_get_default_hourly_rate_LinkClicked(null, null);
                linkLabel_get_total_hours_elapsed_from_documents_LinkClicked(null, null);
                calculate_hourly_rate();

                if (numericUpDown_hourly_rate_total.Value > 0)
                {
                    checkBox_hourly_rate.Checked = true;
                }

                #endregion

                #region  |  PEM Rate  |


                var selectedIndex       = 0;
                var foundPriceRateGroup = false;
                LanguageRateGroup prg   = null;
                if (CompanyProfile != null && CompanyProfile.Id > -1)
                {
                    foreach (ComboboxItem cbi in comboBox_pem_rates.Items)
                    {
                        if (cbi.Value != null && cbi.Value.GetType() == typeof(LanguageRateGroup))
                        {
                            prg = (LanguageRateGroup)cbi.Value;
                            if (prg.Id == CompanyProfile.ProfileRate.LanguageRateId)
                            {
                                foundPriceRateGroup = true;
                                break;
                            }
                            selectedIndex++;
                        }
                        else
                        {
                            selectedIndex++;
                        }
                    }
                }
                comboBox_pem_rates.SelectedIndex = foundPriceRateGroup ? selectedIndex : 0;



                if (objectListView_documents.Items.Count > 0)
                {
                    checkBox_language_rate.Checked = foundPriceRateGroup;

                    SetActivityRateFromLanguageRate(prg);
                }



                #endregion


                checkBox_includeTagsInComparison.Checked = CompanyProfile == null || CompanyProfile.ComparerOptions.IncludeTagsInComparison;
                checkBox_group_changes.Checked           = CompanyProfile == null || CompanyProfile.ComparerOptions.ConsolidateChanges;
                comboBox_comparisonType.SelectedIndex    = CompanyProfile != null ? CompanyProfile.ComparerOptions.ComparisonType : 0;
            }
            else
            {
                #region  |  hourly rate  |

                numericUpDown_hourly_rate_rate.Value  = Convert.ToDecimal(Activity.DocumentActivityRates.HourlyRateRate);
                numericUpDown_hourly_rate_hours.Value = Convert.ToDecimal(Activity.DocumentActivityRates.HourlyRateQuantity);
                numericUpDown_hourly_rate_total.Value = Convert.ToDecimal(Activity.DocumentActivityRates.HourlyRateTotal);
                checkBox_hourly_rate.Checked          = Activity.HourlyRateChecked;

                label_hourly_rate_curency.Text = Activity.DocumentActivityRates.HourlyRateCurrency;

                #endregion

                #region  |  PEM Rate  |


                var selectedIndex       = 0;
                var foundPriceRateGroup = false;
                if (Activity.DocumentActivityRates.LanguageRateId > -1 && Activity.DocumentActivityRates.LanguageRateName.Trim() != string.Empty)
                {
                    foreach (ComboboxItem cbi in comboBox_pem_rates.Items)
                    {
                        if (cbi.Value != null && cbi.Value.GetType() == typeof(ActivityRates))
                        {
                            var prg = cbi.Value as ActivityRates;
                            if (prg != null && prg.LanguageRateId == Activity.DocumentActivityRates.LanguageRateId)
                            {
                                foundPriceRateGroup = true;
                                break;
                            }
                            selectedIndex++;
                        }
                        else
                        {
                            selectedIndex++;
                        }
                    }
                }

                if (!foundPriceRateGroup)
                {
                    foreach (ComboboxItem cbi in comboBox_pem_rates.Items)
                    {
                        if (cbi.Value != null && cbi.Value.GetType() == typeof(LanguageRateGroup))
                        {
                            var prg = (LanguageRateGroup)cbi.Value;

                            if (prg.Id == Activity.DocumentActivityRates.LanguageRateId)
                            {
                                foundPriceRateGroup = true;
                                break;
                            }
                            selectedIndex++;
                        }
                        else
                        {
                            selectedIndex++;
                        }
                    }
                }


                comboBox_pem_rates.SelectedIndex = foundPriceRateGroup ? selectedIndex : 0;

                checkBox_language_rate.Checked     = Activity.LanguageRateChecked;
                numericUpDown_pem_rate_total.Value = Convert.ToDecimal(Activity.DocumentActivityRates.LanguageRateTotal);

                if (foundPriceRateGroup)
                {
                    label_rate_currency.Text       = Activity.DocumentActivityRates.LanguageRateCurrency;
                    label_hourly_rate_curency.Text = Activity.DocumentActivityRates.HourlyRateCurrency;
                }
                else
                {
                    label_rate_currency.Text = Tracked.Settings.GetGeneralProperty("defaultCurrency").Value;
                }



                #endregion

                checkBox_includeTagsInComparison.Checked = Activity.ComparisonOptions.IncludeTagsInComparison;
                checkBox_group_changes.Checked           = Activity.ComparisonOptions.ConsolidateChanges;
                comboBox_comparisonType.SelectedIndex    = Activity.ComparisonOptions.ComparisonType;
            }


            Activity.DocumentActivityRates.CustomRateCurrency = Activity.DocumentActivityRates.HourlyRateCurrency;
            label_custom_rate_currency.Text = Activity.DocumentActivityRates.CustomRateCurrency;

            label_hourly_rate_curency_TextChanged(null, null);

            comboBox_billable_SelectedIndexChanged(null, null);


            if (comboBox_pem_rates.SelectedIndex == 0)
            {
                label_rate_currency.Text = label_hourly_rate_curency.Text;
            }
        }