Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #724 - add source to create mandate actions #725

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Civi/Sepa/ActionProvider/Action/CreateOneOffMandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function getParameterSpecification() {
new Specification('receive_date', 'Date', E::ts('Collection Date'), false, date('Y-m-d H:i:s')),
new Specification('date', 'Date', E::ts('Signature Date'), false, date('Y-m-d H:i:s')),
new Specification('validation_date', 'Date', E::ts('Validation Date'), false, date('Y-m-d H:i:s')),
new Specification('creation_date', 'Date', E::ts('Creation Date'), false, date('Y-m-d H:i:s')),
new Specification('source', 'String', E::ts('Source'), false),
]);
}

Expand Down Expand Up @@ -94,7 +96,7 @@ public function getOutputSpecification() {
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$mandate_data = ['type' => 'OOFF'];
// add basic fields
foreach (['contact_id', 'account_holder', 'iban', 'bic', 'reference', 'amount', 'receive_date', 'date', 'validation_date'] as $parameter_name) {
foreach (['contact_id', 'account_holder', 'iban', 'bic', 'reference', 'amount', 'receive_date', 'date', 'validation_date', 'source', 'creation_date'] as $parameter_name) {
$value = $parameters->getParameter($parameter_name);
if (!empty($value)) {
$mandate_data[$parameter_name] = $value;
Expand All @@ -115,6 +117,11 @@ protected function doAction(ParameterBagInterface $parameters, ParameterBagInter
if (!empty($creditor['uses_bic']) && empty($mandate_data['bic'])) {
throw new ExecutionException('BIC is required');
}
// use default creation date
if (!$mandate_data['creation_date']) {
$creationDate = new \DateTime();
$mandate_data['creation_date'] = $creationDate->format('Y-m-d H:i:s');
}

// create mandate
try {
Expand Down
9 changes: 8 additions & 1 deletion Civi/Sepa/ActionProvider/Action/CreateRecurringMandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function getParameterSpecification() {
new Specification('iban', 'String', E::ts('IBAN'), true),
new Specification('bic', 'String', E::ts('BIC'), false),
new Specification('reference', 'String', E::ts('Mandate Reference'), false),
new Specification('source', 'String', E::ts('Source'), false),
new Specification('amount', 'Money', E::ts('Amount'), false),

// recurring information
Expand All @@ -69,6 +70,7 @@ public function getParameterSpecification() {
new Specification('start_date', 'Date', E::ts('Start Date'), false, date('Y-m-d H:i:s')),
new Specification('date', 'Date', E::ts('Signature Date'), false, date('Y-m-d H:i:s')),
new Specification('validation_date', 'Date', E::ts('Validation Date'), false, date('Y-m-d H:i:s')),
new Specification('creation_date', 'Date', E::ts('Creation Date'), false, date('Y-m-d H:i:s')),
]);
}

Expand Down Expand Up @@ -100,7 +102,7 @@ public function getOutputSpecification() {
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$mandate_data = ['type' => 'RCUR'];
// add basic fields
foreach (['contact_id', 'account_holder', 'iban', 'bic', 'reference', 'amount', 'start_date', 'date', 'validation_date'] as $parameter_name) {
foreach (['contact_id', 'account_holder', 'iban', 'bic', 'reference', 'amount', 'start_date', 'date', 'validation_date', 'source', 'creation_date'] as $parameter_name) {
$value = $parameters->getParameter($parameter_name);
if (!empty($value)) {
$mandate_data[$parameter_name] = $value;
Expand Down Expand Up @@ -139,6 +141,11 @@ protected function doAction(ParameterBagInterface $parameters, ParameterBagInter
if (empty($mandate_data['cycle_day'])) {
$mandate_data['cycle_day'] = $this->calculateSoonestCycleDay($mandate_data);
}
// use default creation date
if (!$mandate_data['creation_date']) {
$creationDate = new \DateTime();
$mandate_data['creation_date'] = $creationDate->format('Y-m-d H:i:s');
}

// create mandate
try {
Expand Down