48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Command;
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use App\Service\Prowar\WarrantyComputationCriteria;
|
|
use App\Service\Prowar\WarrantyComputationService;
|
|
|
|
use DateTime;
|
|
|
|
class TestWarrantyComputationCommand extends Command
|
|
{
|
|
protected $wcs;
|
|
|
|
protected function configure()
|
|
{
|
|
$this->setName('test:generatewarrantycomputation')
|
|
->setDescription('Test Prowar generate warranty computation service.')
|
|
->setHelp('Test Prowar generate warranty computation service.');
|
|
}
|
|
|
|
public function __construct(WarrantyComputationService $wcs)
|
|
{
|
|
$this->wcs = $wcs;
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$warr_criteria = new WarrantyComputationCriteria();
|
|
|
|
// set test values
|
|
$warr_criteria->setTotalWarranty(24)
|
|
->setPurchaseDate(DateTime::createFromFormat('Y-m-d', '2018-06-15'))
|
|
->setClaimDate(new DateTime())
|
|
->setBatteryPrice(100.00)
|
|
->setRate(5)
|
|
->setWarrantyLimit(12);
|
|
|
|
$amount = $this->wcs->generateWarrantyComputation($warr_criteria);
|
|
|
|
error_log('Customer pays ' . $amount);
|
|
}
|
|
}
|