Revert start date of expiry date for warranty back to date_create of invoice. #402

This commit is contained in:
Korina Cordero 2020-05-14 10:44:04 +00:00
parent a5c2c79783
commit 3e83a8e9d2
2 changed files with 12 additions and 11 deletions

View file

@ -191,9 +191,7 @@ class GenerateWarrantyFromJobOrderCommand extends Command
$bty_size_id = $invoice_item->getBattery()->getSize()->getID();
$warranty_class = $jo->getWarrantyClass();
// NOTE: changing date_purchase to date_schedule unless told otherwise
//$date = $jo->getInvoice()->getDateCreate();
$date = $jo->getDateSchedule();
$date = $jo->getInvoice()->getDateCreate();
$date_purchase = $date->format('Y-m-d');
$date_create = date('Y-m-d H:i:s');

View file

@ -104,12 +104,17 @@ class WarrantyCleanupCommand extends Command
// check if a warranty exists with the plate number and date_schedule
// get date_schedule
$datetime_schedule = $jo->getDateSchedule();
$datetime_schedule_str = $datetime_schedule->format('Y-m-d');
$date_schedule = DateTime::createFromFormat('Y-m-d', $datetime_schedule_str);
//$datetime_schedule = $jo->getDateSchedule();
//$datetime_schedule_str = $datetime_schedule->format('Y-m-d');
//$date_schedule = DateTime::createFromFormat('Y-m-d', $datetime_schedule_str);
$warranties_date_schedule = $this->em->getRepository(Warranty::class)->findBy(['plate_number' => $clean_plate_num, 'date_purchase' => $date_schedule]);
if (empty($warranties_date_schedule))
// check if warranty exists with plate number and date_create of invoice
$date = $jo->getInvoice()->getDateCreate();
$date_create_invoice_str = $date->format('Y-m-d');
$date_create_invoice = DateTime::createFromFormat('Y-m-d', $date_create_invoice_str);
$warranties_date_create = $this->em->getRepository(Warranty::class)->findBy(['plate_number' => $clean_plate_num, 'date_purchase' => $date_create_invoice]);
if (empty($warranties_date_create))
{
// check if warranty exists with plate number and date_fulfilled
$datetime_fulfilled = $jo->getDateFulfill();
@ -139,13 +144,11 @@ class WarrantyCleanupCommand extends Command
$warranty_period = $invoice_item->getBattery()->getWarrantyTnv();
}
// NOTE: changing date_purchase to date_schedule unless told otherwise
$date_purchase = $datetime_schedule_str;
// compute expiration date
$expiry_date = $this->wh->computeDateExpire($date_schedule, $warranty_period);
$date_expiry = $expiry_date->format('Y-m-d');
$date_purchase_value = '\'' . $date_purchase . '\'';
$date_purchase_value = '\'' . $date_create_invoice_str . '\'';
$date_expire_value = '\'' . $date_expiry . '\'';
$update_sql_statement = 'UPDATE `warranty` SET date_expire=' . $date_expire_value . ', date_purchase=' . $date_purchase_value . ' WHERE id=\'' . $warranty->getID() . '\';' . "\n";