Skip to content

Amount

isGreaterThanOrEqualTo

1.0.0

Checks if an amount is greater than or equal to another amount by comparing their cents values. Both amounts must have the same currency.

amount.isGreaterThanOrEqualTo(/amount/);
  • Returns a boolean value indicating if the amount is greater than or equal
  • Requires both amounts to have the same currency
  • Compares cents values for precise comparison
  • Returns true when amounts are equal
  • Throws error for currency mismatches
  • Simple and intuitive API
  • No side effects - read-only operation
  • Comprehensive testing
ArgTypeDefault ValueRequired
amountAmount-Yes

From an Amount instance, use the isGreaterThanOrEqualTo() method to check if it is greater than or equal to another amount.

import { amount } from '@inpulse-ui/utils';
const amount1 = amount(100, 'USD');
const amount2 = amount(50, 'USD');
const result = amount1.isGreaterThanOrEqualTo(amount2);
console.log(result); // true

It returns true when amounts are equal:

const amount1 = amount(75.50, 'EUR');
const amount2 = amount(75.50, 'EUR');
console.log(amount1.isGreaterThanOrEqualTo(amount2)); // true

It returns false when the first amount is smaller:

const amount1 = amount(25, 'GBP');
const amount2 = amount(100, 'GBP');
console.log(amount1.isGreaterThanOrEqualTo(amount2)); // false

It throws an error for different currencies:

const amount1 = amount(100, 'USD');
const amount2 = amount(50, 'EUR'); // Different currency
// This will throw: "Currency mismatch: cannot compare USD with EUR"
const result = amount1.isGreaterThanOrEqualTo(amount2);

Works with negative values:

const amount1 = amount(-10, 'USD');
const amount2 = amount(-50, 'USD');
console.log(amount1.isGreaterThanOrEqualTo(amount2)); // true (-10 >= -50)
const amount3 = amount(-25, 'USD');
const amount4 = amount(-25, 'USD');
console.log(amount3.isGreaterThanOrEqualTo(amount4)); // true (equal)

Useful for conditional logic:

const accountBalance = amount(500, 'USD');
const minimumBalance = amount(500, 'USD');
if (accountBalance.isGreaterThanOrEqualTo(minimumBalance)) {
console.log('Account meets minimum balance requirement');
} else {
console.log('Account below minimum balance');
}
// Output: "Account meets minimum balance requirement"

Validation in business logic:

const customerCredit = amount(1000.00, 'USD');
const orderAmount = amount(1000.00, 'USD');
if (customerCredit.isGreaterThanOrEqualTo(orderAmount)) {
console.log('Order approved - sufficient credit');
// Process order
} else {
console.log('Order declined - insufficient credit');
}
// Output: "Order approved - sufficient credit"

Project

Built with by Jo Santana in Brazil.

© 2026 Inpulse. All rights reserved.