Skip to content

BASW-131: Membership end date rules#6

Open
nishant-bhorodia wants to merge 3 commits into7.x-4.xfrom
BASW-131-membership-end-date-rules
Open

BASW-131: Membership end date rules#6
nishant-bhorodia wants to merge 3 commits into7.x-4.xfrom
BASW-131-membership-end-date-rules

Conversation

@nishant-bhorodia
Copy link
Copy Markdown

@nishant-bhorodia nishant-bhorodia commented Nov 27, 2018

Overview:
In Webform/CiviCRM it is not possible

  1. To specify the end date of a new membership.
  2. Calculate pro-rate for membership.

Solution:
This PR adds the functionality to

  1. Specify End date for a membership.
  2. Calculate pro-rate for a membership based on the formula below:

Pro-rated membership fee = (regular membership fee/ number of days in regular membership period) x number of days in pro-rated membership period

Comment thread includes/utils.inc
'value' => 0,
'exposed_empty_option' => t('Automatic'),
);
$fields['membership_start_date_memberships'] = array (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe membership_start_date_rules_memberships is more clear, same for end_date_rules

Comment thread includes/utils.inc Outdated
'expose_list' => TRUE,
'extra' => array('multiple' => 1),
);
$fields['membership_pro_rate_membership'] = array(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this field is not related to the commit, it should not be here, and while it is fine for this PR, I think it is important to not do that when you open the PR against webform_civicrm core repo.

Comment thread includes/utils.inc Outdated
'expose_list' => TRUE,
'extra' => array('multiple' => 1),
);
$fields['membership_pro_rate_membership'] = array(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you removed this field on purpose ? or is it by mistake ?

}
}

// Pro rate price checkbox
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be easy to move this logic to a new private method with a clear name ?

/**
* Validate function for membership date rules.
*/
public function validateMembershipDateRules() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this to be public method

* Validate function for membership date rules.
*/
public function validateMembershipDateRules() {
if (!empty($this->data['membership'])) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or :

if (empty($this->data['membership'])) {
return;
}
// rest of the code

* @param Array $item
* @return Float $price
*/
private function pro_rated_membership_fee($type, $price, $c, $n, $item) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or change the method name to : caculateMembershipProRateFee

* @param Float $price
* @param Integer $c
* @param Array $item
* @return Float $price
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docblock params does not match the method params

* @param Array $item
* @return Float $price
*/
private function pro_rated_membership_fee($type, $price, $c, $n, $item) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you replace $c and $n and $item with names that represent what they actually about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants