1818 */
1919using System ;
2020using System . Collections . Generic ;
21+ using System . IO ;
2122using System . Linq ;
22- using System . Text ;
2323using System . Xml ;
24- using System . Xml . XPath ;
25- using System . IO ;
2624
2725
2826namespace s2industries . ZUGFeRD
@@ -158,7 +156,7 @@ public override InvoiceDescriptor Load(Stream stream)
158156 } ;
159157 var financialCardId = XmlUtils . NodeAsString ( doc . DocumentElement , "//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:ApplicableTradeSettlementFinancialCard/ram:ID" , nsmgr ) ;
160158 var financialCardCardholderName = XmlUtils . NodeAsString ( doc . DocumentElement , "//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:ApplicableTradeSettlementFinancialCard/ram:CardholderName" , nsmgr ) ;
161-
159+
162160 if ( ! string . IsNullOrWhiteSpace ( financialCardId ) || ! string . IsNullOrWhiteSpace ( financialCardCardholderName ) )
163161 {
164162 _tempPaymentMeans . FinancialCard = new FinancialCard ( )
@@ -169,7 +167,7 @@ public override InvoiceDescriptor Load(Stream stream)
169167 }
170168
171169 retval . PaymentMeans = _tempPaymentMeans ;
172-
170+
173171 retval . BillingPeriodStart = XmlUtils . NodeAsDateTime ( doc . DocumentElement , "//ram:ApplicableHeaderTradeSettlement/ram:BillingSpecifiedPeriod/ram:StartDateTime" , nsmgr ) ;
174172 retval . BillingPeriodEnd = XmlUtils . NodeAsDateTime ( doc . DocumentElement , "//ram:ApplicableHeaderTradeSettlement/ram:BillingSpecifiedPeriod/ram:EndDateTime" , nsmgr ) ;
175173
@@ -193,18 +191,18 @@ public override InvoiceDescriptor Load(Stream stream)
193191 retval . CreditorBankAccounts . Add ( _account ) ;
194192 } // !for(i)
195193 }
196-
194+
197195 var specifiedTradeSettlementPaymentMeansNodes = doc . SelectNodes ( "//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans" , nsmgr ) ;
198196
199197 foreach ( var specifiedTradeSettlementPaymentMeansNode in specifiedTradeSettlementPaymentMeansNodes . OfType < XmlNode > ( ) )
200198 {
201199 var payerPartyDebtorFinancialAccountNode = specifiedTradeSettlementPaymentMeansNode . SelectSingleNode ( "ram:PayerPartyDebtorFinancialAccount" , nsmgr ) ;
202-
200+
203201 if ( payerPartyDebtorFinancialAccountNode == null )
204202 {
205203 continue ;
206204 }
207-
205+
208206 var _account = new BankAccount ( )
209207 {
210208 ID = XmlUtils . NodeAsString ( payerPartyDebtorFinancialAccountNode , ".//ram:ProprietaryID" , nsmgr ) ,
@@ -247,7 +245,7 @@ public override InvoiceDescriptor Load(Stream stream)
247245 XmlUtils . NodeAsDecimal ( node , ".//ram:CalculatedAmount" , nsmgr , 0 ) . Value ,
248246 default ( TaxTypes ) . FromString ( XmlUtils . NodeAsString ( node , ".//ram:TypeCode" , nsmgr ) ) ,
249247 default ( TaxCategoryCodes ) . FromString ( XmlUtils . NodeAsString ( node , ".//ram:CategoryCode" , nsmgr ) ) ,
250- 0 ,
248+ XmlUtils . NodeAsDecimal ( node , ".//ram:AllowanceChargeBasisAmount" , nsmgr ) ,
251249 default ( TaxExemptionReasonCodes ) . FromString ( XmlUtils . NodeAsString ( node , ".//ram:ExemptionReasonCode" , nsmgr ) ) ,
252250 XmlUtils . NodeAsString ( node , ".//ram:ExemptionReason" , nsmgr ) ) ;
253251 }
@@ -304,7 +302,7 @@ public override InvoiceDescriptor Load(Stream stream)
304302 retval . DuePayableAmount = XmlUtils . NodeAsDecimal ( doc . DocumentElement , "//ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:DuePayableAmount" , nsmgr , 0 ) . Value ;
305303
306304 // in this version we should only have on invoice referenced document but nevertheless...
307- foreach ( XmlNode invoiceReferencedDocumentNodes in doc . DocumentElement . SelectNodes ( "//ram:ApplicableHeaderTradeSettlement/ram:InvoiceReferencedDocument" , nsmgr ) )
305+ foreach ( XmlNode invoiceReferencedDocumentNodes in doc . DocumentElement . SelectNodes ( "//ram:ApplicableHeaderTradeSettlement/ram:InvoiceReferencedDocument" , nsmgr ) )
308306 {
309307 retval . AddInvoiceReferencedDocument (
310308 XmlUtils . NodeAsString ( invoiceReferencedDocumentNodes , "./ram:IssuerAssignedID" , nsmgr ) ,
@@ -357,7 +355,7 @@ public override bool IsReadableByThisReaderVersion(Stream stream)
357355
358356 return _IsReadableByThisReaderVersion ( stream , validURIs ) ;
359357 } // !IsReadableByThisReaderVersion()
360-
358+
361359
362360 private static TradeLineItem _parseTradeLineItem ( XmlNode tradeLineItem , XmlNamespaceManager nsmgr = null )
363361 {
@@ -367,12 +365,12 @@ private static TradeLineItem _parseTradeLineItem(XmlNode tradeLineItem, XmlNames
367365 }
368366
369367 string _lineId = XmlUtils . NodeAsString ( tradeLineItem , ".//ram:AssociatedDocumentLineDocument/ram:LineID" , nsmgr , String . Empty ) ;
370-
368+
371369 LineStatusCodes ? _lineStatusCode = default ( LineStatusCodes ) . FromString ( XmlUtils . NodeAsString ( tradeLineItem , ".//ram:AssociatedDocumentLineDocument/ram:LineStatusCode" , nsmgr , null ) ) ;
372370 LineStatusReasonCodes ? _lineStatusReasonCode = default ( LineStatusReasonCodes ) . FromString ( XmlUtils . NodeAsString ( tradeLineItem , ".//ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode" , nsmgr , null ) ) ;
373371
374372 TradeLineItem item = new TradeLineItem ( _lineId )
375- {
373+ {
376374 GlobalID = new GlobalID ( default ( GlobalIDSchemeIdentifiers ) . FromString ( XmlUtils . NodeAsString ( tradeLineItem , ".//ram:SpecifiedTradeProduct/ram:GlobalID/@schemeID" , nsmgr ) ) ,
377375 XmlUtils . NodeAsString ( tradeLineItem , ".//ram:SpecifiedTradeProduct/ram:GlobalID" , nsmgr ) ) ,
378376 SellerAssignedID = XmlUtils . NodeAsString ( tradeLineItem , ".//ram:SpecifiedTradeProduct/ram:SellerAssignedID" , nsmgr ) ,
@@ -392,7 +390,7 @@ private static TradeLineItem _parseTradeLineItem(XmlNode tradeLineItem, XmlNames
392390 BillingPeriodEnd = XmlUtils . NodeAsDateTime ( tradeLineItem , ".//ram:BillingSpecifiedPeriod/ram:EndDateTime/udt:DateTimeString" , nsmgr ) ,
393391 } ;
394392
395- if ( _lineStatusCode . HasValue && _lineStatusReasonCode . HasValue )
393+ if ( _lineStatusCode . HasValue && _lineStatusReasonCode . HasValue )
396394 {
397395 item . SetLineStatus ( _lineStatusCode . Value , _lineStatusReasonCode . Value ) ;
398396 }
@@ -422,7 +420,7 @@ private static TradeLineItem _parseTradeLineItem(XmlNode tradeLineItem, XmlNames
422420 }
423421
424422 if ( tradeLineItem . SelectSingleNode ( ".//ram:AssociatedDocumentLineDocument" , nsmgr ) != null )
425- {
423+ {
426424 XmlNodeList noteNodes = tradeLineItem . SelectNodes ( ".//ram:AssociatedDocumentLineDocument/ram:IncludedNote" , nsmgr ) ;
427425 foreach ( XmlNode noteNode in noteNodes )
428426 {
@@ -557,7 +555,7 @@ private static AdditionalReferencedDocument _getAdditionalReferencedDocument(Xml
557555 return new AdditionalReferencedDocument
558556 {
559557 ID = XmlUtils . NodeAsString ( node , "ram:IssuerAssignedID" , nsmgr ) ,
560- TypeCode = default ( AdditionalReferencedDocumentTypeCode ) . FromString ( XmlUtils . NodeAsString ( node , "ram:TypeCode" , nsmgr ) ) ,
558+ TypeCode = default ( AdditionalReferencedDocumentTypeCode ) . FromString ( XmlUtils . NodeAsString ( node , "ram:TypeCode" , nsmgr ) ) ,
561559 Name = XmlUtils . NodeAsString ( node , "ram:Name" , nsmgr ) ,
562560 IssueDateTime = DataTypeReader . ReadFormattedIssueDateTime ( node , "ram:FormattedIssueDateTime" , nsmgr ) ,
563561 AttachmentBinaryObject = ! string . IsNullOrWhiteSpace ( strBase64BinaryData ) ? Convert . FromBase64String ( strBase64BinaryData ) : null ,
0 commit comments