Skip to content

product_code not taken up by API when creating invoice #666

Open
@jeromecc

Description

Hi!

I'm using the latest pip version within a Django 2.2 project (Python 3.6.9).

I could succesfully create customers, providers, product-codes through the API.

I'm trying to create invoices through the API directly (without using plans, because my current use case is a one time invoice for a one time payment for a one time service, even though i plan to use all the features offered by Silver in the future).

The dict in my Python code looks like this.

invoice_dct = {
        "due_date": due_date,
        "issue_date": due_date,
        "customer": customer_url,
        "provider": provider_url,
        "invoice_entries": [
            {
                "description": product_instance.description,
                "unit": product_instance.unit,
                "quantity": quantity,
                "unit_price": product_instance.unit_price,
                "product_code": {
                    "url": get_product_code_copper_url(product_instance.product_code),
                    "value": product_instance.product_code
                },
                "start_date": due_date,
                "end_date": due_date,
                "prorated": False
            },
        ],
        "sales_tax_percent": product_instance.sales_tax_percent,
        "sales_tax_name": product_instance.sales_tax_name,
        "currency": product_instance.currency,
        "state": "draft"
    }

Everything works fine (all fields are fed correctly, invoice is created)... except product_code which is null.
I created a product_code entry with a value (let's say value = "test-product" and it's the 1st product-code with a url like ".../product-codes/1/")

I tried feeding an url to the api:
"product-code": "http://example.com/product-codes/1/"

I tried feeding it url + value
product-code: {"url": "http://example.com/product-codes/1/", "value": "test-product"}

I also tried the value alone:
"product-code": "test-product"

and I even tried the key alone:
"product-code": 1 (or "1")

but nothing works for me, I end up with "product-code": null and I have to add the right product-code FK manually in the admin to have a complete invoice.

Is there a way to inject this data through the API?

Thank you for your outstanding work and for sharing it as free and open source software! :-)
jérôme

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions