-
Notifications
You must be signed in to change notification settings - Fork 169
/
UtilityBill.cs
573 lines (432 loc) · 17.7 KB
/
UtilityBill.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
using indice.Edi.Serialization;
namespace indice.Edi.Tests.Models;
public class Interchange
{
[EdiValue("X(14)", Path = "STX/1/0")]
public string SenderCode { get; set; }
[EdiValue("X(35)", Path = "STX/1/1")]
public string SenderName { get; set; }
[EdiValue("9(6)", Path = "STX/3/0", Format = "yyMMdd", Description = "TRDT - Date")]
[EdiValue("9(6)", Path = "STX/3/1", Format = "HHmmss", Description = "TRDT - Time")]
public DateTime TransmissionStamp { get; set; }
public InterchangeHeader Head { get; set; }
public List<UtilityBill> Invoices { get; set; }
public InterchangeVatSummary Vat { get; set; }
public InterchangeTrailer Summary { get; set; }
}
[EdiMessage, EdiCondition("UTLHDR", Path = "MHD/1")]
public class InterchangeHeader
{
[EdiValue("9(4)"), EdiPath("TYP")]
public string TransactionCode { get; set; }
[EdiValue("9(1)", Path = "MHD/1/1")]
public int Version { get; set; }
[EdiValue("X(40)", Path = "CDT/1")]
public string ClientName { get; set; }
}
[EdiMessage, EdiCondition("UTLTLR", Path = "MHD/1")]
public class InterchangeTrailer
{
[EdiValue("9(1)", Path = "MHD/1/1")]
public int Version { get; set; }
}
[EdiMessage, EdiCondition("UVATLR", Path = "MHD/1")]
public class InterchangeVatSummary
{
[EdiValue("9(4)"), EdiPath("TYP")]
public string TransactionCode { get; set; }
[EdiValue("9(1)", Path = "MHD/1/1")]
public int Version { get; set; }
}
[EdiMessage, EdiCondition("UTLBIL", Path = "MHD/1")]
public class UtilityBill
{
[EdiValue("9(1)", Path = "MHD/1/1")]
public int Version { get; set; }
[EdiValue("X(17)", Path = "BCD/2/0", Description = "INVN - Date")]
public string InvoiceNumber { get; set; }
public MetetAdminNumber Meter { get; set; }
public ContractData SupplyContract { get; set; }
[EdiValue("X(3)", Path = "BCD/5/0", Description = "BTCD - Date")]
public BillTypeCode BillTypeCode { get; set; }
[EdiValue("9(6)", Path = "BCD/1/0", Format = "yyMMdd", Description = "TXDT - Date")]
public DateTime IssueDate { get; set; }
[EdiValue("9(6)", Path = "BCD/7/0", Format = "yyMMdd", Description = "SUMO - Date")]
public DateTime StartDate { get; set; }
[EdiValue("9(6)", Path = "BCD/7/1", Format = "yyMMdd", Description = "SUMO - Date")]
public DateTime EndDate { get; set; }
public UtilityBillTrailer Totals { get; set; }
public UtilityBillValueAddedTax Vat { get; set; }
public List<ConsumptionChargeCharge> Charges { get; set; }
public override string ToString() {
return string.Format("{0} TD:{1:d} F:{2:d} T:{3:d} Type:{4}", InvoiceNumber, IssueDate, StartDate, EndDate, BillTypeCode);
}
}
[EdiSegment, EdiPath("CCD")]
public class ConsumptionChargeCharge
{
[EdiValue("9(1)", Path = "CCD/0")]
public int SequenceNumber { get; set; }
[EdiValue("X(1)", Path = "CCD/1")]
public ChargeIndicator? ChargeIndicator { get; set; }
[EdiValue("9(1)", Path = "CCD/1/1")]
public int? ArticleNumber { get; set; }
[EdiValue("X(3)", Path = "CCD/1/2")]
public string SupplierCode { get; set; }
[EdiValue("X(6)", Path = "CCD/2/0", Description = "TCOD")]
public string TariffCode { get; set; }
[EdiValue("X(40)", Path = "CCD/2/1", Description = "TCOD")]
public string TariffDescription { get; set; }
[EdiValue("X(6)", Path = "CCD/3/0", Description = "TMOD")]
public string TariffCodeModifier1 { get; set; }
[EdiValue("X(6)", Path = "CCD/3/1", Description = "TMOD")]
public string TariffCodeModifier2 { get; set; }
[EdiValue("X(6)", Path = "CCD/3/2", Description = "TMOD")]
public string TariffCodeModifier3 { get; set; }
[EdiValue("X(6)", Path = "CCD/3/3", Description = "TMOD")]
public string TariffCodeModifier4 { get; set; }
[EdiValue("X(35)", Path = "CCD/4", Description = "MTNR")]
public string MeterNumber { get; set; }
[EdiValue("X(40)", Path = "CCD/5", Description = "MLOC")]
public string MeterLocation { get; set; }
[EdiValue("9(6)", Path = "CCD/6", Format = "yyMMdd", Description = "PRDT")]
public DateTime? PresentReadDate { get; set; }
[EdiValue("9(6)", Path = "CCD/7", Format = "yyMMdd", Description = "PVDT")]
public DateTime? PreviousReadDate { get; set; }
[EdiValue("9(3)", Path = "CCD/8", Description = "NDRP")]
public int? ReadingPeriod { get; set; }
[EdiValue("9(15)", Path = "CCD/9/0", Description = "PRRD")]
public decimal PresentReading { get; set; }
[EdiValue("X(4)", Path = "CCD/9/1", Description = "PRRD")]
public ReadingDataType? PresentReadingType { get; set; }
[EdiValue("9(15)", Path = "CCD/9/2", Description = "PRRD")]
public decimal PreviousReading { get; set; }
[EdiValue("X(4)", Path = "CCD/9/3", Description = "PRRD")]
public ReadingDataType? PreviousReadingType { get; set; }
[EdiValue("9(10)V9(3)", Path = "CCD/10/0", Description = "CONS")]
public decimal? UnitsConsumedBilling { get; set; }
[EdiValue("X(6)", Path = "CCD/10/1", Description = "CONS")]
public string UnitOfMeasureBilling { get; set; }
private string _UnitsNegativeBilling;
[EdiValue("X(4)", Path = "CCD/10/2", Description = "CONS")]
public string UnitsNegativeBilling {
get { return _UnitsNegativeBilling; }
set {
_UnitsNegativeBilling = value;
if (_UnitsNegativeBilling == "R") {
UnitsConsumedBilling = UnitsConsumedBilling * -1;
}
}
}
[EdiValue("9(10)V9(3)", Path = "CCD/11/0", Description = "CONB")]
public decimal? UnitsConsumedBase { get; set; }
[EdiValue("X(6)", Path = "CCD/11/1", Description = "CONB")]
public string UnitOfMeasureBase { get; set; }
private string _UnitsNegativeBase;
[EdiValue("X(4)", Path = "CCD/11/2", Description = "CONB")]
public string UnitsNegativeBase {
get { return _UnitsNegativeBase; }
set {
_UnitsNegativeBase = value;
if (_UnitsNegativeBase == "R") {
UnitsConsumedBase = UnitsConsumedBase * -1;
}
}
}
[EdiValue("X(3)", Path = "CCD/12/0", Description = "ADJF")]
public string AdjustmentFactorCode { get; set; }
[EdiValue("9(10)V9(5)", Path = "CCD/12/1", Description = "ADJF")]
public decimal AdjustmentFactorValue { get; set; }
[EdiValue("X(4)", Path = "CCD/12/2", Description = "ADJF")]
public string AdjustmentFactorNegativeIndicator { get; set; }
[EdiValue("9(10)V9(3)", Path = "CCD/13/0", Description = "CONA")]
public decimal UnitsConsumedAdjusted { get; set; }
[EdiValue("X(6)", Path = "CCD/13/1", Description = "CONA")]
public string UnitOfMeasureAdjusted { get; set; }
[EdiValue("X(4)", Path = "CCD/13/2", Description = "CONA")]
public string NegativeIndicatorAdjusted { get; set; }
[EdiValue("9(10)V9(5)", Path = "CCD/14", Description = "BPRI")]
public decimal? BasePriceUnit { get; set; }
[EdiValue("9(10)V9(3)", Path = "CCD/15/0", Description = "NUCT")]
public decimal UnitsBilled { get; set; }
[EdiValue("X(6)", Path = "CCD/15/1", Description = "NUCT")]
public string UnitOfMeasureBilled { get; set; }
[EdiValue("X(4)", Path = "CCD/15/2", Description = "NUCT")]
public string NegativeIndicatorBilled { get; set; }
[EdiValue("9(6)", Path = "CCD/16", Format = "yyMMdd", Description = "CSDT")]
public DateTime ChargeStartDate { get; set; }
[EdiValue("9(6)", Path = "CCD/17", Format = "yyMMdd", Description = "CEDT")]
public DateTime ChargeEndDate { get; set; }
[EdiValue("9(10)V9(5)", Path = "CCD/18", Description = "CPPU")]
public decimal? PricePerUnit { get; set; }
[EdiValue("9(10)V9(2)", Path = "CCD/18/0", Description = "CTOT")]
public decimal TotalChargeForChargeType { get; set; }
[EdiValue("X(4)", Path = "CCD/18/1", Description = "CTOT")]
public string TotalChargeCreditIndicator { get; set; }
[EdiValue("X(1)", Path = "CCD/19", Description = "TSUP")]
public string VatTypeOfSupply { get; set; }
[EdiValue("X(1)", Path = "CCD/20", Description = "VATC")]
public VatRateCategoryCode? VatRateCategoryCode { get; set; }
[EdiValue("9(3)V9(3)", Path = "CCD/21", Description = "VATP")]
public string VatRatePercentage { get; set; }
[EdiValue("X(17)", Path = "CCD/22/0", Description = "MSAD")]
public string MeterSubAddressCode { get; set; }
[EdiValue("X(40)", Path = "CCD/22/1", Description = "MSAD")]
public string MeterSubAddressLine { get; set; }
public override string ToString() {
return string.Format("SeqNum:{0} Type:{1}", SequenceNumber, ChargeIndicator);
}
}
[EdiSegment, EdiPath("BTL")]
public class UtilityBillTrailer
{
//[EdiValue("9(10)", Path = "BTL/0")]
//public decimal TotalPaymentDetails { get; set; }
[EdiValue("9(10)", Path = "BTL/1")]
public decimal TotalChargeBeforeVat { get; set; }
[EdiValue("9(10)", Path = "BTL/2")]
public decimal BillTotalVatAmmoutPayable { get; set; }
//[EdiValue("9(10)", Path = "BTL/3")]
//public decimal BalanceBroughtForward { get; set; }
[EdiValue("9(10)", Path = "BTL/4")]
public decimal TotalBillAmountPayable { get; set; }
public override string ToString() {
return string.Format("Net:{0} Vat:{1} Gross:{2}", TotalChargeBeforeVat, BillTotalVatAmmoutPayable, TotalBillAmountPayable);
}
}
[EdiSegment, EdiPath("MAN")]
public class MetetAdminNumber
{
static Dictionary<string, string> _distributorsIdentifier = new Dictionary<string, string>();
public MetetAdminNumber() {
if (_distributorsIdentifier == null || _distributorsIdentifier.Count() == 0) {
_distributorsIdentifier.Add("10", "Eastern Electricity");
_distributorsIdentifier.Add("11", "East Midlands Electricity");
_distributorsIdentifier.Add("12", "London Electricity");
_distributorsIdentifier.Add("13", "Manweb");
_distributorsIdentifier.Add("14", "Midlands Electricity");
_distributorsIdentifier.Add("15", "Northern Electricity");
_distributorsIdentifier.Add("16", "NORWEB");
_distributorsIdentifier.Add("17", "Scottish Hydro Electric");
_distributorsIdentifier.Add("18", "Scottish Power");
_distributorsIdentifier.Add("19", "SEEBOARD");
_distributorsIdentifier.Add("20", "Southern Electric");
_distributorsIdentifier.Add("21", "SWALEC");
_distributorsIdentifier.Add("22", "South Western Electricity");
_distributorsIdentifier.Add("23", "Yorkshire Electricity");
_distributorsIdentifier.Add("TR", "TRANSCO");
}
}
[EdiValue("9(10)", Path = "MAN/0", Description = "SEQA")]
public int FirstLevelSequenceNumber { get; set; }
[EdiValue("9(10)", Path = "MAN/1", Description = "SEQB")]
public int SecondLevelSequenceNumber { get; set; }
[EdiValue("X(2)", Path = "MAN/2/0", Description = "MADN")]
public string DistributorIdentifier { get; set; }
public string DistributorName {
get {
if (_distributorsIdentifier.ContainsKey(DistributorIdentifier))
return _distributorsIdentifier[DistributorIdentifier];
else
throw new ArgumentOutOfRangeException(DistributorIdentifier, "Unregistered distributor identifier");
}
}
[EdiValue("X(10)", Path = "MAN/2/1", Description = "MADN")]
public string UniqueReferenceNumber { get; set; }
[EdiValue("9(1)", Path = "MAN/2/2", Description = "MADN")]
public int? CheckDigit { get; set; }
[EdiValue("9(2)", Path = "MAN/2/3", Description = "MADN")]
public int? ProfileType { get; set; }
[EdiValue("9(3)", Path = "MAN/2/4", Description = "MADN")]
public int? MeterTimeSwitchDetails { get; set; }
[EdiValue("9(3)", Path = "MAN/2/5", Description = "MADN")]
public int? LineLossFactor { get; set; }
[EdiValue("X(35)", Path = "MAN/3", Description = "MTNR")]
public string MeterSerialNumber { get; set; }
[EdiValue("9(1)", Path = "MAN/4", Description = "NDIG")]
public int? NumberOfDigits { get; set; }
public override string ToString() {
return string.Format("SN:{0} PC:{1} LLFC:{2} UniqueId:{3} Distributor:{4}", MeterSerialNumber, ProfileType, LineLossFactor, UniqueReferenceNumber, DistributorIdentifier);
}
}
[EdiSegment, EdiPath("VAT")]
public class UtilityBillValueAddedTax
{
[EdiValue("9(10)", Path = "VAT/0", Description = "SEQA")]
public int FirstLevelSequenceNumber { get; set; }
[EdiValue("9(3)", Path = "VAT/1", Description = "NDVT")]
public int? NumberOfDays { get; set; }
[EdiValue("9(3)V9(3)", Path = "VAT/2", Description = "PNDP")]
public decimal? PercentageQualifyingFor { get; set; }
[EdiValue("X(1)", Path = "VAT/3", Description = "VATC")]
public VatRateCategoryCode VatRateCategoryCode { get; set; }
[EdiValue("9(3)", Path = "VAT/4", Description = "VATP")]
public decimal VatRatePercentage { get; set; }
[EdiValue("9(10)", Path = "VAT/5/0", Description = "UVLA")]
public decimal TotalChargeBeforeVat { get; set; }
[EdiValue("9(10)", Path = "VAT/6/0", Description = "UVTT")]
public decimal VatAmmountPayable { get; set; }
[EdiValue("9(10)V9(2)", Path = "VAT/7/0", Description = "UCSI")]
public decimal TotalChargeIncludingVat { get; set; }
[EdiValue("9(4)", Path = "VAT/8", Description = "NRIL")]
public int? NumberOfItemLines { get; set; }
[EdiValue("X(3)", Path = "VAT/9", Description = "RFLV")]
public ReasonForLowerVatRateType ReasonForLowerZeroVatRate { get; set; }//null-able
public override string ToString() {
return string.Format("Net:{0} Vat:{1} Gross:{2}", TotalChargeBeforeVat, VatAmmountPayable, TotalChargeIncludingVat);
}
}
[EdiSegment, EdiPath("CDA")]
public class ContractData
{
[EdiValue("X(17)", Path = "CDA/0", Description = "CPSC")]
public string CurrentPriceScheduleReference { get; set; }
[EdiValue("X(17)", Path = "CDA/1/0", Description = "ORNO")]
public string CustomerOrderNumber { get; set; }
[EdiValue("X(17)", Path = "CDA/1/1", Description = "ORNO")]
public string SupplierOrderNumber { get; set; }
[EdiValue("9(6)", Path = "CDA/1/2", Format = "yyMMdd", Description = "ORNO")]
public DateTime? DateOrderedPlacedByCustomer { get; set; }
[EdiValue("9(6)", Path = "CDA/1/3", Format = "yyMMdd", Description = "ORNO")]
public DateTime? DateOrderedReceivedBySupplier { get; set; }
[EdiValue("9(6)", Path = "CDA/2", Format = "yyMMdd", Description = "INSD")]
public DateTime? InstallationDate { get; set; }
[EdiValue("X(3)", Path = "CDA/3", Description = "REPE")]
public string RentalPeriod { get; set; }
public override string ToString() {
return string.Format("CON:{0} SON:{1}", CustomerOrderNumber, SupplierOrderNumber);
}
}
#region Edi Enumerations
public enum ChargeIndicator
{
ConsumptionOnly = 1,
CombinedConsumptionAndCharge = 2,
ChargeOnly_ConsumptionBased = 3,
ChargeOnly_Fixed = 4
}
public enum MeasureIndicator
{
//KVA = Kilovolt - ampere
//KWH = Kilowatt - hour
//KW = Kilowatt
//M3 = Cubic Metre (Gas only)
//CUFT = Cubic Feet (Gas only)
//1 = 1 Consumer Unit
}
public enum VatRateCategoryCode
{
/// <summary>
/// Edi Value Description : Low Rate
/// </summary>
L = 1,
/// <summary>
/// Edi Value Description : Standard Rate
/// </summary>
S,
/// <summary>
/// Edi Value Description : Exemption From VAT
/// </summary>
X,
/// <summary>
/// Edi Value Description : Services Outside The Scope of VAT
/// </summary>
O,
/// <summary>
/// Edi Value Description : Zero Rate
/// </summary>
Z,
/// <summary>
/// Edi Value Description : Standard Rate In Withdrawn Bill
/// </summary>
B,
/// <summary>
/// Edi Value Description : Lower Rate In Withdrawn Bill
/// </summary>
M,
/// <summary>
/// Edi Value Description : Zero Rate In Withdrawn Bill
/// </summary>
Q,
/// <summary>
/// Edi Value Description : Exemption From Vat In Withdrawn Bill
/// </summary>
U,
/// <summary>
/// Edi Value Description : Standard Rate (used in tradacoms as alternative)
/// </summary>
A,
}
public enum ReasonForLowerVatRateType
{
/// <summary>
/// Edi Value : L
/// Edi Description : Low Consumption
/// </summary>
L = 1,
/// <summary>
/// Edi Value : D
/// Edi Description : Domestic Usage
/// </summary>
D,
/// <summary>
/// Edi Value : C
/// Edi Description : Combined
/// </summary>
C,
}
public enum ReportPeriod
{
Monthly = 'M',
Quarterly = 'Q'
}
public enum BillTypeCode
{
/// <summary>
/// Edi Value : F
/// Edi Description : Final
/// Business Description : Last bill when an account is closed
/// </summary>
F = 1,
/// <summary>
/// Edi Value : N
/// Edi Description : Normal
/// Business Description : Normal Invoice
/// </summary>
N,
/// <summary>
/// Edi Value : W
/// Edi Description : Withdrawn
/// Business Description : Reverses a previous bill
/// </summary>
W
}
public enum ReadingDataType
{
NormalReading = 00,
Estimated_Computer_Reading = 02,
CustomersOwnReading = 04,
ExchangeMeterReading = 06,
ThirdPartyNormalReading = 09,
ThirdPartyEstimated_Computer_Reading = 11,
ReadingForInformationOnly = 12,
}
public enum DistributionBusinessCodes
{
Eastern_Electricity = 10,
East_Midlands_Electricity = 11,
London_Electricity = 12,
Manweb = 13,
Midlands_Electricity = 14,
Northern_Electricity = 15,
NORWEB = 16,
Scottish_Hydro_Electric = 17,
Scottish_Power = 18,
SEEBOARD = 19,
Southern_Electric = 20,
SWALEC = 21,
South_Western_Electricity = 22,
Yorkshire_Electricity = 23,
//TRANSCO = TR
}
#endregion