taocomp / php-e-invoice-it

A PHP package for managing italian e-invoice and notice XML formats. (Pacchetto PHP per gestire il formato XML di fatture e notifiche come richiesto dal SdI).
GNU General Public License v3.0
73 stars 22 forks source link

Allow to add more line of DettagliPagamento #32

Open mdeprezzo opened 11 months ago

mdeprezzo commented 11 months ago

just add these controls? Something like that:


    /**
     * Add payment detail line item
     */
    public function addPaymentDetailLineItem( int $n, int $bodyIndex = 1 )
    {
        if ($n < 1) {
            return $this;
        }

        if ($bodyIndex < 1) {
            throw new \Exception("Invalid body index '$bodyIndex'");
        }

        $body = $this->getBody($bodyIndex);
        $line = $this->getElement('DatiPagamento', $body);

        for ($i = 0; $i < $n; $i++) {
            $this->addElement($line->cloneNode(true), $body);
        }

        return $this;
    }

    /**
     * Get payment detail line item i
     */
    public function getPaymentDetailLineItem( int $i, int $bodyIndex = 1 )
    {
        $body = $this->getBody($bodyIndex);
        return $this->getElement("DatiPagamento[$i]", $body);
    }

    /**
     * Set number of payment detail line items
     */
    public function setPaymentDetailLineItemCount( int $n, int $bodyIndex = 1 )
    {
        return $this->addPaymentDetailLineItem($n - 1, $bodyIndex);
    }