CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Membership End Date not calculated properly in GUI: fixed period MembershipTypes
Pages: [1]

Author Topic: Membership End Date not calculated properly in GUI: fixed period MembershipTypes  (Read 2536 times)

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 14, 2013, 10:59:43 am
Just reproduced this on CiviCRM 4.3 Demo site:

Memberships -> New Membership -> (borrowed) Allan Cooper
California Culture Fund - Select: Student - Fixed (a 1y fixed period Membership)
Member Since: 11/14/2011 (say he joined 2y ago - but we're only getting around to entering him now)
Start Date: 11/14/2013 (today - renewal chq in hand for the next year)
End Date: leave empty
Save

Check Allan's Membership:

Active: Student (which is a rolling one - that worked as expected for these data entered)
But: Inactive (expired): Student - Fixed:

Membership        Start Date                   End Date                      Status   
Student - Fixed        November 14th, 2013   December 31st, 2011      Expired

I was expecting an End Date = December 31, 2013

Looks like for Fixed period Membership Types CiviCRM calculates End date using Member Since instead of Start Date. I don't understand when you would (ever?) want to use the MemberSince (also called Join) date to calculate an End date - shouldn't it always be based on Start Date?

I came across something similar during an import this morning: http://forum.civicrm.org/index.php/topic,30668.0.html - it's easy to ignore MemberSince during an import - but it now looks like the actual calculation doesn't work for Fixed period Memberships.

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 14, 2013, 03:53:51 pm
indeed taking $joinDate out of the equation fixes this.

in CRM/Member/Form/Membership.php:

Code: [Select]
    $calcDates = array();
    foreach ($this->_memTypeSelected as $memType) {
      $memTypeNumTerms = CRM_Utils_Array::value($memType, $termsByType, $num_terms);
      $calcDates[$memType] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($memType,
        //$joinDate,
        NULL,
        $startDate, $endDate, $memTypeNumTerms
      );
    }

What was the reason for adding $joinDate to the Membership EndDate calculation? What am I missing?

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 14, 2013, 11:33:28 pm
i think you might want to consider doing this in 2 steps
create his membership from 2 years ago
renew that membership based on the current payment you have.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 15, 2013, 08:58:55 am
Hi Pete - thanks - yes - I can see how that would be a potential workaround for a one time case when editing a Membership of a fixed period Membership Type, but:

a) we need to be able to import such data ( see: http://forum.civicrm.org/index.php/topic,30668.0.html )

StartDateIDMemberSinceType
2013-01-0112001-01-01Arctic

When imported - produces (Recent Memberships screen):

A., Robyn   Arctic   January 1st, 2001   January 1st, 2013   December 31st, 2001      Expired
So end date is mistakenly calculated as MemberSince date + 1y (from Membership Type settings).

It should be StartDate + 1y (as defined for this particular Membership in its settings):
A., Robyn   Arctic   January 1st, 2001   January 1st, 2013   December 31st, 2013      Current   

So we're 12y off in this example.

and:

b) for rolling period Membership Types the Edits described above work fine ($endDate is calculated properly under these exact same circumstances).

Doesn't this look like a bug in how $endDate is calculated for fixed period Membership Types?

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 15, 2013, 10:49:56 am
Is it following the logic explained here?

http://wiki.civicrm.org/confluence/display/CRMDOC40/Membership+Status+Rules

I remember a page where there were a whole bunch of test cases

I don't think this is it but I can't find a more recent one and it is similar to what i was looking for. dgg is best guy to get a response from i think

http://wiki.civicrm.org/confluence/display/CRM/Test+Plan+-+Membership+Renewal

If you are importing, can't you just import the End Date (expiration date)
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 15, 2013, 12:20:08 pm
The workaround is indeed to explicitly add the EndDate to the csv import file and to explicitly type in the EndDate in the GUI, but only b/c CiviCRM doesn't always calculate the EndDate properly (for fixed period Membership Types).

in the GUI - it says it does
e.g. New Membership ->
...
End Date    (clear)
"Latest membership period expiration date. End Date will be automatically set based on Membership Type if you don't select a date."
..

But the result of that calculation isn't always correct. This is just an issue w/ fixed period Membership Types.

I'm going to have a peak at:

Code: [Select]
public static function getDatesForMembershipType($membershipTypeId, $joinDate = NULL, $startDate = NULL, $endDate = NULL, $numRenewTerms = 1) {

And see if I can work out the logic behind this.

-- Karin

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 15, 2013, 01:11:50 pm
I think we need two edits (this is a 4.3.7):

1. If there is a start date - use it to calculate the $fixedStartDate. If there is no start date - then use $joinDate (="today").

Old:
Code: [Select]
$toDay = explode('-', $joinDate);
// get year from join date
$year = $toDay[0];
$month = $toDay[1];

New:
Code: [Select]
           
// get year from join date
// if !$startDate then use $joinDate
$toDay = explode('-', (empty($startDate) ? $joinDate : $startDate));
$year = $toDay[0];
$month = $toDay[1];


2.
Old:
Code: [Select]
       
//make sure membership should not start in future.
if ($joinDate < $actualStartDate) {
   $actualStartDate = date('Y-m-d', mktime(0, 0, 0, $startMonth, $startDay, $year - 1));
}

New:
Code: [Select]
       
//make sure membership should not start in future.
// if ($joinDate < $actualStartDate) {
if ($startDate < $actualStartDate) {
   $actualStartDate = date('Y-m-d', mktime(0, 0, 0, $startMonth, $startDay, $year - 1));
}

Will write this up in JIRA - for review.
« Last Edit: November 16, 2013, 10:00:35 am by KarinG »

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 15, 2013, 03:21:33 pm
can you set up some examples on the demo site so others can see the issue?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 15, 2013, 06:01:49 pm
The example I created in #1 has been wiped. I set up a new one on 4.4 demo site:

Student: rolling 1y Membership Type (comes standard w/ CiviCRM)
Student - Fixed: fixed 1y Membership Type (just created)

Both are with the same Organization: MrAdvocate

New Contact: Robyn A

1. Add Membership:
MrAdvocate: Student
Member Since: 01/01/2010
Start Date: 01/01/2013
End Date: leave empty
don't record payment
Save

Result: as expected: End Date is calculated correctly: Dec. 31, 2013

2. Add Membership:
MrAdvocate: Student - Fixed
Member Since: 01/01/2010
Start Date: 01/01/2013
End Date: leave empty
don't record payment
Save

Result: is wrong: End Date is calculated incorrectly: Dec. 31, 2010

View of both Memberships:
http://drupal.demo.civicrm.org/civicrm/contact/view?reset=1&cid=206



KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 16, 2013, 10:21:03 am
I opened a pull request for Eileen to review - her 4.2. LTS:

https://github.com/CiviCRM42/civicrm42-core/pull/54
file diff: https://github.com/CiviCRM42/civicrm42-core/pull/54/files

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 17, 2013, 07:00:33 am
in JIRA:
http://issues.civicrm.org/jira/browse/CRM-13786

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 21, 2013, 08:32:07 am
Just a quick follow up that this issue was resolved. Patch made it into 4.4.2 and 4.2.14 (last night). It will also be in 4.3.9 once that comes out.
« Last Edit: November 21, 2013, 08:49:54 am by KarinG »

Detlev

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
    • Software für Engagierte e.V.
  • CiviCRM version: 4.5
  • CMS version: Drupal
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 21, 2013, 08:46:09 am
Quote from: KarinG on November 21, 2013, 08:32:07 am
Patch made it into 4.2.2 and 4.2.14 (last night). It will also be in 4.3.9 once that comes out.
Should read: 4.4.2 instead of 4.2.2 !

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: Membership End Date not calculated properly in GUI: fixed period MembershipTypes
November 21, 2013, 08:50:49 am
Fixed my typo! Thanks for catching that.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Membership End Date not calculated properly in GUI: fixed period MembershipTypes

This forum was archived on 2017-11-26.