Skip to content

Commit

Permalink
Merge pull request #54 from TheDMSGroup/various-bugs
Browse files Browse the repository at this point in the history
Minor bugs surrounding field changes.
  • Loading branch information
heathdutton authored Jun 13, 2018
2 parents 59c1caf + adc6370 commit 49e2796
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Integration/AgeFromBirthdateIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public function doEnhancement(Lead &$lead)
$month = intval($lead->getFieldValue('dob_month'));
$day = intval($lead->getFieldValue('dob_day'));

if ($year && $month && $day) {
if ($year && $month && $month <= 12 && $day && $day <= 31) {
$birthdate = sprintf('%04d-%02d-%02d 00:00:00', $year, $month, $day);
$dob = new DateTime($birthdate);
$today = new DateTime();
$age = (int) $today->diff($dob)->y;
$prevAge = (int) $lead->getFieldValue('afb_age');
if ($age !== $prevAge) {
if ($age !== $prevAge && $age < 120) {
$this->logger->info("calculated age is $age");
$lead->addUpdatedField('afb_age', $age, $prevAge);

Expand Down
4 changes: 2 additions & 2 deletions Integration/PhoneToPartsIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getDisplayName()
protected function getEnhancerFieldArray()
{
return [
'ptp_areacode' => [
'ptp_area_code' => [
'label' => 'Area Code',
],
'ptp_prefix' => [
Expand All @@ -54,7 +54,7 @@ public function doEnhancement(Lead &$lead)
}

if (10 === strlen($phone)) {
$lead->addUpdatedField('ptp_areacode', substr($phone, 0, 3));
$lead->addUpdatedField('ptp_area_code', substr($phone, 0, 3));
$lead->addUpdatedField('ptp_prefix', substr($phone, 3, 3));
$lead->addUpdatedField('ptp_line_number', substr($phone, 6, 4));

Expand Down

0 comments on commit 49e2796

Please sign in to comment.