fix(statements/transactions)

This commit is contained in:
2026-06-02 21:00:44 +03:00
parent a412af3e07
commit c763fe6c71
9 changed files with 269 additions and 95 deletions

View File

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Apoloz\AlfaBank\Data\Statement;
use Spatie\LaravelData\Data;
class CartInfoData extends Data
{
public function __construct(
public ?string $documentCode = null,
public ?string $documentContent = null,
public ?string $documentDate = null,
public ?string $documentNumber = null,
public ?string $paymentNumber = null,
public ?string $restAmount = null,
) {}
}

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Apoloz\AlfaBank\Data\Statement;
use Spatie\LaravelData\Data;
class CurTransferData extends Data
{
public function __construct(
public ?string $bankOperationCode = null,
public ?string $beneficiaryBankAccount = null,
public ?string $beneficiaryBankName = null,
public ?string $beneficiaryBankOption = null,
public ?string $beneficiaryCustomerAccount = null,
public ?string $beneficiaryCustomerName = null,
public ?string $detailsOfCharges = null,
public ?string $exchangeRate = null,
public ?string $instructedAmount = null,
public ?string $instructionCode = null,
public ?string $intermediaryBankAccount = null,
public ?string $intermediaryBankName = null,
public ?string $intermediaryBankOption = null,
public ?string $orderingCustomerAccount = null,
public ?string $orderingCustomerName = null,
public ?string $payeeBankBic = null,
public ?string $payeeBankCorrAccount = null,
public ?string $payeeBankName = null,
public ?string $payerInn = null,
public ?string $receiverCorrespondentAccount = null,
public ?string $receiverCorrespondentName = null,
public ?string $regulatoryReporting = null,
public ?string $senderCorrespondentAccount = null,
public ?string $senderCorrespondentName = null,
public ?string $senderCorrespondentOption = null,
public ?string $senderToReceiverInformation = null,
public ?string $transactionRelatedReference = null,
public ?string $valueDateCurrencyInterbankSettledAmount = null,
) {}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Apoloz\AlfaBank\Data\Statement;
use Spatie\LaravelData\Data;
class DepartmentalInfoData extends Data
{
public function __construct(
public ?string $uip = null,
public ?string $drawerStatus101 = null,
public ?string $kbk = null,
public ?string $oktmo = null,
public ?string $reasonCode106 = null,
public ?string $taxPeriod107 = null,
public ?string $docNumber108 = null,
public ?string $docDate109 = null,
public ?string $paymentKind110 = null,
) {}
}

View File

@@ -1,29 +1,17 @@
<?php
declare(strict_types=1);
/*
// MODULE_CONTRACT: Defines the data structure for detailed Russian Ruble (RUR) transfer information within a transaction.
// RESPONSIBILITY: To hold and type-safely represent comprehensive details about the payer and payee in an RUR transfer.
// INPUTS: Raw JSON object from the API response.
// OUTPUTS: A structured object containing RUR transfer details.
// LINKS: TransactionData.php
*/
namespace Apoloz\AlfaBank\Data\Statement;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides other DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for Russian Ruble transfer details.">
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for highly detailed RUR transfer information, which is critical for financial reconciliation and compliance with Russian banking standards.">
class RurTransferData extends Data
{
// <SECTION name="constructor_properties" intent="Define the comprehensive properties of an RUR transfer.">
// <BELIEF_STATE "The constructor includes a wide array of optional fields covering full payee and payer details (account, bank BIC, correspondent account, INN, KPP, name), as well as specific payment attributes like `paymentKind110`, `priority`, `receiptDate`, and `valueDate`. All are optional as not all fields may be present or relevant in every transaction record.">
public function __construct(
public ?CartInfoData $cartInfo = null,
public ?string $deliveryKind = null,
public ?DepartmentalInfoData $departmentalInfo = null,
public ?string $payeeAccount = null,
public ?string $payeeBankBic = null,
public ?string $payeeBankCorrAccount = null,
@@ -38,10 +26,10 @@ class RurTransferData extends Data
public ?string $payerInn = null,
public ?string $payerKpp = null,
public ?string $payerName = null,
public ?string $payingCondition = null,
public ?string $paymentKind110 = null,
public ?string $priority = null,
public ?string $purposeCode = null,
public ?string $receiptDate = null,
public ?string $valueDate = null,
) {}
// </SECTION>
}

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Apoloz\AlfaBank\Data\Statement;
use Spatie\LaravelData\Data;
class SwiftTransferData extends Data
{
public function __construct(
public ?string $bankOperationCode = null,
public ?string $beneficiaryBankAccount = null,
public ?string $beneficiaryBankName = null,
public ?string $beneficiaryBankOption = null,
public ?string $beneficiaryCustomerAccount = null,
public ?string $beneficiaryCustomerName = null,
public ?string $detailsOfCharges = null,
public ?string $exchangeRate = null,
public ?string $instructedAmount = null,
public ?string $instructionCode = null,
public ?string $intermediaryBankAccount = null,
public ?string $intermediaryBankName = null,
public ?string $intermediaryBankOption = null,
public ?string $orderingCustomerAccount = null,
public ?string $orderingCustomerName = null,
public ?string $payeeBankCorrAccount = null,
public ?string $payeeBankName = null,
public ?string $payeeBankBic = null,
public ?string $payerInn = null,
public ?string $receiverCorrespondentAccount = null,
public ?string $receiverCorrespondentName = null,
public ?string $regulatoryReporting = null,
public ?string $senderCorrespondentAccount = null,
public ?string $senderCorrespondentName = null,
public ?string $senderCorrespondentOption = null,
public ?string $senderToReceiverInformation = null,
public ?string $transactionRelatedReference = null,
public ?string $valueDateCurrencyInterbankSettledAmount = null,
) {}
}

View File

@@ -1,34 +1,18 @@
<?php
declare(strict_types=1);
/*
// MODULE_CONTRACT: Defines the data structure for a paginated collection of TransactionData objects.
// RESPONSIBILITY: To provide a structured, type-safe container for lists of account transactions returned by the API, including pagination metadata.
// INPUTS: Raw JSON array from the API response.
// OUTPUTS: An object containing pagination details and a collection of `TransactionData`.
// LINKS: Requests/Statement/GetTransactionsRequest.php
*/
namespace Apoloz\AlfaBank\Data\Statement;
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
// <BELIEF_STATE "This collection DTO relies on `PaginationData` for metadata and `TransactionData` for the individual items. `DataCollection` and `DataCollectionOf` are Spatie Data features for handling typed arrays of DTOs.">
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for a collection of account transactions.">
// <BELIEF_STATE "A dedicated DTO for a collection ensures that the structure of paginated lists is consistent and type-safe, providing a reliable contract for consumers to manage financial statements.">
class TransactionCollectionData extends Data
{
// <SECTION name="constructor_properties" intent="Define the properties of the transaction collection.">
// <BELIEF_STATE "The collection structure includes pagination metadata (`pagination`) and the actual list of transactions (`transactions`). The `#[DataCollectionOf(TransactionData::class)]` attribute is crucial for ensuring that each item in the `transactions` array is automatically cast to a `TransactionData` DTO.">
public function __construct(
#[DataCollectionOf(TransactionData::class)]
public DataCollection $transactions
) {
}
// </SECTION>
public DataCollection $transactions,
public ?array $_links = null,
) {}
}

View File

@@ -1,39 +1,32 @@
<?php
declare(strict_types=1);
/*
// MODULE_CONTRACT: Defines the data structure for a single transaction record.
// RESPONSIBILITY: To hold and type-safely represent the details of an individual account transaction.
// INPUTS: Raw JSON object from the API response.
// OUTPUTS: A structured object containing transaction details.
// LINKS: TransactionCollectionData.php
*/
namespace Apoloz\AlfaBank\Data\Statement;
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
// <BELIEF_STATE "This DTO includes nested `AmountData` for monetary values and `RurTransferData` for detailed transfer information.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for a single account transaction.">
// <BELIEF_STATE "This DTO provides a comprehensive, type-safe representation of a transaction, essential for consistent data handling and financial reporting.">
class TransactionData extends Data
{
// <SECTION name="constructor_properties" intent="Define all properties that describe an account transaction.">
// <BELIEF_STATE "The constructor includes key identifiers like `uuid`, `transactionId`, `operationDate`, `number`, and `direction` (DEBIT/CREDIT). Crucially, `amount` and `amountRub` use the nested `AmountData` DTO to ensure monetary values are correctly associated with their currencies. `paymentPurpose` and `rurTransfer` provide additional context, with `rurTransfer` being another nested DTO for specific RUR details.">
public function __construct(
public string $uuid,
public string $transactionId,
public string $operationDate,
public string $number,
public string $direction, // DEBIT, CREDIT
public AmountData $amount, // Nested DTO for amount
public AmountData $amountRub, // Nested DTO for amount in RUB
public string $direction,
public AmountData $amount,
public AmountData $amountRub,
public ?string $documentDate = null,
public ?string $filial = null,
public ?string $operationCode = null,
public ?string $paymentPurpose = null,
public ?RurTransferData $rurTransfer = null, // Nested DTO for RUR specific transfer details
public ?string $priority = null,
public ?string $revaln = null,
public ?string $correspondingAccount = null,
public ?string $debtorCode = null,
public ?string $extendedDebtorCode = null,
public ?RurTransferData $rurTransfer = null,
public ?SwiftTransferData $swiftTransfer = null,
public ?CurTransferData $curTransfer = null,
) {}
// </SECTION>
}