Create Enum for Invoice type codes and build a translatable Trait.

This commit is contained in:
2025-01-31 13:02:14 +01:00
parent b887899dfc
commit 69c0222cc6
2 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Enum;
enum InvoiceTypeCode: string
{
use hasTranslatable;
case PARTIAL_INVOICE = '326';
case COMMERCIAL_INVOICE = '380';
case CREDIT_NOTE = '381';
case CORRECTED_INVOICE = '384';
case SELF_BILLED_INVOICE = '389';
case PARTIAL_CONSTRUCTION_INVOICE = '875';
case PARTIAL_FINAL_CONSTRUCTION_INVOICE = '876';
case FINAL_CONSTRUCTION_INVOICE = '877';
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Enum;
trait hasTranslatable
{
public static function options(): array
{
$options = [];
foreach (self::cases() as $value) {
$options[$value->value] = __('enum.' . $value->name);
}
return $options;
}
public static function label($value)
{
return self::options()[$value];
}
}