Esempio n. 1
0
        public decimal GetPrice()
        {
            AbstractCalculatorDecorator currentDecorator;

            // base
            BaseCalculatorComponent baseComponent
                = new BaseCalculatorComponent(BasicPriceList.TaxModeNames[0], BasicPriceList.OperationRangeNames[5], new BasicPriceList());

            // Employees decorator
            EmployeesCalculatorDecorator employeeDecorator = new EmployeesCalculatorDecorator(baseComponent, 3, 300);

            employeeDecorator.EmployeeCount = 4;
            currentDecorator = employeeDecorator;

            // VED decorator
            VEDExportImportDecorator vedDecorator = new VEDExportImportDecorator(currentDecorator, 5000);

            currentDecorator = vedDecorator;

            // Currency account decorator
            CurrencyAccountCountDecorator currencyDecorator = new CurrencyAccountCountDecorator(currentDecorator, 1000, 2);

            currentDecorator = currencyDecorator;

            // KKM decorator
            KKMDecorator kkmDecorator = new KKMDecorator(currencyDecorator, 2, 1, 3000);

            currentDecorator = kkmDecorator;

            // Branches decorator
            //BranchesDecorator branchesDecorator = new BranchesDecorator(currentDecorator, 5000);
            //currentDecorator = branchesDecorator;

            // Leasing/Credit
            LeasingCreditDecorator leasingCreditDecorator = new LeasingCreditDecorator(currentDecorator, 2000);

            currentDecorator = leasingCreditDecorator;

            // Expats decorator
            ExpatsDecorator expatsDecorator = new ExpatsDecorator(currentDecorator, 3, 500);

            currentDecorator = expatsDecorator;

            // Client bank decorator
            ClientBankDecorator clientBankDecorator = new ClientBankDecorator(currentDecorator, 5000);

            currentDecorator = clientBankDecorator;

            // Primary documents decorator
            PrimaryDocumentsDecorator primaryDocumentsDecorator = new PrimaryDocumentsDecorator(currentDecorator, baseComponent, 30);

            currentDecorator = primaryDocumentsDecorator;

            // Fixed assets decorator
            FixedAssetsDecorator fixedAssetsDecorator = new FixedAssetsDecorator(currentDecorator, 3000);

            currentDecorator = fixedAssetsDecorator;

            // Manufacture decorator
            ManufactureDecorator manufactureDecorator = new ManufactureDecorator(currentDecorator, baseComponent, 30);

            currentDecorator = manufactureDecorator;

            // LAST decorator
            return(currentDecorator.GetPrice());
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //AbstractCalculatorDecorator currentDecorator;

            // Base
            BaseCalculatorComponent baseComponent
                = new BaseCalculatorComponent(cmb_taxRegime.SelectedValue.ToString(), cmb_operationCountRanges.SelectedValue.ToString(), new BasicPriceList());

            ICalculatorComponent currentComponent = baseComponent;

            // Employees decorator
            EmployeesCalculatorDecorator employeeDecorator = new EmployeesCalculatorDecorator(currentComponent, BASE_EMPLOYEE_COUNT, EXTRA_EMPLOYEE_PRICE);

            employeeDecorator.EmployeeCount = nud_employees.Value.Value;
            currentComponent = employeeDecorator;

            // VED decorator
            if (chk_ved.IsChecked.Value)
            {
                VEDExportImportDecorator vedDecorator = new VEDExportImportDecorator(currentComponent, VED_PRICE);
                currentComponent = vedDecorator;
            }
            // Currency account decorator
            CurrencyAccountCountDecorator currencyDecorator
                = new CurrencyAccountCountDecorator(currentComponent, price: CURRENCY_ACCOUNT_PRICE, accountCount: nud_currencyAccounts.Value.Value);

            currentComponent = currencyDecorator;

            // KKM decorator
            KKMDecorator kkmDecorator = new KKMDecorator(currentComponent, nud_kkmCount.Value.Value, BASE_KKM_COUNT, EXTRA_KKM_PRICE);

            currentComponent = kkmDecorator;

            // Branches decorator
            if (chk_branches.IsChecked.Value)
            {
                BranchesDecorator branchesDecorator
                    = new BranchesDecorator(currentComponent, EXTRA_BRANCH_PRICE);
                currentComponent = branchesDecorator;
            }
            // Leasing/Credit
            if (chk_leasingCredits.IsChecked.Value)
            {
                LeasingCreditDecorator leasingCreditDecorator = new LeasingCreditDecorator(currentComponent, LEASING_CREDIT_PRICE);
                currentComponent = leasingCreditDecorator;
            }
            // Expats decorator
            ExpatsDecorator expatsDecorator = new ExpatsDecorator(currentComponent, nud_expatCount.Value.Value, EXPAT_PRICE);

            currentComponent = expatsDecorator;

            // Client bank decorator
            if (chk_clientBank.IsChecked.Value)
            {
                ClientBankDecorator clientBankDecorator = new ClientBankDecorator(currentComponent, CLIENT_BANK_PRICE);
                currentComponent = clientBankDecorator;
            }
            // Primary documents decorator
            if (chk_primaryDocuments.IsChecked.Value)
            {
                PrimaryDocumentsDecorator primaryDocumentsDecorator = new PrimaryDocumentsDecorator(currentComponent, baseComponent, PRIMERY_DOCUMENTS_PERCENT);
                currentComponent = primaryDocumentsDecorator;
            }
            // Fixed assets decorator
            if (chk_fixedAssets.IsChecked.Value)
            {
                FixedAssetsDecorator fixedAssetsDecorator = new FixedAssetsDecorator(currentComponent, FIXED_ASSETS_PRICE);
                currentComponent = fixedAssetsDecorator;
            }
            // Manufacture decorator
            if (chk_manufacture.IsChecked.Value)
            {
                ManufactureDecorator manufactureDecorator = new ManufactureDecorator(currentComponent, baseComponent, MANUFACTURE_PERCENT);
                currentComponent = manufactureDecorator;
            }

            // RESULT

            lbl_result.Content = currentComponent.GetPrice() * HIDDEN_COEFFICIENT + " rub.";

            //
            // Additional services
            //

            DummyBaseComponent   dummy          = new DummyBaseComponent();
            ICalculatorComponent addServCurrent = dummy;

            if (chk_keepingDocumentsOfPastYears.IsChecked.Value)
            {
                KeepingDocumentsOFPastYears keepingDecor = new KeepingDocumentsOFPastYears(addServCurrent, KEEPING_DOCUMENTS_OF_PAST_YEARS_PRICE);
                addServCurrent = keepingDecor;
            }

            if (chk_preparingDocumentsForTrading.IsChecked.Value)
            {
                PreparingDocumentsForBargainingDecorator preparingDocumentsDecor = new PreparingDocumentsForBargainingDecorator(addServCurrent, PREPARING_DOCUMENTS_FOR_BARGAINING_PRICE);
                addServCurrent = preparingDocumentsDecor;
            }

            if (chk_resubmissionOfDocuments.IsChecked.Value)
            {
                ResubmissionOfReport resubmissionDecor = new ResubmissionOfReport(addServCurrent, RESUBMISSION_OF_REPORT_PRICE);
                addServCurrent = resubmissionDecor;
            }
            // RESULT
            lbl_AdditionalServiceResult.Content = addServCurrent.GetPrice() + " rub.";
        }