Management downloads a created billing material as a semicolon CSV with decimal commas and a UTF-8 BOM for Excel: one row per invoice line with the invoice's customer, billing unit, e-invoice details and reference, the job, the line and its net, VAT and gross amounts. Consumers' full personal identity codes are included only for those who may see them, the response is not cached, and cells Excel would read as formulas are escaped. The columns follow Fennoa's import format once a sample exists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Billing\Infrastructure;
|
|
|
|
use App\Modules\Billing\Application\Contracts\BillingCustomers;
|
|
use App\Modules\Billing\Application\DTOs\CustomerBillingDetails;
|
|
use App\Modules\Customers\Application\Contracts\CustomerQueries;
|
|
use App\Modules\Customers\Domain\Enums\CustomerType;
|
|
|
|
/**
|
|
* Customers' invoicing details through the Customers module's queries.
|
|
*/
|
|
class CustomersForBilling implements BillingCustomers
|
|
{
|
|
public function __construct(private CustomerQueries $customers) {}
|
|
|
|
public function billingDetails(int $customerId, ?int $billingUnitId, bool $withIdentityCode): CustomerBillingDetails
|
|
{
|
|
$customer = $this->customers->findSummary($customerId);
|
|
$isConsumer = $customer?->type === CustomerType::Consumer;
|
|
$unit = $billingUnitId === null ? null : $this->customers->findBillingUnit($customerId, $billingUnitId);
|
|
|
|
return new CustomerBillingDetails(
|
|
$customer->name ?? '',
|
|
$isConsumer,
|
|
$customer?->businessId,
|
|
$isConsumer && $withIdentityCode ? $this->customers->personalIdentityCodeOf($customerId) : null,
|
|
$unit?->name,
|
|
$unit?->billingAddress,
|
|
$unit?->eInvoiceAddress,
|
|
$unit?->eInvoiceOperator,
|
|
$unit?->reference,
|
|
);
|
|
}
|
|
}
|