Closed 3tlam closed 2 years ago
This is now possible using the following:
$download = $ninja->invoices->download(['hashed_id']);
Ensure you pass an id in a array
Heya @turbo124
Thank for the quick fix, but it does not really work for me? It just returns an array of the invoice?
And maybe update die README accordingly, as this function is not supported?
Best
@3tlam
have you run composer update to pull in the new version?
Yep, sure - otherwise I‘d have gotten an error for an unspecified method What should be happening?
not sure, i wrote tests for this and it passes as expected for me:
can you paste a snippet of your code?
Heya
well there isn't much to show, but here it is:
require 'vendor/autoload.php';
use InvoiceNinja\Sdk\InvoiceNinja;
$ninja = new InvoiceNinja("key");
$ninja->setUrl('https://ninja.site:8890');
$pdf = $ninja->invoices->download(['joQeZzvepZ']);
echo '<pre>'; print_r($pdf); echo '</pre>';;
Calling just download()
results in nothing
While you did generate a test, it only asserts to not null - seeing the return is the full array of an invoice, your test asserts correctly?
{
"data": [
{
"id": "joQeZzvepZ",
"user_id": "VolejRejNm",
"project_id": "",
"assigned_user_id": "",
"amount": 217.5,
"balance": 217.5,
"client_id": "JAPdRoReGy",
"vendor_id": "",
"status_id": "2",
"design_id": "7LDdwRb1YK",
"recurring_id": "",
"created_at": 1662470728,
"updated_at": 1662471091,
"archived_at": 0,
"is_deleted": false,
"number": "0015",
"discount": 25,
"po_number": "",
"date": "2022-09-06",
"last_sent_date": "2022-09-06",
"next_send_date": "",
"due_date": "",
"terms": "",
"public_notes": "",
"private_notes": "",
"uses_inclusive_taxes": false,
"tax_name1": "",
"tax_rate1": 0,
"tax_name2": "",
"tax_rate2": 0,
"tax_name3": "",
"tax_rate3": 0,
"total_taxes": 0,
"is_amount_discount": false,
"footer": "",
"partial": 0,
"partial_due_date": "",
"custom_value1": "stuff",
"custom_value2": "",
"custom_value3": "",
"custom_value4": "",
"has_tasks": false,
"has_expenses": false,
"custom_surcharge1": 0,
"custom_surcharge2": 0,
"custom_surcharge3": 0,
"custom_surcharge4": 0,
"exchange_rate": 1,
"custom_surcharge_tax1": false,
"custom_surcharge_tax2": false,
"custom_surcharge_tax3": false,
"custom_surcharge_tax4": false,
"line_items": [
{
"product_key": "asd",
"notes": "asd",
"custom_value1": "Laufzeit: 06.09.2022 - 06.10.2022",
"quantity": 1,
"cost": 290,
"type_id": "1",
"product_cost": 0,
"discount": 0,
"is_amount_discount": false,
"tax_name1": "",
"tax_rate1": 0,
"tax_name2": "",
"tax_rate2": 0,
"tax_name3": "",
"tax_rate3": 0,
"sort_id": "0",
"line_total": "290.00",
"gross_line_total": 290,
"date": "",
"custom_value2": "",
"custom_value3": "",
"custom_value4": ""
}
],
"entity_type": "invoice",
"reminder1_sent": "2022-09-06",
"reminder2_sent": "",
"reminder3_sent": "",
"reminder_last_sent": "2022-09-06",
"paid_to_date": 0,
"subscription_id": "",
"auto_bill_enabled": false,
"invitations": [
{
"id": "EKQe1G3bJY",
"client_contact_id": "X46dB6nd79",
"key": "CF5GYqB6TrvRbSXbeYZqeam2rtRYz936",
"link": "https://ninja.site:8890/client/invoice/CF5GYqB6TrvRbSXbeYZqeam2rtRYz936",
"sent_date": "2022-09-06 13:31:15",
"viewed_date": "",
"opened_date": "",
"updated_at": 1662471075,
"archived_at": 0,
"created_at": 1662470728,
"email_status": "",
"email_error": ""
}
],
"documents": [
]
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 20,
"current_page": 1,
"total_pages": 1,
"links": [
]
}
}
}
I think I understand the issue, there are changes in the main InvoiceNinja repo which are required for this to work.
If you update to the latest, you'll see this will work as expected
Hi, I'm running on the latest version (1.0.6) and we have the same issue as described above.
I've opened 2 Pull Requests, they both have the same result. You can choose which one is the better fit 😄
@TheJenne18 can you confirm that your Invoice Ninja installation is at 5.5.21 these additional methods - whilst valid - should not be needed if you are using the latest version of Invoice Ninja
Heya
as per the README:
This does not work for me :(
Looking into the source (
/app/Http/Controllers/InvoiceController.php
, Line 567), the action should bebulk_download
and notdownload
? Also thecount() > 1
should becount() >0
or>= 1
, as per the README I can "download" one inovice? Changing this, there is no browser "download" per se, instead an email is generated for the customer? Is this the idea?Thanks for your help!