<commit_before><?php
/*-------------------------------------------------------------+
| SYSTOPIA Contract Extension                                  |
| Copyright (C) 2019 SYSTOPIA                                  |
| Author: <NAME> (endres -at- systopia.de)                  |
| http://www.systopia.de/                                      |
+--------------------------------------------------------------*/

use CRM_Contract_ExtensionUtil as E;

/**
 * "New Membership Signed" record
 */
class CRM_Contract_Change_Sign extends CRM_Contract_Change {

  /**
   * Get a list of required fields for this type
   *
   * @return array list of required fields
   */
  public function getRequiredFields() {
    return []; // none required because change is documentary
  }

  /**
   * Apply the given change to the contract
   *
   * @throws Exception should anything go wrong in the execution
   */
  public function execute() {
    throw new Exception("New membership sign-ups are documentary, they cannot be scheduled into the future, and therefore not executed.");
  }

  /**
   * Derive/populate additional data
   */
  public function populateData() {
    parent::populateData();
    $contract = $this->getContract(TRUE);
    $this->data['contract_updates.ch_annual_diff'] = CRM_Utils_Array::value('membership_payment.membership_annual', $contract, '');
  }


  /**
   * Check whether this change activity should actually be created
   *
   * CANCEL activities should not be created, if there is another one already there
   *
   * @throws Exception if the creation should be disallowed
   */<commit_msg>[#17027] if annual diff is empty, take from current annual<commit_after><?php
/*-------------------------------------------------------------+
| SYSTOPIA Contract Extension                                  |
| Copyright (C) 2019 SYSTOPIA                                  |
| Author: <NAME> (endres -at- systopia.de)                  |
| http://www.systopia.de/                                      |
+--------------------------------------------------------------*/

use CRM_Contract_ExtensionUtil as E;

/**
 * "New Membership Signed" record
 */
class CRM_Contract_Change_Sign extends CRM_Contract_Change {

  /**
   * Get a list of required fields for this type
   *
   * @return array list of required fields
   */
  public function getRequiredFields() {
    return []; // none required because change is documentary
  }

  /**
   * Apply the given change to the contract
   *
   * @throws Exception should anything go wrong in the execution
   */
  public function execute() {
    throw new Exception("New membership sign-ups are documentary, they cannot be scheduled into the future, and therefore not executed.");
  }

  /**
   * Derive/populate additional data
   */
  public function populateData() {
    parent::populateData();
    $contract = $this->getContract(TRUE);
    if (empty($this->data['contract_updates.ch_annual_diff'])) {
      $this->data['contract_updates.ch_annual_diff'] = CRM_Utils_Array::value('membership_payment.membership_annual', $contract, '');
    }
  }


  /**
   * Check whether this change activity should actually be created
   *
   * CANCEL activities should not be created, if there is another one already there
   *
   * @throws Exception if the creation should be disallowed
   */
{'fraction_non_alphanumeric': 0.16536380036079373, 'fraction_numerical': 0.0039085989176187615, 'mean_word_length': 1.9919064748201438, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2733112', 'n_tokens_mistral': 860, 'n_tokens_neox': 819, 'n_words': 273}