-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command that sends outstanding appliance debts
- Loading branch information
Showing
13 changed files
with
203 additions
and
119 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Website/htdocs/mpmanager/app/Console/Commands/MailApplianceDebtsCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace app\Console\Commands; | ||
|
||
use App\Services\ApplianceRateService; | ||
use MPM\OutstandingDebts\OutstandingDebtsExportService; | ||
|
||
class MailApplianceDebtsCommand extends AbstractSharedCommand | ||
{ | ||
protected $signature = 'mail:appliance-debts'; | ||
|
||
protected $description = 'Send mail to customers with appliance debts'; | ||
|
||
|
||
public function handle(ApplianceRateService $applianceRateService, OutstandingDebtsExportService $outstandingDebtsExportService): void | ||
{ | ||
$applianceDebtHavingCustomerCount = $applianceRateService->queryOutstandingDebtsByApplianceRates()->count(); | ||
// do not send mail if there is no customer with appliance debt | ||
if ($applianceDebtHavingCustomerCount > 0) { | ||
$outstandingDebtsExportService->sendApplianceDebtsAsEmail(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 9 additions & 19 deletions
28
Website/htdocs/mpmanager/app/Http/Controllers/OutstandingDebtsExportController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Services\ApplianceRateService; | ||
use Illuminate\Http\Request; | ||
use MPM\OutstandingDebts\Export\OutstandingDebtsExportService; | ||
use Carbon\CarbonImmutable; | ||
use MPM\OutstandingDebts\OutstandingDebtsExportService; | ||
use Symfony\Component\HttpFoundation\BinaryFileResponse; | ||
|
||
class OutstandingDebtsExportController | ||
{ | ||
private string $path = __DIR__ . '/../../modules/OutstandingDebts/Export'; | ||
|
||
public function __construct( | ||
private OutstandingDebtsExportService $outstandingDebtsExportService, | ||
private ApplianceRateService $applianceRateService | ||
) { | ||
} | ||
|
||
public function download( | ||
Request $request, | ||
) { | ||
$data = $this->applianceRateService->getOutstandingDebtsByApplianceRates(); | ||
$this->outstandingDebtsExportService->createSpreadSheetFromTemplate($this->outstandingDebtsExportService->getTemplatePath()); | ||
$currency = $this->applianceRateService->getCurrencyFromMainSettings(); | ||
$this->outstandingDebtsExportService->setCurrency($currency); | ||
$this->outstandingDebtsExportService->setOutstandingDebtsData($data); | ||
$this->outstandingDebtsExportService->setExportingData(); | ||
$this->outstandingDebtsExportService->writeOutstandingDebtsData(); | ||
$this->outstandingDebtsExportService->saveSpreadSheet($this->path); | ||
public function download(): BinaryFileResponse | ||
{ | ||
$path = $this->outstandingDebtsExportService->createReport(CarbonImmutable::now()); | ||
|
||
return response()->download($this->path . '/' . | ||
$this->outstandingDebtsExportService->getRecentlyCreatedSpreadSheetId() . '.xlsx'); | ||
return response()->download($path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.