Beispiel #1
0
        public static bool calculateEverything(Worker worker, double bas, int yrs, double bon, double tax, bool rel, bool city)
        {
            if (bas == 0)
            {
                throw new ExceptionNullValue();
            }
            Salarycalc salaryCalc = new Salarycalc(bas, bon, yrs);

            salaryCalc.calc_brutto();

            Contributions contributions = new Contributions();

            contributions.calc_conts(salaryCalc.brutto);
            contributions.calc_health_conts(salaryCalc.brutto);

            Taxes_and_others TaO = new Taxes_and_others(tax, rel, city);

            TaO.calc_taxes(contributions);

            salaryCalc.calc_netto(contributions.ZUS, contributions.hc_asessed, TaO.tax_complete);

            bool added = DBManager.AddSalaryDB(worker, salaryCalc, TaO, contributions);

            if (added)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void calc_taxes(Contributions cont)
        {
            tax_base = cont.health_cont_base - calc_obt_costs();

            tax_1st_step = Math.Round((tax_base * tax_precent * 0.01), 2);

            if (relief)
            {
                tax_relief = 43.76;
            }
            else
            {
                tax_relief = 0;
            }

            tax_raw = tax_1st_step - tax_relief - cont.hc_deducted;
            if (tax_raw < 0)
            {
                tax_raw = 0;
            }
            tax_complete = Math.Round(tax_raw, MidpointRounding.AwayFromZero);
        }
        public static bool AddSalaryDB(Worker worker, Salarycalc salaryC, Taxes_and_others TaO, Contributions cont)
        {
            SalariesLINQDataContext db = new SalariesLINQDataContext(con);

            Salary salary = new Salary()
            {
                WorkerID           = worker.WorkerID,
                Base_sal           = salaryC.base_sal,
                Bonus              = salaryC.bonus,
                YearsInWork        = salaryC.years,
                ZUS                = cont.ZUS,
                HCDeducted         = cont.hc_deducted,
                HCAsessed          = cont.hc_asessed,
                WorksNotInLiveCity = TaO.otherCity,
                TaxPercent         = TaO.tax_precent,
                TaxRelief          = TaO.relief,
                Tax                = TaO.tax_complete,
                Brutto             = salaryC.brutto,
                Netto              = salaryC.netto,
                DateOfContributing = DateTime.Now
            };

            db.Salary.InsertOnSubmit(salary);

            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }