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))
|
||||
{
|
||||
// TODO: find warranties that used date_schedule for date_purchase
|
||||
// find warranties that used date_schedule for date_purchase
|
||||
$missing_flag = true;
|
||||
$jo_warranty_class = $jo->getWarrantyClass();
|
||||
|
||||
$warr_period = $this->getWarrantyPeriod($jo_warranty_class, $invoice_item);
|
||||
|
||||
// get date fulfill
|
||||
$datetime_fulfilled = $jo->getDateFulfill();
|
||||
if ($datetime_fulfilled != null)
|
||||
// get date schedule
|
||||
$datetime_schedule = $jo->getDateSchedule();
|
||||
$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');
|
||||
$date_fulfilled = DateTime::createFromFormat('Y-m-d', $datetime_fulfilled_str);
|
||||
$missing_flag = false;
|
||||
|
||||
$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)))
|
||||
foreach ($warranties_date_scheduled as $warranty_date_scheduled)
|
||||
{
|
||||
$missing_flag = false;
|
||||
|
||||
foreach ($warranties_date_fulfilled as $warranty_date_fulfilled)
|
||||
// check if sap_code exists in battery
|
||||
$warr_sap_battery = $warranty_date_scheduled->getSAPBattery();
|
||||
if ($warr_sap_battery != null)
|
||||
{
|
||||
// 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();
|
||||
$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]);
|
||||
if ($batteries == null)
|
||||
{
|
||||
$no_saps[] = [
|
||||
'warranty_id' => $warranty_date_fulfilled->getID(),
|
||||
'plate_number' => $cleaned_plate_number,
|
||||
'sap_code' => $warr_sap_code,
|
||||
];
|
||||
}
|
||||
$no_saps[] = [
|
||||
'warranty_id' => $warranty_date_scheduled->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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue