abwebdevelopers/aba-generator

提供了一种简单的方法来生成ABA文件,该文件由银行用于允许批量交易。

1.1.0 2020-06-05 06:16 UTC

This package is not auto-updated.

Last update: 2024-09-22 01:31:26 UTC


README

提供了一种简单的方法来生成ABA文件,该文件由银行用于允许批量交易。

信用

由于出纳参考字符串填充问题,此分支从https://github.com/anam-hossain/aba 分叉而来。此分支将文本更改为左对齐,而不是右对齐。

特性

  • 简单API
  • 框架无关

要求

  • PHP 5.4+

安装

Aba 通过Composer提供

$ composer require abwebdevelopers/aba-generator

集成

Laravel集成

尽管Aba 与框架无关,但它默认支持Laravel,并附带服务提供者和外观,便于集成。

安装Aba后,打开Laravel包含的config/app.php 文件,并添加以下行。

$providers 数组中添加以下服务提供者。

ABWebDevelopers\AbaGenerator\AbaServiceProvider::class

将此包的外观添加到$aliases 数组中。

'Aba' => ABWebDevelopers\AbaGenerator\Facades\Aba::class,

您现在可以在以下示例中使用此外观代替自己实例化转换器。

用法

use ABWebDevelopers\AbaGenerator\Aba;

$aba = new Aba();

// Descriptive record or file header
// The header information is included at the top of every ABA file
// and is used to describe your bank details.
$aba->addFileDetails([
    'bank_name' => 'CBA', // bank name
    'user_name' => 'Your account name', // Account name
    'bsb' => '062-111', // bsb with hyphen
    'account_number' => '101010101', // account number
    'remitter' => 'Name of remitter', // Remitter
    'user_number' => '301500', // User Number (as allocated by APCA). The Commonwealth bank default is 301500
    'description' => 'Payroll', // description
    'process_date'  => '270616' // DDMMYY - Date to be processed 
]);

// Add a transaction or Detail record
$aba->addTransaction([
    'bsb' => '111-111', // bsb with hyphen
    'account_number' => '999999999',
    'account_name'  => 'Jhon doe',
    'reference' => 'Payroll number',
    'transaction_code'  => '53',
    'amount' => '250.87'
]);

$abaFileContent = $aba->generate(); // Generate ABA string.

$aba->download();
多个交易
$transactions = [
    [
        'bsb' => '111-111', // bsb with hyphen
        'account_number' => '999999999',
        'account_name'  => 'Jhon doe',
        'reference' => 'Payroll number',
        'transaction_code'  => '53',
        'amount' => '250.87'
    ],
    [
        'bsb' => '222-2222', // bsb with hyphen
        'account_number' => '888888888',
        'account_name'  => 'Foo Bar',
        'reference' => 'Rent',
        'transaction_code'  => '50',
        'amount' => '300'
    ]
];

foreach ($transactions as $transaction) {
    $aba->addTransaction($transaction);
}

$aba->generate();

$aba->download("Multiple-transactions");

Laravel示例

use Aba;

// Descriptive record or file header
// The header information is included at the top of every ABA file
// and is used to describe your bank details.
Aba::addFileDetails([]);

Aba::addTransaction([]);

Aba::generate();

Aba::download();

附录

验证
交易代码

参考