Money

Easy money management within October

Back to Money Support

VektarDesign
VektarDesign

Whenever I save with an amount say £120.00, when I save & close and go back I end up with the amount £12,000.00, if I repeat this process I end up with £1,200,000.00 and so on. This happens every time I save & close.

I have the following in my table:

$table->integer('currency_id');
$table->decimal('amount', 15,2);

fields.yaml

price:
    label: 'vektar.crm::lang.job.amount'
    placeholder: '-- TOTAL AMOUNT --'
    type: money
    mode: amountcurrency
    span: auto
    tab: 'Job Information'

Model:

 public $implement = [
    'Initbiz.Money.Behaviors.MoneyFields'
 ];

public $moneyFields = [
    'price' => [
        'amountColumn' => 'amount',
        'currencyIdColumn' => 'currency_id'
    ]
];

Any ideas why this might be happening?

Last updated

inIT
inIT

Thanks for using the plugin.

The issue was probably fixed in the Github version but not yet published to Marketplace. I have published a new version (1.0.8) to Marketplace. Update and check if the problem still occurs. If it does, give me a note here.

Best regards,

Tomasz Strojny

inIT
inIT

I have also noticed you have a bug in your migrations. Do not use decimal types to store amount. Use integer or other monetary type as stated in the plugin's docs.

VektarDesign
VektarDesign

That's great stuff, it did the trick.

Just one problem I have now, if I use float or integer, the value is stored without the decimal place for example, 20.00 in the model would be 2000 in the database.

Generally, this wouldn't matter but I'm relying on the value in the database to display amounts paid and unpaid so they report that it is 2000 rather than 20.00.

If you have any suggestions, that would be terrific.

Great plugin thus dar so thanks.

inIT
inIT

Well, it's not a bug, it's a feature :)

It's one of the biggest advantages of this plugin and the main feature of why the plugin was created. It was mentioned in the documentation but take a look at this link: https://spin.atomicobject.com/2014/08/14/currency-rounding-errors/

If you want to display amounts, you can use the money column type in the backend lists and money twig filter in the frontend.

Best regards,

Tomasz Strojny

1-5 of 5