Skip to content

Commit

Permalink
1635: Increased invoice description length
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Jul 1, 2024
1 parent a9917b9 commit 63b5b66
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
31 changes: 31 additions & 0 deletions migrations/Version20240701104400.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240701104400 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE invoice CHANGE description description VARCHAR(500) DEFAULT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE invoice CHANGE description description VARCHAR(255) DEFAULT NULL');
}
}
6 changes: 5 additions & 1 deletion src/Entity/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
#[ORM\Entity(repositoryClass: InvoiceRepository::class)]
class Invoice extends AbstractBaseEntity
{
// Opus allows at most 500 characters (cf. BillingService::exportInvoicesToSpreadsheet).
public const DESCRIPTION_MAX_LENGTH = 500;

#[ORM\Column(length: 255)]
private ?string $name = null;

#[ORM\Column(length: 255, nullable: true)]

#[ORM\Column(length: self::DESCRIPTION_MAX_LENGTH, nullable: true)]
private ?string $description = null;

#[ORM\Column]
Expand Down
2 changes: 1 addition & 1 deletion src/Service/BillingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function exportInvoicesToSpreadsheet(array $invoiceIds): Spreadsheet
$setCellValue(15, $row, substr('Att: '.$contactName, 0, 35));
// 16. "Toptekst, yderligere spec i det hvide felt på fakturaen"
$description = $invoice->getDescription() ?? '';
$setCellValue(16, $row, substr($description, 0, 500));
$setCellValue(16, $row, substr($description, 0, Invoice::DESCRIPTION_MAX_LENGTH));
// 17. "Leverandør"
if ($internal) {
$setCellValue(17, $row, str_pad($this->invoiceSupplierAccount, 10, '0', \STR_PAD_LEFT));
Expand Down

0 comments on commit 63b5b66

Please sign in to comment.