Exemplo n.º 1
0
        private static void CalculateUserEstimatedUsageFee(UserInvoice userEstimatedInvoice, FeeConfig feeConfig)
        {
            Contract.Requires(userEstimatedInvoice != null);
            Contract.Requires(feeConfig != null);

            userEstimatedInvoice.GetUsageFee().CleanWaterFee = (userEstimatedInvoice.GetConsumption().Estimated *feeConfig.GetMonthlyCleanWaterUsageFeeWithoutVAT()).RoundToCents();
            userEstimatedInvoice.GetUsageFee().WasteWaterFee = (userEstimatedInvoice.GetConsumption().Estimated *feeConfig.GetMonthlyWasteWaterUsageFeeWithoutVAT()).RoundToCents();
        }
Exemplo n.º 2
0
        private static ulong CalculateEstimatedUserConsumption(UserInvoice invoice, ulong realUserConsumption, ConsumptionValue commonConsumption)
        {
            Contract.Requires(commonConsumption != null);

            decimal estimatedUserConsumption = Convert.ToDecimal(commonConsumption.Estimated * realUserConsumption) / Convert.ToDecimal(commonConsumption.Real);

            invoice.GetConsumption().Estimated = Convert.ToUInt64(Math.Round(estimatedUserConsumption));
            return(invoice.GetConsumption().Estimated);
        }
Exemplo n.º 3
0
        private static ulong CalculateRealUserConsumption(DateRange readOutPeriod, UserInvoice prevInvoice, UserInvoice invoice, IEnumerable <MeterConfig> meterConfigs)
        {
            Contract.Requires(invoice != null);
            Contract.Requires(meterConfigs != null);

            ulong startRealReadOut = prevInvoice?.GetReadOut().Real ?? 0U;
            ulong endRealReadOut   = invoice.GetReadOut().Real;

            ulong realConsumption = CalculateConsumption(readOutPeriod, startRealReadOut, endRealReadOut, meterConfigs);

            invoice.GetConsumption().Real = realConsumption;

            return(realConsumption);
        }
Exemplo n.º 4
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;
        }