diff --git a/src/dataproviders/PaymentInvoiceProviderInterface.php b/src/dataproviders/PaymentInvoiceProviderInterface.php index 18b0865..a84980c 100644 --- a/src/dataproviders/PaymentInvoiceProviderInterface.php +++ b/src/dataproviders/PaymentInvoiceProviderInterface.php @@ -6,5 +6,10 @@ interface PaymentInvoiceProviderInterface { + /** + * @param ActiveRow $payment + * @throws \Crm\InvoicesModule\InvoiceGenerationException + * @throws \Crm\InvoicesModule\PaymentNotInvoiceableException If payment is not invoiceable from valid reasons (eg. outside of invoiceable period). + */ public function provide(ActiveRow $payment); } diff --git a/src/dataproviders/PaymentInvoiceProviderManager.php b/src/dataproviders/PaymentInvoiceProviderManager.php index 51a883b..b11fd48 100644 --- a/src/dataproviders/PaymentInvoiceProviderManager.php +++ b/src/dataproviders/PaymentInvoiceProviderManager.php @@ -2,6 +2,7 @@ namespace Crm\PaymentsModule\DataProvider; +use Crm\InvoicesModule\PaymentNotInvoiceableException; use Nette\Database\Table\ActiveRow; use Tracy\Debugger; @@ -38,6 +39,9 @@ public function getAttachments(ActiveRow $payment): array foreach ($this->getProviders() as $provider) { try { $attachment = $provider->provide($payment); + } catch (PaymentNotInvoiceableException $e) { + // do nothing, no invoice attachment; exception may be raised for valid payments that are not invoiceable + continue; } catch (\Exception $e) { Debugger::log($e, Debugger::ERROR); continue;