financieel type donatie en contributie
This commit is contained in:
parent
bf37091748
commit
e083872465
|
@ -18,7 +18,8 @@ class CRM_Bij1migratie_Bij1MigratieService {
|
|||
protected $_manGeslacht = NULL;
|
||||
protected $_onbekendGeslacht = NULL;
|
||||
protected $_vrouwGeslacht = NULL;
|
||||
protected $_financialTypeId = NULL;
|
||||
protected $_contributieFinancialTypeId = NULL;
|
||||
protected $_donatieFinancialTypeId = NULL;
|
||||
protected $_completedContributionStatusId = NULL;
|
||||
protected $_pendingContributionStatusId = NULL;
|
||||
protected $_migratieGroupId = NULL;
|
||||
|
@ -129,15 +130,29 @@ class CRM_Bij1migratie_Bij1MigratieService {
|
|||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setFinancialTypeId(int $id) {
|
||||
$this->_financialTypeId = $id;
|
||||
public function setContributieFinancialTypeId(int $id) {
|
||||
$this->_contributieFinancialTypeId = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getFinancialTypeId() {
|
||||
return $this->_financialTypeId;
|
||||
public function getContributieFinancialTypeId() {
|
||||
return $this->_contributieFinancialTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setDonatieFinancialTypeId(int $id) {
|
||||
$this->_donatieFinancialTypeId = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getDonatieFinancialTypeId() {
|
||||
return $this->_donatieFinancialTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -357,4 +372,22 @@ class CRM_Bij1migratie_Bij1MigratieService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method om financieel type vast te stellen
|
||||
*
|
||||
* @param array $rij
|
||||
* @return null
|
||||
*/
|
||||
public function haalFinancieelType(array $rij) {
|
||||
if (isset($rij['omschrijving']) && !empty($rij['omschrijving'])) {
|
||||
if (strpos($rij['omschrijving'], "donatie") !== FALSE) {
|
||||
return $this->_donatieFinancialTypeId;
|
||||
}
|
||||
if (strpos($rij['omschrijving'], "donation") !== FALSE) {
|
||||
return $this->_donatieFinancialTypeId;
|
||||
}
|
||||
}
|
||||
return $this->_contributieFinancialTypeId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,11 +67,12 @@ class CRM_Bij1migratie_Migratie {
|
|||
} else {
|
||||
$rij['status'] = Civi::service('bij1Migratie')->getPendingContributionStatusId();
|
||||
}
|
||||
$rij['financial_type_id'] = Civi::service('bij1Migratie')->haalFinancieelType($rij);
|
||||
if (!self::bestaatBetaling($contactId, $rij)) {
|
||||
try {
|
||||
$bijdrage = \Civi\Api4\Contribution::create()
|
||||
->addValue('contact_id', $contactId)
|
||||
->addValue('financial_type_id', Civi::service('bij1Migratie')->getFinancialTypeId())
|
||||
->addValue('financial_type_id', $rij['financial_type_id'])
|
||||
->addValue('payment_instrument_id', $rij['betalingsinstrument'])
|
||||
->addValue('receive_date', $rij['aanmaakdatum'])
|
||||
->addValue('total_amount', $rij['bedrag'])
|
||||
|
|
|
@ -21,7 +21,7 @@ class Bij1MigratieContainer implements CompilerPassInterface {
|
|||
$definition->setFactory(['CRM_Bij1migratie_Bij1MigratieService', 'getInstance']);
|
||||
$this->setAanhef($definition);
|
||||
$this->setGeslacht($definition);
|
||||
$this->setFinancieelType($definition);
|
||||
$this->setFinancieelTypes($definition);
|
||||
$this->setContributionStatus($definition);
|
||||
$definition->setPublic(TRUE);
|
||||
$container->setDefinition('bij1Migratie', $definition);
|
||||
|
@ -58,11 +58,21 @@ class Bij1MigratieContainer implements CompilerPassInterface {
|
|||
*
|
||||
* @param $definition
|
||||
*/
|
||||
private function setFinancieelType(&$definition) {
|
||||
$query = "SELECT id FROM civicrm_financial_type WHERE name = %1;";
|
||||
$id = \CRM_Core_DAO::singleValueQuery($query, [1 => ["Contributie", "String"]]);
|
||||
if ($id) {
|
||||
$definition->addMethodCall('setFinancialTypeId', [(int) $id]);
|
||||
private function setFinancieelTypes(&$definition) {
|
||||
$query = "SELECT id, name FROM civicrm_financial_type WHERE name IN(%1, %2)";
|
||||
$dao = \CRM_Core_DAO::executeQuery($query, [
|
||||
1 => ["Contributie", "String"],
|
||||
2 => ["Donatie", "String"],
|
||||
]);
|
||||
while ($dao->fetch()) {
|
||||
switch ($dao->name) {
|
||||
case "Contributie":
|
||||
$definition->addMethodCall('setContributieFinancialTypeId', [(int) $dao->id]);
|
||||
break;
|
||||
case "Donatie":
|
||||
$definition->addMethodCall('setDonatieFinancialTypeId', [(int) $dao->id]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue