All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mustangproject.ReferencedDocument Maven / Gradle / Ivy

Go to download

FOSS Java library to read, write and validate european electronic invoices and orders in the UN/CEFACT Cross Industry Invoice based formats Factur-X/ZUGFeRD, XRechnung and Order-X in your invoice PDFs.

There is a newer version: 2.15.0
Show newest version
package org.mustangproject;

import org.mustangproject.ZUGFeRD.IReferencedDocument;
import org.mustangproject.util.NodeMap;
import org.w3c.dom.Node;

public class ReferencedDocument implements IReferencedDocument {

	String issuerAssignedID;
	String typeCode;
	String referenceTypeCode;

	public ReferencedDocument(String issuerAssignedID, String typeCode, String referenceTypeCode) {
		this.issuerAssignedID = issuerAssignedID;
		this.typeCode = typeCode;
		this.referenceTypeCode = referenceTypeCode;
	}

	public ReferencedDocument(String issuerAssignedID, String referenceTypeCode) {
		this.issuerAssignedID = issuerAssignedID;
		this.typeCode = "916"; // additional invoice related document
		this.referenceTypeCode = referenceTypeCode;
	}

	/***
	 * sets an ID assigned by the sender
	 * @param issuerAssignedID the ID as a string :-)
	 */
	public void setIssuerAssignedID(String issuerAssignedID) {
		this.issuerAssignedID = issuerAssignedID;
	}

	/**
	 * which type is the document? e.g. "916" for additional invoice related
	 * @param typeCode as String, e.g. 916
	 */
	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}

	/**
	 * type of the reference of this line, a UNTDID 1153 code
	 * @param referenceTypeCode three uppercase character reference type code as string
	 */
	public void setReferenceTypeCode(String referenceTypeCode) {
		this.referenceTypeCode = referenceTypeCode;
	}

	@Override
	public String getIssuerAssignedID() {
		return issuerAssignedID;
	}

	@Override
	public String getTypeCode() {
		return typeCode;
	}

	@Override
	public String getReferenceTypeCode() {
		return referenceTypeCode;
	}

	public static ReferencedDocument fromNode(Node node) {
		if (!node.hasChildNodes()) {
			return null;
		}
		NodeMap nodes = new NodeMap(node);
		return new ReferencedDocument(nodes.getAsStringOrNull("IssuerAssignedID"),
			nodes.getAsStringOrNull("TypeCode"),
			nodes.getAsStringOrNull("ReferenceTypeCode"));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy