Skip to content

Feat/add endpoint update invoice pdf link

CHANGELOG:

### Added
- [#1156](https://git.coopdevs.org/coopdevs/som-connexio/odoo-somconnexio/-/merge_requests/1156) Introduce `api/invoice/update-pdf-link` endpoint for updating invoice PDF links.

Related card: https://trello.com/c/IM8cFj4p/1810-projecte-facturaci%C3%B3-endpoint-per-actualitzar-info-de-factura-amb-lenlla%C3%A7-a-la-factura


Merge Request Description: Update PDF Link Endpoint

This merge request introduces a critical enhancement to the billing process. We have implemented a new endpoint, api/invoice/update-pdf-link, which plays a pivotal role in updating the URL for downloading the generated invoice PDF in Odoo.

Changes in this MR:

  1. New Endpoint:

    • Added a new endpoint, api/invoice/update-pdf-link, to facilitate the update of the invoice PDF link.
  2. Endpoint Specifications:

    • Expects a JSON body with the following parameters:
      • invoice_number: The unique identifier of the invoice.
      • pdf_link: The updated URL for downloading the invoice PDF.

Purpose:

The primary purpose of this enhancement is to allow the Data Warehouse (DWH), after generating the PDF of the invoice, to seamlessly notify Odoo about the updated PDF link. This link is crucial as it will be utilized in the billing email to provide users with a convenient way to download their invoices.

How it Works:

  1. The DWH generates the PDF of the invoice.
  2. It calls the api/invoice/update-pdf-link endpoint in Odoo with the invoice number and the new PDF link.
  3. Odoo locates the invoice using the provided number and updates the PDF link accordingly.
  4. In the previous step of the billing process (from the previous MR), Odoo notifies the Data Warehouse about the invoice number.

Example Usage:

  curl -X POST \
    -H  "accept: application/json" \
    -H  "Content-Type: application/json" \
    -H  "api-key: $APIKEY" \
    -d '{
          "invoice_number": "CON/2023/123456",
          "pdf_link": "https://example.com/invoices/123456.pdf"
    }' \
    "$URL/api/invoice/update-pdf-link"

Diagram

sequenceDiagram
    participant DWH
    participant Odoo

    Odoo ->> DWH: Notify Invoice Number (in MR !1154)

    Note over DWH: Generate Invoice PDF
    DWH ->> Odoo: POST /api/invoice/update-pdf-link {"invoice_number": "123456", "pdf_link": "https://example.com/invoices/123456.pdf"}
Edited by Gerard Funosas

Merge request reports