src/Shop/InvoiceManager.php
protected function doSend(array $invoice, Source $invoiceSource, Result $result)
    {
        /** @var \Siel\Acumulus\Invoice\Result $result */
        $result = $this->getService()->invoiceAdd($invoice, $result);// Store the reference between the source of the webshop invoice and the

        // Save Acumulus entry:
        // - If we were sending in test mode or there were errors, no invoice
        //   will have been created in Acumulus: nothing to store.
        // - If the invoice was sent as a concept, the entry id and token will
        //   be empty: store nulls.
        if (!$this->isTestMode() && !$result->hasError()) {
            // If we are going to overwrite an existing entry, we want to delete
            // that from Acumulus.
            $acumulusEntryManager = $this->getAcumulusEntryManager();
            $oldEntry = $acumulusEntryManager->getByInvoiceSource($invoiceSource, true);
            $response = $result->getResponse();
            $saved = (bool) $acumulusEntryManager->save($invoiceSource,
                empty($response['entryid']) ? null : $response['entryid'],
                empty($response['token']) ? null : $response['token']
            );

            // Delete if there is an old entry and we successfully saved the new
            // entry.
            if ($saved && isset($oldEntry) && $oldEntry->getEntryId()) {
                // But only if the old entry does not refer to a concept as
                // concepts do not have an entry id and thus cannot be deleted.
                $entryId = $oldEntry->getEntryId();
                $deleteResult = $this->getService()->setDeleteStatus($entryId, API::Entry_Delete);
                if ($deleteResult->hasMessages()) {
                    // Add messages to result but not if the entry has already
                    // the delete status or does not exist at all (anymore).
                    if ($deleteResult->hasCodeTag('P2XFELO12')) {
                        // Successfully deleted the old entry: add a warning so
                        // this info will be  mailed to the user.
                        $result->addWarning(902, '',
                            sprintf($this->t('message_warning_old_entry_not_deleted'), $this->t($invoiceSource->getType()), $entryId));
                    } else {
                        $result->mergeMessages($deleteResult, true);
                    }
                } else {
                    // Successfully deleted the old entry: add a notice so this
                    // info will be mailed to the user.
                    $result->addNotice(901, '',
                        sprintf($this->t('message_warning_old_entry_deleted'), $this->t($invoiceSource->getType()), $entryId));
                }
            }
        }

        return $result;
    }
protected function doSend(array $invoice, Source $invoiceSource, Result $result)
    {
        /** @var \Siel\Acumulus\Invoice\Result $result */
        $result = $this->getService()->invoiceAdd($invoice, $result);// Store the reference between the source of the webshop invoice and the

        // Save Acumulus entry:
        // - If we were sending in test mode or there were errors, no invoice
        //   will have been created in Acumulus: nothing to store.
        // - If the invoice was sent as a concept, the entry id and token will
        //   be empty: store nulls.
        if (!$this->isTestMode() && !$result->hasError()) {
            // If we are going to overwrite an existing entry, we want to delete
            // that from Acumulus.
            $acumulusEntryManager = $this->getAcumulusEntryManager();
            $oldEntry = $acumulusEntryManager->getByInvoiceSource($invoiceSource, true);
            $response = $result->getResponse();
            $saved = (bool) $acumulusEntryManager->save($invoiceSource,
                empty($response['entryid']) ? null : $response['entryid'],
                empty($response['token']) ? null : $response['token']
            );

            // Delete if there is an old entry and we successfully saved the new
            // entry.
            if ($saved && isset($oldEntry) && $oldEntry->getEntryId()) {
                // But only if the old entry does not refer to a concept as
                // concepts do not have an entry id and thus cannot be deleted.
                $entryId = $oldEntry->getEntryId();
                $deleteResult = $this->getService()->setDeleteStatus($entryId, API::Entry_Delete);
                if ($deleteResult->hasMessages()) {
                    // Add messages to result but not if the entry has already
                    // the delete status or does not exist at all (anymore).
                    if ($deleteResult->hasCodeTag('P2XFELO12')) {
                        // Successfully deleted the old entry: add a warning so
                        // this info will be  mailed to the user.
                        $result->addWarning(902, '',
                            sprintf($this->t('message_warning_old_entry_not_deleted'), $this->t($invoiceSource->getType()), $entryId));
                    } else {
                        $result->mergeMessages($deleteResult, true);
                    }
                } else {
                    // Successfully deleted the old entry: add a notice so this
                    // info will be mailed to the user.
                    $result->addNotice(901, '',
                        sprintf($this->t('message_warning_old_entry_deleted'), $this->t($invoiceSource->getType()), $entryId));
                }
            }
        }

        return $result;
    }
protected function doSend ( array $ invoice , Source $ invoiceSource , Result $ result ) { /** @var \Siel\Acumulus\Invoice\Result $result */ $ result = $ this -> getService ( ) -> invoiceAdd ( $ invoice , $ result ) ; // Store the reference between the source of the webshop invoice and the // Save Acumulus entry: // - If we were sending in test mode or there were errors, no invoice //   will have been created in Acumulus: nothing to store. // - If the invoice was sent as a concept, the entry id and token will //   be empty: store nulls. if ( ! $ this -> isTestMode ( ) && ! $ result -> hasError ( ) ) { // If we are going to overwrite an existing entry, we want to delete // that from Acumulus. $ acumulusEntryManager = $ this -> getAcumulusEntryManager ( ) ; $ oldEntry = $ acumulusEntryManager -> getByInvoiceSource ( $ invoiceSource , true ) ; $ response = $ result -> getResponse ( ) ; $ saved = ( bool ) $ acumulusEntryManager -> save ( $ invoiceSource , empty ( $ response [ 'entryid' ] ) ? null : $ response [ 'entryid' ] , empty ( $ response [ 'token' ] ) ? null : $ response [ 'token' ] ) ; // Delete if there is an old entry and we successfully saved the new // entry. if ( $ saved && isset ( $ oldEntry ) && $ oldEntry -> getEntryId ( ) ) { // But only if the old entry does not refer to a concept as // concepts do not have an entry id and thus cannot be deleted. $ entryId = $ oldEntry -> getEntryId ( ) ; $ deleteResult = $ this -> getService ( ) -> setDeleteStatus ( $ entryId , API :: Entry_Delete ) ; if ( $ deleteResult -> hasMessages ( ) ) { // Add messages to result but not if the entry has already // the delete status or does not exist at all (anymore). if ( $ deleteResult -> hasCodeTag ( 'P2XFELO12' ) ) { // Successfully deleted the old entry: add a warning so // this info will be  mailed to the user. $ result -> addWarning ( 902 , '' , sprintf ( $ this -> t ( 'message_warning_old_entry_not_deleted' ) , $ this -> t ( $ invoiceSource -> getType ( ) ) , $ entryId ) ) ; } else { $ result -> mergeMessages ( $ deleteResult , true ) ; } } else { // Successfully deleted the old entry: add a notice so this // info will be mailed to the user. $ result -> addNotice ( 901 , '' , sprintf ( $ this -> t ( 'message_warning_old_entry_deleted' ) , $ this -> t ( $ invoiceSource -> getType ( ) ) , $ entryId ) ) ; } } } return $ result ; }
Unconditionally sends the invoice and update the Acumulus entries table.

After sending the invoice:
- A successful result gets saved to the acumulus entries table.
- If an older submission exists, it will be deleted from Acumulus.

@param \Siel\Acumulus\Invoice\Source $invoiceSource
@param array $invoice
@param \Siel\Acumulus\Invoice\Result $result

@return \Siel\Acumulus\Invoice\Result
The result structure of the invoice add API call merged with any local
messages.
Unconditionally sends the invoice and update the Acumulus entries table .