Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined array key \"tax\" and items not shown on invoice with admin API call #1276

Open
kenjibailly opened this issue Dec 8, 2023 · 1 comment

Comments

@kenjibailly
Copy link

I'm trying to create an invoice using the admin API with nodejs.
But I'm getting a response body message: Undefined array key "tax"
I've tried a number of things, like setting the tax to a string, setting it to the ID of the tax type I have set in crater, giving it a higher number than 0, but they all result in the same error message.
However the invoice does get created in Crater, but the items aren't there. I'm guessing this might have to do because I'm getting an error message.

I have used the default body code that can be found on the API documentation. (https://api-docs.craterapp.com/#admin-invoices-POSTapi-v1-invoices)
All I have changed is the item ID to the item ID of that item which is 3. I have checked this by doing an API call and getting the items:

data: [
    {
      id: 3,
      name: 'Apple Macbook',
      description: 'Light and powerful laptop',
      price: 10000,
      unit_id: 1,
      company_id: 1,
      creator_id: 1,
      currency_id: 3,
      created_at: '2023-12-08T10:22:33.000000Z',
      updated_at: '2023-12-08T10:22:33.000000Z',
      tax_per_item: 0,
      formatted_created_at: '08 Dec 2023',
      unit: [Object],
      company: [Object],
      currency: [Object]
    }
  ],
  let body = {
    "invoice_date": "2022-02-13",
    "due_date": "2022-02-16",
    "customer_id": 1,
    "invoice_number": "INV-000001",
    "exchange_rate": 1,
    "discount_type": "fixed",
    "discount": 50,
    "discount_val": 5000,
    "sub_total": 10000,
    "total": 5000,
    "tax": 0,
    "template_name": "invoice1",
    "items": [
        {
            "name": "Apple Macbook",
            "quantity": 1,
            "price": 10000,
            "description": "Light and powerful laptop",
            "item_id": 3,
            "sub_total": 10000,
            "total": 10000,
            "unit_name": "box",
            "discount": 0,
            "discount_type": "fixed",
            "discount_val": 0,
        }
    ],
  };

I'm not sure how to fix this. What am I doing wrong? Is this a bug?

@rihards-simanovics
Copy link

rihards-simanovics commented Jan 10, 2024

quick reminder the software is abandonware and will no longer receive updates: #1265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants