Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charges on item level #568

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

InnuceEAN
Copy link
Contributor

Adds support for allowances and charges on item level

Fixes #561

Previously charges/allowances on item level where handled same as header level

Adds support for allowances and charges on item level

Fixes ZUGFeRD#561

Previously charges/allowances on item level where handled same as header
level
// now handling base64 encoded attachments AttachmentBinaryObject=CII, EmbeddedDocumentBinaryObject=UBL
xpr = xpath.compile("//*[local-name()=\"AttachmentBinaryObject\"]|//*[local-name()=\"EmbeddedDocumentBinaryObject\"]");
NodeList attachmentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
for (int i = 0; i < attachmentNodes.getLength(); i++) {
Copy link
Contributor Author

@InnuceEAN InnuceEAN Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically moved everything below to new method parseCharge() without much changes. Ignoring whitespaces should make this diff easier to parse (?w=1)

// be read,
// so the invoice remains arithmetically correct
// -> parse document level charges+allowances
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]//*[local-name()=\"SpecifiedTradeAllowanceCharge\"]");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ApplicableHeaderTradeSettlement because we only want to have header level charges here

reason = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
} else if (chargeChildName.equals("ReasonCode")) {
reasonCode = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
} else if (isHeader && chargeChildName.equals("CategoryTradeTax")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added condition isHeader


if (zpp.getZFItems() != null && zpp.getZFItems().length > 0) {
Copy link
Contributor Author

@InnuceEAN InnuceEAN Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously only done for if (nodes.getLength() != 0)
zfItems.length > 0 should basically check the same

@InnuceEAN
Copy link
Contributor Author

@jstaerk Do you mind sharing why you have rejected this PR until now? What can I do to improve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tax calculation on allowance position
1 participant