Skip to content

Commit

Permalink
PROD-204: Use default account receivable as payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Shahrukh committed May 27, 2024
1 parent b5c4b22 commit 79c6e72
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Civi/Financeextras/Setup/Configure/SetDefaultCompany.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Civi\Financeextras\Setup\Configure;

use Civi\Financeextras\Setup\Manage\AccountsReceivablePaymentMethod;

/**
* For this extension to work properly we need
* at least one company. This adds a company
Expand All @@ -26,6 +28,7 @@ public function apply() {
->addValue('creditnote_template_id:name', 'Credit Note Invoice')
->addValue('next_creditnote_number', $this->getDefaultNextCreditNoteNumber())
->addValue('creditnote_prefix', $this->getDefaultCreditNotePrefix())
->addValue('receivable_payment_method', $this->getDefaultAccountReceivablePaymentMethod())
->execute();
}
catch (\Exception $exception) {
Expand Down Expand Up @@ -113,4 +116,15 @@ private function getDefaultNextCreditNoteNumber() {
return $creditNoteNum ?? '1';
}

private function getDefaultAccountReceivablePaymentMethod() {
$paymentMethod = civicrm_api3('OptionValue', 'get', [
'sequential' => 1,
'return' => ['value'],
'option_group_id' => 'payment_instrument',
'name' => AccountsReceivablePaymentMethod::NAME,
]);

return $paymentMethod['values'][0]['value'] ?? NULL;
}

}

0 comments on commit 79c6e72

Please sign in to comment.