1
0
Fork 0
mirror of https://github.com/xHyroM/lighteco.git synced 2024-11-21 22:41:06 +01:00

fix(pay): substract original amount from sender

This commit is contained in:
Jozef Steinhübl 2023-08-26 22:55:47 +02:00
parent 0cd8e50f9c
commit 63e911a12c

View file

@ -122,14 +122,14 @@ public abstract class AbstractCommandManager implements CommandManager {
BigDecimal tax = currency.getProxy().calculateTax(user.getProxy(), amount);
// subtract tax from amount
amount = amount.subtract(tax);
BigDecimal taxedAmount = amount.subtract(tax);
target.setBalance(currency, target.getBalance(currency).add(amount));
target.setBalance(currency, target.getBalance(currency).add(taxedAmount));
user.setBalance(currency, user.getBalance(currency).subtract(amount));
// send message and also include tax rate (percentage) with tax amount
// send message that will include original amount, taxed amount, tax rate - percentage amount and tax amount
sender.sendMessage(
miniMessage.deserialize("<yellow>Paid <gold>" + amount.toPlainString() + " <yellow>" + currency.getIdentifier() + " to " + target.getUsername() + " with a tax rate of <gold>" + tax + "% <yellow>(<gold>" + tax.toPlainString() + " <yellow>" + currency.getIdentifier() + ")")
miniMessage.deserialize("<yellow>Paid <gold>" + amount.toPlainString() + " <yellow>" + currency.getIdentifier() + " to " + target.getUsername() + " <yellow>(<gold>" + taxedAmount.toPlainString() + " <yellow>after tax)")
);
CompletableFuture.allOf(