-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to configure how long after purchase (or end of the month)
should be generation of payment's invoice allowed remp/crm#2799 - **BREAKING**: Changed `InvoicesRepository::paymentInInvoiceablePeriod` from static to instance method - Until now invoice could be generated 15 days after purchase date. This behavior is kept (no breaking change) by presetting this config to "15 days after purchase date" - **IMPORTANT**: This config is restricted: If number of days is bigger than 15, system requires you to enable config "Generate an invoice number for every paid payment" - Added support for select boxes to application config forms. remp/crm#2799
- Loading branch information
Showing
10 changed files
with
211 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Crm\InvoicesModule\DataProvider; | ||
|
||
use Contributte\Translation\Translator; | ||
use Crm\AdminModule\DataProvider\ConfigFormDataProviderInterface; | ||
use Crm\ApplicationModule\DataProvider\DataProviderException; | ||
use Crm\InvoicesModule\Repository\InvoicesRepository; | ||
use Nette\Application\UI\Form; | ||
|
||
class ConfigFormDataProvider implements ConfigFormDataProviderInterface | ||
{ | ||
public const GENERATE_INVOICE_NUMBER_LIMIT = 15; | ||
|
||
public function __construct(private Translator $translator) | ||
{ | ||
} | ||
|
||
public function provide(array $params): Form | ||
{ | ||
if (!isset($params['form'])) { | ||
throw new DataProviderException('missing [form] within data provider params'); | ||
} | ||
|
||
/** @var Form $form */ | ||
$form = $params['form']; | ||
if ($form->getComponent('generate_invoice_number_for_paid_payment', false)) { | ||
$generateInvoiceLimitFromDays = $form->getComponent(InvoicesRepository::GENERATE_INVOICE_LIMIT_FROM_DAYS); | ||
|
||
$form->getComponent('generate_invoice_number_for_paid_payment') | ||
->addConditionOn($generateInvoiceLimitFromDays, Form::Min, self::GENERATE_INVOICE_NUMBER_LIMIT + 1) | ||
->setRequired($this->translator->translate( | ||
'invoices.config.generate_invoice_number_for_paid_payment.required_because_of_invoice_limit_from_days', | ||
[ | ||
'days' => self::GENERATE_INVOICE_NUMBER_LIMIT | ||
] | ||
)); | ||
} | ||
return $form; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters