saeid-khaleghi/police-reporter

A package for securely reporting business transactions to the New Zealand Police for compliance and transparency purposes.

V1.3.0 2024-01-08 19:12 UTC

This package is auto-updated.

Last update: 2024-05-08 20:16:12 UTC


README

This package will help you generate an XML file for New Zealand Police reports.

Installation

You can install this package via Composer:

composer require saeid-khaleghi/police-reporter

Usage

use SaeidKhaleghi\PoliceReporter\XMLGenerator;

$transactions = Transaction::all();

$reporter = XMLGenerator::create($transactions)->writeToFile($path);

You can add your models directly by implementing the \SaeidKhaleghi\PoliceReporter\Contracts\Reportable interface.

use SaeidKhaleghi\PoliceReporter\Contracts\Reportable;

class Transaction extends Model implements Reportable
{
    public function toReportTransaction(): Url | string | array
    {
        return (new ReportTransaction($this))->transaction();
    }
}

Your PoliceReportTransactionMaker should be like this:

use SaeidKhaleghi\PoliceReporter\Tags\Person;
use SaeidKhaleghi\PoliceReporter\Tags\Signatory;
use SaeidKhaleghi\PoliceReporter\Tags\ToAccount;
use SaeidKhaleghi\PoliceReporter\Tags\FromAccount;
use SaeidKhaleghi\PoliceReporter\Tags\TransactionTo;
use SaeidKhaleghi\PoliceReporter\Tags\TransactionFrom;
use SaeidKhaleghi\PoliceReporter\Tags\Transaction as ReportTransaction;

class PoliceReportTransactionMaker
{
    private Transaction $transaction;

    public function __construct(Transaction $transaction)
    {
        $this->transaction = $transaction;
    }

    public function transactionFrom()
    {
        return new TransactionFrom('From fund code', 'From country');
    }

    public function fromAccount()
    {
        return new FromAccount(env('APP_FORMAL_NAME'), env('APP_INSTITUTION_CODE'), 'Branch', 'Account', 'Account_name');
    }

    public function signatory()
    {
        $identification = new PersonIdentification('Type', 'id_number', 'country', 'Expiry date');
        $user = new Person('Gender', 'First name', 'Last name', 'Birthdate', 'Passport number', 'Passport Country (Two-Letter Country Code)', $identification);

        return new Signatory($user);
    }

    public function transactionTo()
    {
        return new TransactionTo('To fund code', 'To country');
    }

    public function toAccount()
    {
        return ToAccount::create('Institution name', 'Account', 'Account_name', 'swift');
    }

    public function transaction()
    {
        return ReportTransaction::create($this->transfer->reference, $this->transfer->updated_at, $this->transfer->origin_amount)
            ->addFromMyClient($this->transactionFrom()->addFromAccount($this->fromAccount()->addSignatory($this->signatory())))
            ->addTransactionTo($this->transactionTo()->addToAccount($this->toAccount()));
    }
}

The generated XML will look similar to this:

<reportdata>
    <transactions>
        <transaction>
            <transactionnumber>TW01182606-101023</transactionnumber>
            <transaction_location>web</transaction_location>
            <date_transaction>2023-10-11T11:03:51</date_transaction>
            <transmode_code>BA</transmode_code>
            <amount_local>129.06</amount_local>
            <t_from_my_client>
                <from_funds_code>N</from_funds_code>
                <from_account>
                    <institution_name>Your Company</institution_name>
                    <institution_code>12345</institution_code>
                    <branch>web</branch>
                    <account>ABC123</account>
                    <account_name>Saeid Khaleghi</account_name>
                    <signatory>
                        <t_person>
                            <gender>M</gender>
                            <first_name>Saeid</first_name>
                            <last_name>Khaleghi</last_name>
                            <birthdate>1980-06-24T00:00:00</birthdate>
                            <id_number>ZYXWV123</id_number>
                            <identification>
                                <type>A</type>
                                <number>ZYXWV123</number>
                                <issue_country>NZ</issue_country>
                            </identification>
                        </t_person>
                    </signatory>
                </from_account>
                <from_country>NZ</from_country>
            </t_from_my_client>
            <t_to>
                <to_funds_code>N</to_funds_code>
                <to_account>
                    <institution_name>BNZ</institution_name>
                    <swift>BSIRIRTH</swift>
                    <account>ABCDEFGHIJK1234567890</account>
                    <account_name>RECIPIENT NAME</account_name>
                </to_account>
                <to_country>US</to_country>
            </t_to>
        </transaction>
        <transaction>
            ...
        </transaction>
    </transactions>
</reportdata>

Credits

License

The MIT License (MIT). Please see License File for more information.