horstoeko / zugferd

ZUGFeRD/XRechnung/Factur-X Library
MIT License
141 stars 25 forks source link

[FEATURE] #143

Open turbo124 opened 2 days ago

turbo124 commented 2 days ago

Describe the feature Currently it is only possible to read content from a xml.

We'd like to store parts of a CII in object form and hydrate this into a ZugferDocument.

For example, instead of building and storing an entire CII to store a users Payment Means, we can serialize just the SpecifiedTradeSettlementPaymentMeans and then inject this when building the document.

Suggested code

We would like to suggest adding a setter here:

https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocument.php#L90

public function setInvoiceObject(\horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwl\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice $invoiceObject): self
{

    $this->invoiceObject = $invoiceObject;

    return $this;
}

There did not appear to be any other lower level way of introducing direct "Types" into the documents

If this looks suitable, happy to send this through as a PR.

Thanks!

horstoeko commented 1 day ago

Hi @turbo124 ,

nice to hear from you

For example, instead of building and storing an entire CII to store a users Payment Means, we can serialize just the SpecifiedTradeSettlementPaymentMeans and then inject this when building the document.

Where do you get it from?

We would like to suggest adding a setter here:

No, this is not possible, as there are a number of other constraints involved, such as correctly determining the internal profile ID. Other processes (validation, etc.) are dependent on this. And you simply cannot guarantee this with your solution.

My library is designed to help people generate a complete XML and not to assemble it from puzzle pieces.

I don't want to implement that.

Kind regards