storing sender/recipient in 1Lieferschein

This commit is contained in:
jstaerk
2022-05-11 20:44:31 +02:00
parent 28e27d0de3
commit 1fbb295417
2 changed files with 28 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter; import org.dom4j.io.XMLWriter;
import org.mustangproject.EStandard; import org.mustangproject.EStandard;
import org.mustangproject.FileAttachment; import org.mustangproject.FileAttachment;
import org.mustangproject.TradeParty;
import org.mustangproject.XMLTools; import org.mustangproject.XMLTools;
import java.io.IOException; import java.io.IOException;
@@ -63,11 +64,18 @@ public class UBLDAPullProvider implements IXMLProvider {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<DespatchAdvice xmlns=\"urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2\" xmlns:cac=\"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2\" xmlns:cbc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\" xmlns:cec=\"urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2\" xmlns:csc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2\">\n" + "<DespatchAdvice xmlns=\"urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2\" xmlns:cac=\"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2\" xmlns:cbc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\" xmlns:cec=\"urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2\" xmlns:csc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2\">\n" +
" <cbc:UBLVersionID>2.2</cbc:UBLVersionID>\n" +
" <cbc:CustomizationID>1Lieferschein</cbc:CustomizationID>\n" +
" <cbc:ProfileID>ubl-xml-only</cbc:ProfileID>\n" +
" <cbc:ID>" + XMLTools.encodeXML(trans.getNumber()) + "</cbc:ID>\n" + " <cbc:ID>" + XMLTools.encodeXML(trans.getNumber()) + "</cbc:ID>\n" +
" <cbc:IssueDate>"+ublDateFormat.format(trans.getIssueDate())+"</cbc:IssueDate>\n" + " <cbc:IssueDate>" + ublDateFormat.format(trans.getIssueDate()) + "</cbc:IssueDate>\n" +
" <cac:DespatchSupplierParty/>\n" + " <cbc:DespatchAdviceTypeCode>900</cbc:DespatchAdviceTypeCode>\n";
" <cac:DeliveryCustomerParty/>\n"; if (trans.getReferenceNumber() != null) {
xml += "<cac:OrderReference> <cbc:ID>" + XMLTools.encodeXML(trans.getNumber()) + "</cbc:ID></cac:OrderReference>\n";
}
xml += " <cac:DespatchSupplierParty>" + getPartyXML(trans.getSender()) + "</cac:DespatchSupplierParty>\n" +
" <cac:DeliveryCustomerParty>" + getPartyXML(trans.getRecipient()) + "</cac:DeliveryCustomerParty>\n";
int i = 1; int i = 1;
for (IZUGFeRDExportableItem item : trans.getZFItems()) { for (IZUGFeRDExportableItem item : trans.getZFItems()) {
xml += xml +=
@@ -91,6 +99,23 @@ public class UBLDAPullProvider implements IXMLProvider {
} }
} }
public String getPartyXML(IZUGFeRDExportableTradeParty tp) {
return "<cac:Party>\n" +
" <cac:PostalAddress>\n" +
" <cbc:CityName>" + XMLTools.encodeXML(tp.getLocation()) + "</cbc:CityName>\n" +
" <cac:AddressLine>\n" +
" <cbc:Line>" + XMLTools.encodeXML(tp.getName()) + "</cbc:Line>\n" +
" </cac:AddressLine>\n" +
" <cac:AddressLine>\n" +
" <cbc:Line>" + XMLTools.encodeXML(tp.getStreet()) + "</cbc:Line>\n" +
" </cac:AddressLine>\n" +
" <cac:Country>\n" +
" <cbc:IdentificationCode>" + XMLTools.encodeXML(tp.getCountry()) + "</cbc:IdentificationCode>\n" +
" </cac:Country>\n" +
" </cac:PostalAddress>\n" +
" </cac:Party>";
}
@Override @Override
public byte[] getXML() { public byte[] getXML() {

View File

@@ -72,9 +72,6 @@ public class UBLTest extends ResourceCase {
.setReferenceNumber("991-01484-64")//leitweg-id .setReferenceNumber("991-01484-64")//leitweg-id
.setNumber("123").addItem(new Item(new Product("Testprodukt", "", "C62", BigDecimal.ZERO), /*price*/ new BigDecimal("1.0"), /*qty*/ new BigDecimal("1.0")).addReferencedLineID("A12")); .setNumber("123").addItem(new Item(new Product("Testprodukt", "", "C62", BigDecimal.ZERO), /*price*/ new BigDecimal("1.0"), /*qty*/ new BigDecimal("1.0")).addReferencedLineID("A12"));
UBLDAPullProvider zf2p = new UBLDAPullProvider();
zf2p.setProfile(Profiles.getByName(EStandard.despatchadvice, "Pilot", 1));
zf2p.generateXML(i);
try { try {
oe.setTransaction(i); oe.setTransaction(i);