picqer / moneybird-php-client

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

Estimate Details and sending the Estimate #74

Closed hiranthi closed 7 years ago

hiranthi commented 7 years ago

I'm trying to add estimates and send them automatically after filling in a form. Adding the Estimate to Moneybird works, just not how it should. Details aren't added and besides that I am unable to send the estimate, only to save it as a draft.

In another issue I saw code that used $moneybird->salesInvoiceDetail(), just as you would with adding an invoice. I tried using that, but the Details in the actual Estimate in Moneybird are not there. Using EstimateDetail() or estimateDetail() results in an error stating that those methods don't exist.

Using $moneybird->sendEstimate() and $moneybird->send() for trying to send the Estimate result in the same 'method does not exist' error.

I noticed that in SalesInvoice.php the SalesInvoiceDetail and sendInvoice() mentioned specifically. Those for Estimates in Estimate.php are missing (or at least not there). Is that the reason why adding details to my Estimate (and trying to send it) are failing?

hiranthi commented 7 years ago

I'm guessing the same applies to notes and custom fields for Estimates

Spreeuw commented 7 years ago

@onexa I could help if you post a more complete bit of code here! The Estimate does not have a definition for the details yet, it should be included in the multipleNestedEntities property (as in the invoice). there are indeed no sendEstimate or send methods in the main class. Rather, this is a function inside the SalesInvoice entity. Such a method is not yet implemented for estimates yet in this client. You can probably implement this relatively easily by copying the method from the SalesInvoice to the Estimate class. (MB documentation here).

Short answer: what you need is not implemented in this client yet but shouldn't be super difficult to add.

hiranthi commented 7 years ago

That immediately explains why I didn't provide any code. I figured it had to do with missing code for Estimates. Adding the code for programmatically making (partial) estimates wouldn't add anything or change anything to what I was experiencing. Adding code to my question wouldn't have made a difference, wouldn't have changed the fact that they indeed aren't implemented for estimates yet (although an earlier issue about estimates does point in a different direction, hence my initial confusion).

It's good to know that even though I'm not that familiar with API's as this (I've been out of these kinds of things for a few years), I did notice the differences (and thus the possibilities) between estimates and invoices correctly. Thanks :)