Пример #1
0
        private static void CalculateUserEstimatedBasicFee(DateRange invoicePeriod, UserInvoice userEstimatedInvoice, int userCount, FeeConfig feeConfig)
        {
            Contract.Requires(invoicePeriod != null);
            Contract.Requires(userEstimatedInvoice != null);
            Contract.Requires(feeConfig != null);
            Contract.Requires(userCount > 0);

            userEstimatedInvoice.GetBasicFee().CleanWaterFee = (invoicePeriod.GetMonths() * feeConfig.GetMonthlyCleanWaterBasicFeeWithoutVAT() / userCount).RoundToCents();
            userEstimatedInvoice.GetBasicFee().WasteWaterFee = (invoicePeriod.GetMonths() * feeConfig.GetMonthlyWasteWaterBasicFeeWithoutVAT() / userCount).RoundToCents();
        }
Пример #2
0
        private void AssertInvoicesFee(InvoiceShared expected, InvoiceShared actual)
        {
            Assert.AreEqual(expected.GetBasicFee().CleanWaterFee, actual.GetBasicFee().CleanWaterFee, $"different clean water basic fee of invoice {actual.Id}");
            Assert.AreEqual(expected.GetBasicFee().WasteWaterFee, actual.GetBasicFee().WasteWaterFee, $"different waste water basic fee of invoice {actual.Id}");
            Assert.AreEqual(expected.GetUsageFee().CleanWaterFee, actual.GetUsageFee().CleanWaterFee, $"different clean water usage fee of invoice {actual.Id}");
            Assert.AreEqual(expected.GetUsageFee().WasteWaterFee, actual.GetUsageFee().WasteWaterFee, $"different waste water usage fee of invoice {actual.Id}");

            Assert.AreEqual(expected.UserInvoices.Count, actual.UserInvoices.Count);
            for (int i = 0; i < expected.UserInvoices.Count; i++)
            {
                UserInvoice expectedUserInvoice = expected.UserInvoices[i];
                UserInvoice actualUserInvoice   = actual.UserInvoices.GetInvoiceByOwner(expectedUserInvoice.InvoiceOwner);
                Assert.IsNotNull(actualUserInvoice, $"missing user '{actualUserInvoice.InvoiceOwner}' invoice {actual.Id}");

                Assert.AreEqual(expectedUserInvoice.GetBasicFee().CleanWaterFee, actualUserInvoice.GetBasicFee().CleanWaterFee,
                                $"different clean water basic fee of user '{actualUserInvoice.InvoiceOwner}' invoice {actual.Id}");
                Assert.AreEqual(expectedUserInvoice.GetBasicFee().WasteWaterFee, actualUserInvoice.GetBasicFee().WasteWaterFee,
                                $"different waste water basic fee of user '{actualUserInvoice.InvoiceOwner}' invoice {actual.Id}");
                Assert.AreEqual(expectedUserInvoice.GetUsageFee().CleanWaterFee, actualUserInvoice.GetUsageFee().CleanWaterFee,
                                $"different clean water usage fee of user '{actualUserInvoice.InvoiceOwner}' invoice {actual.Id}");
                Assert.AreEqual(expectedUserInvoice.GetUsageFee().WasteWaterFee, actualUserInvoice.GetUsageFee().WasteWaterFee,
                                $"different waste water usage fee of user '{actualUserInvoice.InvoiceOwner}' invoice {actual.Id}");
            }
        }
Пример #3
0
        private static void ShowUserInvoice(DataGridViewRow row, InvoiceShared invoice, UserInvoice userInvoice, Price.ShowFormat priceFormat)
        {
            Contract.Requires(row != null);
            Contract.Requires(invoice != null);
            Contract.Requires(userInvoice != null);

            row.Cells[0].Value           = userInvoice.InvoiceOwner;
            row.Cells[0].Tag             = invoice.Id;
            row.Cells[1].Style.BackColor = Color.LightGray;

            row.Cells[2].Value = userInvoice.InvoiceOwner;

            row.Cells[3].Value           = userInvoice.GetReadOut().ToString();
            row.Cells[3].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(inv => inv.GetReadOut().Sum(), userInv => userInv.GetReadOut().Sum()) ?
                                           Color.LightPink : row.Cells[3].Style.BackColor;

            row.Cells[4].Value           = userInvoice.GetConsumption().ToString();
            row.Cells[4].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(inv => inv.GetConsumption().Sum(), userInv => userInv.GetConsumption().Sum()) ?
                                           Color.LightPink : row.Cells[4].Style.BackColor;

            row.Cells[5].Value           = userInvoice.GetBasicFee().ToString(priceFormat);
            row.Cells[5].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(
                inv => (inv.GetBasicFee().GetTotalPrice().VATLess),
                userInv => (userInv.GetBasicFee().GetTotalPrice().VATLess)) ?
                                           Color.LightPink : row.Cells[5].Style.BackColor;

            row.Cells[6].Value           = userInvoice.GetUsageFee().ToString(priceFormat);
            row.Cells[6].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(
                inv => (inv.GetUsageFee().GetTotalPrice().VATLess),
                userInv => (userInv.GetUsageFee().GetTotalPrice().VATLess)) ?
                                           Color.LightPink : row.Cells[6].Style.BackColor;

            row.Cells[7].Value = invoice.Balanced;

            row.Cells[8].Value           = userInvoice.GetTotalPrice().ToString(Price.ShowFormat.both);
            row.Cells[8].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(
                inv => (inv.GetTotalPrice().VATLess + inv.GetTotalPrice().WithVAT),
                userInv => (userInv.GetTotalPrice().VATLess + userInv.GetTotalPrice().WithVAT)) ?
                                           Color.LightPink : row.Cells[8].Style.BackColor;

            row.Tag = userInvoice;
        }