Download the PHP package abather/mini-accounting without Composer

On this page you can find all versions of the php package abather/mini-accounting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mini-accounting

Create accounts for any model to withdraw and deposit to it

Latest Version on Packagist Total Downloads

Adding an Account to Your Models and Tracking Transactions

To seamlessly integrate account functionality into your Laravel models and keep track of transactions, follow the steps outlined below.

Installation

Begin by installing the package via Composer:

Next, publish and run the migrations:

You can also publish the configuration file:

The contents of the published configuration file (config/mini-accounting.php) will look like this:

Usage

This package links two entities: Accountable (a model with an account) and Referencable (a document triggering account deposits or withdrawals).

Accountable

To make a model accountable, use the HasAccountMovement trait:

Now you can deposit or withdraw any amount from it by referring to any reference model:

You can also provide notes or extra data in JSON format to any transaction:

To get the model's current balance:

You can also retrieve the model's balance at the end of any month:

you can also pass the year for this function if you went any year other than this year balanceAtEndOfMonth(6, 1990)

also you can get the balance for any given year:

as end of month balance you can specify the year balanceAtEndOfYear(1990)

Referencable

Make any model referencable by using the Referencable trait and implementing the Referencable interface:

Define the defaultTransactions(): array method. This method will be described later. Similar to the accountable model, you can deposit and withdraw from the referencable model, affecting different accounts simultaneously. For example, when a user buys from a market, the bill will deposit the amount into the market's account and withdraw the same amount from the user's account:

Assuming you have another transaction caused by the bill, such as a commission, your code would be:

To simplify, define the default transactions for each referencable model using the defaultTransactions method:

For each object (either Deposit or Withdraw), set the affected account and the calculation method used to determine the transaction amount.

Account

Refer to the desired account in three ways: direct relationship from the current model, using a foreign key from the current model, or giving it any ID for reference:

In this example, specify the model in the make method; during calculation, the account will be the market linked with the current entity ($bill->market). Other settings include:

In this way, you do not need to provide any other functions.

Calculation

For calculation, use the following objects:

For each object, provide make($resource, $attribute). In our previous example, make($this, "amount") means the calculation will be on $bill->amount. Except for Equal, you must also define factor, which is the other side of each equation. Factor can be either dynamic or a static value:

After defining defaultTransactions(), use it by calling executeDefaultTransactions(). You are free to define as many transactions methods as needed. Keep in mind that the name of each method should end with Transactions, and you can run these transactions by calling the function with "execute" at the beginning of the method name ( e.g., cancelTransactions() runs transactions using executeCancelTransactions()).

Note: If you ever use __call($method, $parameters) in

your Accountable or Referencable models, please add the following lines:

This documentation pertains to a Laravel package designed to enhance models' capabilities by linking them to their accounts. Additionally, it establishes links with other models to serve as reference documents, such as bills or refunds.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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


All versions of mini-accounting with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0
laravel/framework Version ^10.10
spatie/laravel-package-tools Version ^1.14.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package abather/mini-accounting contains the following files

Loading the files please wait ....