picqer / moneybird-php-client

PHP Client for Moneybird V2
MIT License
82 stars 77 forks source link

Unable to set details on recurringInvoice #43

Closed TomOffringa closed 8 years ago

TomOffringa commented 8 years ago

Hi @stephangroen,

I'm trying to add details to a recurringInvoice. This is what I've tried so far. It says:

Call to undefined method Picqer\Financials\Moneybird\Moneybird::recurringSalesInvoiceDetail().

The solution / PR that #14 suggested doesn't seem to work anymore. Am I overseeing something?

Thanks.

    $invoiceDetail = $moneybird->recurringSalesInvoiceDetail();
    $invoiceDetail->tax_rate_id = $taxrate;
    $invoiceDetail->price = '5.00';
    $invoiceDetail->description = 'Foo';

    $invoice = $moneybird->recurringSalesInvoice();

    $invoice->contact_id = $contact_id;
    $invoice->prices_are_incl_tax = true;
    $invoice->reference = 'Bar';
    $invoice->frequency_type = 'year';
    $invoice->frequency = 1;
    $invoice->details = [$invoiceDetail];

I added the recurringSalesInvoiceDetail method but it doesn't seem to add anything. Adding the invoice works fine without the $invoice->details part.

stephangroen commented 8 years ago

Hi @TomOffringa,

The code to factory a RecurringSalesInvoiceDetail was missing. Your code should work now (v0.5.1). Keep in mind that you need to also at least set the ledger_account_id on the detail and an invoice_date on the invoice.

TomOffringa commented 8 years ago

Hi,

I added the factory myself but it still wasn't working. It seemed I missed the ledger_account_id, which in the API v2 documentation isn't marked as required. Stupid mistake on my side. Thanks for clearing it up though! Your fix indeed fixes the missing method part so this issue is therefor closed! Thanks!