@@ -489,5 +489,91 @@ public void TestTransportModeWithComfort(ZUGFeRDVersion version)
489
489
InvoiceDescriptor loadedInvoice = InvoiceDescriptor . Load ( ms ) ;
490
490
Assert . IsNull ( loadedInvoice . TransportMode ) ; // not supported in comfort profile
491
491
} // !TestTransportModeWithExtended()
492
+
493
+
494
+ // Test for rule PEPPOL-EN16931-R046
495
+ [ TestMethod ]
496
+ [ DataRow ( ZUGFeRDVersion . Version20 ) ]
497
+ [ DataRow ( ZUGFeRDVersion . Version23 ) ]
498
+ public void TestGrossPriceRepresentationForXRechnungAndNotXRechnungNegativeCase ( ZUGFeRDVersion version )
499
+ {
500
+ decimal grossPrice = 10.1m ;
501
+ decimal netPrice = 10.0m ;
502
+ decimal discountPercent = 10.0m ;
503
+ decimal discountAmount = 0.1m ;
504
+
505
+ InvoiceDescriptor desc = this . _InvoiceProvider . CreateInvoice ( ) ;
506
+ desc . TradeLineItems . Clear ( ) ;
507
+
508
+ TradeLineItem item = desc . AddTradeLineItem ( "Test" ,
509
+ netPrice , // net unit price
510
+ "Test" ,
511
+ QuantityCodes . C62 ,
512
+ 1 ,
513
+ grossPrice , // gross unit price
514
+ 1 ) ;
515
+
516
+ MemoryStream ms = new MemoryStream ( ) ;
517
+ desc . Save ( ms , ZUGFeRDVersion . Version23 , Profile . Extended ) ;
518
+
519
+ InvoiceDescriptor zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge = InvoiceDescriptor . Load ( ms ) ;
520
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) . Count , 1 ) ;
521
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GrossUnitPrice , grossPrice ) ;
522
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) . Count , 0 ) ;
523
+
524
+ ms = new MemoryStream ( ) ;
525
+ desc . Save ( ms , ZUGFeRDVersion . Version23 , Profile . XRechnung ) ;
526
+
527
+ InvoiceDescriptor zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge = InvoiceDescriptor . Load ( ms ) ;
528
+ Assert . AreEqual ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) . Count , 1 ) ;
529
+ Assert . AreEqual ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GrossUnitPrice , null ) ;
530
+ Assert . AreEqual ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) . Count , 0 ) ;
531
+ } // !TestGrossPriceRepresentationForXRechnungAndNotXRechnungNegativeCase()
532
+
533
+
534
+ // Test for rule PEPPOL-EN16931-R046
535
+ [ TestMethod ]
536
+ [ DataRow ( ZUGFeRDVersion . Version20 ) ]
537
+ [ DataRow ( ZUGFeRDVersion . Version23 ) ]
538
+ public void TestGrossPriceRepresentationForXRechnungAndNotXRechnungPositiveCase ( ZUGFeRDVersion version )
539
+ {
540
+ decimal grossPrice = 10.1m ;
541
+ decimal netPrice = 10.0m ;
542
+ decimal discountPercent = 10.0m ;
543
+ decimal discountAmount = 0.1m ;
544
+
545
+ InvoiceDescriptor desc = this . _InvoiceProvider . CreateInvoice ( ) ;
546
+ desc . TradeLineItems . Clear ( ) ;
547
+
548
+ TradeLineItem item = desc . AddTradeLineItem ( "Test" ,
549
+ netPrice , // net unit price
550
+ "Test" ,
551
+ QuantityCodes . C62 ,
552
+ 1 ,
553
+ grossPrice , // gross unit price
554
+ 1 ) ;
555
+
556
+ item . AddTradeAllowanceCharge ( true , CurrencyCodes . EUR , grossPrice , discountAmount , "Discount" , AllowanceReasonCodes . Discount ) ;
557
+
558
+ MemoryStream ms = new MemoryStream ( ) ;
559
+ desc . Save ( ms , ZUGFeRDVersion . Version23 , Profile . Extended ) ;
560
+
561
+ InvoiceDescriptor zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge = InvoiceDescriptor . Load ( ms ) ;
562
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) . Count , 1 ) ;
563
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GrossUnitPrice , grossPrice ) ;
564
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) . Count , 1 ) ;
565
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) [ 0 ] . BasisAmount , grossPrice ) ;
566
+ Assert . AreEqual ( zugferd23ExtendedInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) [ 0 ] . ActualAmount , discountAmount ) ;
567
+
568
+ ms = new MemoryStream ( ) ;
569
+ desc . Save ( ms , ZUGFeRDVersion . Version23 , Profile . XRechnung ) ;
570
+
571
+ InvoiceDescriptor zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge = InvoiceDescriptor . Load ( ms ) ;
572
+ Assert . AreEqual ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) . Count , 1 ) ;
573
+ Assert . AreEqual ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GrossUnitPrice , grossPrice ) ;
574
+ Assert . AreEqual ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) . Count , 1 ) ;
575
+ Assert . IsNull ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) [ 0 ] . BasisAmount ) ; // not written in XRechnung
576
+ Assert . AreEqual ( zugferd23XRechnungInvoiceWithGrossWithoutAllowanceCharge . GetTradeLineItems ( ) [ 0 ] . GetTradeAllowanceCharges ( ) [ 0 ] . ActualAmount , discountAmount ) ;
577
+ } // !TestGrossPriceRepresentationForXRechnungAndNotXRechnungPositiveCase()
492
578
}
493
579
}
0 commit comments