Topic: Cannot Delete / Cancel invoice from api

Hi .

I was trying to delete or cancel the invoice from api.

But i found out that the sample code has disabled the function for demonstrating how to delete with a message that it isn't implemented or tested fully.


        /* Delete is currently untested, and not implemented with standard FA
        // Delete
        $response = $client->delete('/modules/api/sales/' . $id, array(
            'headers' => TestEnvironment::headers()
        ));
        $this->assertEquals('200', $response->getStatusCode());
        $result = $response->getBody();
        $result = json_decode($result);

        // List again
        $response = $client->get('/modules/api/sales/', array(
            'headers' => TestEnvironment::headers()
        ));

        $this->assertEquals('200', $response->getStatusCode());
        $result = $response->getBody();
        $result = json_decode($result);

        $count2 = count($result);
        $this->assertEquals($count0, $count2);
        */

I did further study. i tried to enable the code , It gave me error for loading the class AutoFacturaCore.php.inc .. Which isn't there int he project.

I need to know if there is any update on this

Re: Cannot Delete / Cancel invoice from api

The Api is not officially taken to be a module. It was made with before. 2.4 and after that , there  is no maintenance from the original developer. May be If you find him from github, knock him to get its updated version.

Or hopefully any other developer used it before. They will help you here.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Cannot Delete / Cancel invoice from api

Hi,

@DrCard

To "delete" an invoice you need to void the invoice.  In src/Journal.php you'll see the implementation of delete which voids a transaction.  This is on the endpoint '/modules/api/journal/'.

The tests are in tests/Journal_Tets.php which demonstrates a full Create Read Update Delete test cycle.

You'll need to do a little research on the $type parameter.  I think "10" is for invoice from memory - not sure.

BTW, I was a contributor to the api back in 2018.

Cambell https://github.com/cambell-prince