feat: improved invoice stamping command
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
"scienta/doctrine-json-functions": "^6.3",
|
"scienta/doctrine-json-functions": "^6.3",
|
||||||
"setasign/fpdf": "^1.8",
|
"setasign/fpdf": "^1.8",
|
||||||
"setasign/fpdi": "^2.5",
|
"setasign/fpdi": "^2.5",
|
||||||
|
"spatie/blink": "^1.4",
|
||||||
"spatie/icalendar-generator": "^2.5",
|
"spatie/icalendar-generator": "^2.5",
|
||||||
"symfony/apache-pack": "^1.0",
|
"symfony/apache-pack": "^1.0",
|
||||||
"symfony/asset": "6.4.*",
|
"symfony/asset": "6.4.*",
|
||||||
|
|||||||
Generated
+63
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "52ec6ca4d15ec27e3586b5bab26b528c",
|
"content-hash": "0bd1cb4a8201fb9558138001813bec5a",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "beberlei/doctrineextensions",
|
"name": "beberlei/doctrineextensions",
|
||||||
@@ -3371,6 +3371,68 @@
|
|||||||
],
|
],
|
||||||
"time": "2025-02-05T13:22:35+00:00"
|
"time": "2025-02-05T13:22:35+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "spatie/blink",
|
||||||
|
"version": "1.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/spatie/blink.git",
|
||||||
|
"reference": "d2c12b84ba04d4c5b53d701cc09810bf7e5d546f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/spatie/blink/zipball/d2c12b84ba04d4c5b53d701cc09810bf7e5d546f",
|
||||||
|
"reference": "d2c12b84ba04d4c5b53d701cc09810bf7e5d546f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.5"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Spatie\\Blink\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Freek Van der Herten",
|
||||||
|
"email": "[email protected]",
|
||||||
|
"homepage": "https://spatie.be",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Cache that expires in the blink of an eye",
|
||||||
|
"homepage": "https://github.com/spatie/blink",
|
||||||
|
"keywords": [
|
||||||
|
"Blink",
|
||||||
|
"cache",
|
||||||
|
"caching",
|
||||||
|
"spatie"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/spatie/blink/issues",
|
||||||
|
"source": "https://github.com/spatie/blink/tree/1.4.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://spatie.be/open-source/support-us",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/spatie",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-07-19T18:28:44+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "spatie/enum",
|
"name": "spatie/enum",
|
||||||
"version": "3.13.0",
|
"version": "3.13.0",
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ namespace App\Command;
|
|||||||
|
|
||||||
use App\Entity\Disposition;
|
use App\Entity\Disposition;
|
||||||
use App\Entity\Upload;
|
use App\Entity\Upload;
|
||||||
|
use App\Entity\User;
|
||||||
use App\Service\Pdf\InvoiceApprover;
|
use App\Service\Pdf\InvoiceApprover;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Spatie\Blink\Blink;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Helper\ProgressBar;
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
@@ -42,8 +44,24 @@ class StampUploadsCommand extends Command
|
|||||||
|
|
||||||
$progressBar = new ProgressBar($output, count($dispositions));
|
$progressBar = new ProgressBar($output, count($dispositions));
|
||||||
$progressBar->start();
|
$progressBar->start();
|
||||||
|
$blink = new Blink();
|
||||||
|
$userRepository = $this->entityManager->getRepository(User::class);
|
||||||
|
|
||||||
foreach ($dispositions as $disposition) {
|
foreach ($dispositions as $disposition) {
|
||||||
|
/** @var Disposition $disposition */
|
||||||
|
$upload = $disposition->getDocumentByType(Upload::TYPE_INVOICE);
|
||||||
|
if (null === $upload->getApprovedBy()) {
|
||||||
|
$email = $upload->getUpdatedBy();
|
||||||
|
if ($blink->has($email)) {
|
||||||
|
$approvingUser = $blink->get($email);
|
||||||
|
} else {
|
||||||
|
$approvingUser = $userRepository->findOneBy(['email' => $email]);
|
||||||
|
$blink->put($email, $approvingUser);
|
||||||
|
}
|
||||||
|
if (null !== $approvingUser) {
|
||||||
|
$upload->setApprovedBy($approvingUser->getInitials());
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->invoiceApprover->render($disposition);
|
$this->invoiceApprover->render($disposition);
|
||||||
$progressBar->advance();
|
$progressBar->advance();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user