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); }
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; }