Add checking for warranties with date schedule as the start date of expiry date computation. #407
This commit is contained in:
parent
f2de60d65a
commit
714aa5636d
1 changed files with 86 additions and 38 deletions
|
|
@ -169,61 +169,109 @@ class GetFlawedWarrantiesCommand extends Command
|
||||||
|
|
||||||
if (empty($results_date_create))
|
if (empty($results_date_create))
|
||||||
{
|
{
|
||||||
// TODO: find warranties that used date_schedule for date_purchase
|
// find warranties that used date_schedule for date_purchase
|
||||||
$missing_flag = true;
|
$missing_flag = true;
|
||||||
$jo_warranty_class = $jo->getWarrantyClass();
|
$jo_warranty_class = $jo->getWarrantyClass();
|
||||||
|
|
||||||
$warr_period = $this->getWarrantyPeriod($jo_warranty_class, $invoice_item);
|
$warr_period = $this->getWarrantyPeriod($jo_warranty_class, $invoice_item);
|
||||||
|
|
||||||
// get date fulfill
|
// get date schedule
|
||||||
$datetime_fulfilled = $jo->getDateFulfill();
|
$datetime_schedule = $jo->getDateSchedule();
|
||||||
if ($datetime_fulfilled != null)
|
$datetime_schedule_str = $datetime_schedule->format('Y-m-d');
|
||||||
|
$date_scheduled = DateTime::createFromFormat('Y-m-d', $datetime_schedule_str);
|
||||||
|
|
||||||
|
$expiry_date_date_scheduled = $this->wh->computeDateExpire($date_scheduled, $warr_period);
|
||||||
|
|
||||||
|
// find warranties with date_schedule as the date_purchase
|
||||||
|
$warranties_date_scheduled = $em->getRepository(Warranty::class)->findBy(['plate_number' => $cleaned_plate_number,
|
||||||
|
'date_purchase' => $date_scheduled]);
|
||||||
|
|
||||||
|
if (!(empty($warranties_date_scheduled)))
|
||||||
{
|
{
|
||||||
$datetime_fulfilled_str = $datetime_fulfilled->format('Y-m-d');
|
$missing_flag = false;
|
||||||
$date_fulfilled = DateTime::createFromFormat('Y-m-d', $datetime_fulfilled_str);
|
|
||||||
|
|
||||||
$expiry_date_date_create = $this->wh->computeDateExpire($date_fulfilled, $warr_period);
|
foreach ($warranties_date_scheduled as $warranty_date_scheduled)
|
||||||
|
|
||||||
// find warranties with date fulfilled as the date_purchase
|
|
||||||
$warranties_date_fulfilled = $em->getRepository(Warranty::class)->findBy(['plate_number' => $cleaned_plate_number,
|
|
||||||
'date_purchase' => $date_fulfilled]);
|
|
||||||
|
|
||||||
if (!(empty($warranties_date_fulfilled)))
|
|
||||||
{
|
{
|
||||||
$missing_flag = false;
|
// check if sap_code exists in battery
|
||||||
|
$warr_sap_battery = $warranty_date_scheduled->getSAPBattery();
|
||||||
foreach ($warranties_date_fulfilled as $warranty_date_fulfilled)
|
if ($warr_sap_battery != null)
|
||||||
{
|
{
|
||||||
// check if sap_code exists in battery
|
$warr_sap_code = $warr_sap_battery->getID();
|
||||||
$warr_sap_battery = $warranty_date_fulfilled->getSAPBattery();
|
|
||||||
if ($warr_sap_battery != null)
|
|
||||||
{
|
|
||||||
$warr_sap_code = $warr_sap_battery->getID();
|
|
||||||
|
|
||||||
if ($warr_sap_code != null)
|
if ($warr_sap_code != null)
|
||||||
|
{
|
||||||
|
$batteries = $em->getRepository(Battery::class)->findBy(['sap_code' => $warr_sap_code]);
|
||||||
|
if ($batteries == null)
|
||||||
{
|
{
|
||||||
$batteries = $em->getRepository(Battery::class)->findBy(['sap_code' => $warr_sap_code]);
|
$no_saps[] = [
|
||||||
if ($batteries == null)
|
'warranty_id' => $warranty_date_scheduled->getID(),
|
||||||
{
|
'plate_number' => $cleaned_plate_number,
|
||||||
$no_saps[] = [
|
'sap_code' => $warr_sap_code,
|
||||||
'warranty_id' => $warranty_date_fulfilled->getID(),
|
];
|
||||||
'plate_number' => $cleaned_plate_number,
|
|
||||||
'sap_code' => $warr_sap_code,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrong expiration date
|
|
||||||
$date_expiry_wrongs[] = [
|
|
||||||
'warranty_id' => $warranty_date_fulfilled->getID(),
|
|
||||||
'plate_number' => $cleaned_plate_number,
|
|
||||||
'expiry_date' => $expiry_date_date_create->format('Y-m-d'),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wrong expiration date
|
||||||
|
$date_expiry_wrongs[] = [
|
||||||
|
'warranty_id' => $warranty_date_scheduled->getID(),
|
||||||
|
'plate_number' => $cleaned_plate_number,
|
||||||
|
'expiry_date' => $expiry_date_date_create->format('Y-m-d'),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// get date fulfill
|
||||||
|
$datetime_fulfilled = $jo->getDateFulfill();
|
||||||
|
if ($datetime_fulfilled != null)
|
||||||
|
{
|
||||||
|
$datetime_fulfilled_str = $datetime_fulfilled->format('Y-m-d');
|
||||||
|
$date_fulfilled = DateTime::createFromFormat('Y-m-d', $datetime_fulfilled_str);
|
||||||
|
|
||||||
|
$expiry_date_date_create = $this->wh->computeDateExpire($date_fulfilled, $warr_period);
|
||||||
|
|
||||||
|
// find warranties with date fulfilled as the date_purchase
|
||||||
|
$warranties_date_fulfilled = $em->getRepository(Warranty::class)->findBy(['plate_number' => $cleaned_plate_number,
|
||||||
|
'date_purchase' => $date_fulfilled]);
|
||||||
|
|
||||||
|
if (!(empty($warranties_date_fulfilled)))
|
||||||
|
{
|
||||||
|
$missing_flag = false;
|
||||||
|
|
||||||
|
foreach ($warranties_date_fulfilled as $warranty_date_fulfilled)
|
||||||
|
{
|
||||||
|
// check if sap_code exists in battery
|
||||||
|
$warr_sap_battery = $warranty_date_fulfilled->getSAPBattery();
|
||||||
|
if ($warr_sap_battery != null)
|
||||||
|
{
|
||||||
|
$warr_sap_code = $warr_sap_battery->getID();
|
||||||
|
|
||||||
|
if ($warr_sap_code != null)
|
||||||
|
{
|
||||||
|
$batteries = $em->getRepository(Battery::class)->findBy(['sap_code' => $warr_sap_code]);
|
||||||
|
if ($batteries == null)
|
||||||
|
{
|
||||||
|
$no_saps[] = [
|
||||||
|
'warranty_id' => $warranty_date_fulfilled->getID(),
|
||||||
|
'plate_number' => $cleaned_plate_number,
|
||||||
|
'sap_code' => $warr_sap_code,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrong expiration date
|
||||||
|
$date_expiry_wrongs[] = [
|
||||||
|
'warranty_id' => $warranty_date_fulfilled->getID(),
|
||||||
|
'plate_number' => $cleaned_plate_number,
|
||||||
|
'expiry_date' => $expiry_date_date_create->format('Y-m-d'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($missing_flag)
|
if ($missing_flag)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue