Giter Club home page Giter Club logo

balance's Issues

Auto account creation

What steps will reproduce the problem?

\Illuminatech\Balance\Facades\Balance::increase($user->id, 100);

What is the expected result?

Balance increase

What do you get instead?

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (tracking.backend.balance_transactions, CONSTRAINT balance_transactions_account_id_foreign FOREIGN KEY (account_id) REFERENCES balance_accounts (id) ON DELETE CASCADE ON UPDATE CASC) (SQL: insert into balance_transactions (created_at, amount, account_id) values (2020-08-28 11:45:47, 100, 1))

Additional info

Code increase balance is

public function increase($account, $amount, $data = [])
{
        $accountId = $this->fetchAccountId($account);
        ...
}

And if the variable account is an integer, then there is no automatic creation of an account if it does not exist

protected function fetchAccountId($idOrFilter)
{
        if (is_array($idOrFilter)) {
            $accountId = $this->findAccountId($idOrFilter);
            if ($accountId === null) {
                if ($this->autoCreateAccount) {
                    $accountId = $this->createAccount($idOrFilter);
                } else {
                    throw new InvalidArgumentException('Unable to find account matching filter: ' . print_r($idOrFilter, true));
                }
            }
        } else {
            $accountId = $idOrFilter; // Here
        }

        return $accountId;
}

There are no methods for obtaining an account, where to get an ID from or how to create one.
Perhaps I did not understand something about how to use it correctly, thanks

Q A
This Package Version 1.1.1
Laravel Framework Version 7.26.0

Usage with Database Transaction

What steps will reproduce the problem?

Put the balance increase call in between DB::beginTransaction(); and DB::commit();

What is the expected result?

Transaction is not committed until DB::commit(); is called and is rolled back when DB::rollBack(); is called.

What do you get instead?

The transaction is committed even if an exception is thrown.

Additional info

Q A
This Package Version ^1.2
Laravel Framework Version ^8.40
PHP version 7.4.9
Operating system Windows 10

Multiple balance service.

Hello all,

How to use multiple balance service in 1 application?

For example:

Default is balance_accounts & balance_transactions during installation.
And I need to add another table like stock_accounts & stock_transactions and wanna use the same service.

Is it possible ?

Thank You.

Creating balance_accounts and attempting to increase their balances does nothing

What steps will reproduce the problem?

i created balance accounts through the seeder and I tried to increase their balance without artisan tinker, I get returned a transaction ID but the table remains empty and the balance unchanged. I did it with the Balance facade and it's ::increase method

What is the expected result?

seeing transactions in the database and balance changed

What do you get instead?

balance remains 0, transactions table auto-increment increments but no existing rows remain + balance doesn't get recalculated

Additional info

Q A
This Package Version 1.3.0
Laravel Framework Version 9.7.0
PHP version 8.1
Operating system Mac OS

Balance_accounts balance not updating

What steps will reproduce the problem?

Increase to an account with:

Balance::increase(
    [
        'user_id' => 3,
        'type' => 'virtual-money',
    ],
    100
);

What is the expected result?

The below should equal 100, But it equals 0. I can see the database table shows 0.

echo $currentBalance = \DB::table('balance_accounts')
    ->select(['balance'])
    ->where(['id' => 1])
    ->value('balance');

What do you get instead?

0 balance on accounts.

Additional info

Q A
This Package Version 1.2.2
Laravel Framework Version 8.8.0
PHP version 7.3
Operating system Windows

Managing multiple currency

Can this package support multiple currencies?

Should I use the account type eg 'gbp:virtual-money'? Or add a column to both tables of currency, and modify the core logic to check ->where('currency', $currency) etc?

Additional info

Q A
This Package Version 1.2.2
Laravel Framework Version 8.8.0
PHP version 7.3
Operating system Windows

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.