kubinyete/getnet-edi

该软件包的最新版本(1.0.5)没有提供许可信息。

一个简单而实用的Getnet(巴西支付机构)EDI解析器

1.0.5 2024-05-03 13:26 UTC

This package is auto-updated.

Last update: 2024-09-03 14:09:21 UTC


README

pt-BR:一个用于加载Getnet(https://getnet.com.br/)发行商的EDI文件的简单直接库

en-US:一个用于从Getnet(https://getnet.com.br/)加载EDI文件的直接库

NOTA:本指南主要使用英语,如有需要,将未来添加pt-BR版本的版本。

警告

此软件包仍在开发中,计划添加更好的文档阅读支持,通过提供索引和类绑定以直接访问这些条目,目前我们只提供了基本的解析器和文档包装器,提供了按行逐行顺序读取的必要手段。

安装

让我们先通过运行以下命令来要求该软件包

composer require kubinyete/getnet-edi

用法

基本的逐行解析

提供了一个用于打开EDI文本文件的文档类

// Opening a new document (version 10.1)
$document = Kubinyete\Edi\Getnet\Document\Document::open('./sample/getnetextr_20240418_0000000_c101.txt');

// Sequential reading
while ($row = $document->next()) {
    // Current line number that has been read
    $lineNumber = $document->currentLineNumber();
    // Current line contents that has been read
    $lineContent = $document->currentLine();

    // What type/class we got after parsing it.
    $parsedType = get_class($row);

    echo "Current line {$lineNumber}: '{$lineContent}'" . PHP_EOL;
    echo "Parsed content ($parsedType): " . json_encode($row, JSON_PRETTY_PRINT) . PHP_EOL;
    // @NOTE: This is only a sample code for visualizing each entry that has been parsed
}

上面的代码将输出

Current line 1: '01804202407321018042024CEADM1000000000        00000000000000GETNET S.A.         000000001GSSANT. V.10.1 400 BYTES                                                                                                                                                                                                                                                                                               '
Parsed content (Kubinyete\Edi\Getnet\Registry\Header): {
    "registryType": 0,
    "fileCreationDate": {
        "date": "2024-04-18 07:32:10.000000",
        "timezone_type": 3,
        "timezone": "America\/Sao_Paulo"
    },
    "movementReferenceDate": {
        "date": "2024-04-18 00:00:00.000000",
        "timezone_type": 3,
        "timezone": "America\/Sao_Paulo"
    },
    "fileVersion": "CEADM100",
    "establishmentCode": "0000000",
    "acquirerDocument": "00000000000000",
    "acquirerName": "GETNET S.A.",
    "sequenceNumber": 1,
    "acquirerCode": "GS",
    "layoutVersion": "SANT. V.10.1 400 BYTES",
    "_padding": ""
}

类型参考

每个注册类型及其相关基线版本的快速类型参考。

我们建议只期待相关的注册接口,而不是其定义的类型,这将防止任何破坏性变更立即影响您的应用程序(例如:名称更改、值类型更改等)

如果有任何不向后兼容的更改,将为该功能使用新的类型或相关接口。

注册类型