Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 00c93df

Browse files
authored
Prince/ Incorrect error message payment agent transfer (#6627)
* Chore: added validation condition under numbers * Chore: Lint Fix * Chore: Applied form validation on payment agent transfer form
1 parent 7ce5a0d commit 00c93df

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/javascript/app/common/form_validation.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,21 @@ const Validation = (() => {
231231
message = localize('Should be less than [_1]', addComma(options.max, options.format_money ? getDecimalPlaces(Client.get('currency')) : undefined));
232232
}
233233

234+
// Priority Validation
235+
if ('balance' in options && isLessThanBalance(value, options)) {
236+
is_ok = false;
237+
message = localize('Insufficient balance.');
238+
}
239+
234240
ValidatorsMap.get().number.message = message;
235241
return is_ok;
236242
};
237243

238244
const isMoreThanMax = (value, options) =>
239245
(options.type === 'float' ? +value > +options.max : compareBigUnsignedInt(value, options.max) === 1);
240246

247+
const isLessThanBalance = (value,options) => options.balance < value;
248+
241249
const validTaxID = (value, options, field) => {
242250
// input is valid in API regex but may not be valid for country regex
243251
if (/^[a-zA-Z0-9]*[\w-]*$/.test(value)) {

src/javascript/app/pages/cashier/payment_agent_withdraw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const PaymentAgentWithdraw = (() => {
108108
$form.find('.wrapper-row-agent').find('label').append($('<span />', { text: '*', class: 'required_field_asterisk' }));
109109
$form.find('label[for="txtAmount"]').text(`${localize('Amount in')} ${Currency.getCurrencyDisplayCode(currency)}`);
110110
FormManager.init(form_id, [
111-
{ selector: field_ids.txt_amount, validations: ['req', ['number', { type: 'float', decimals: Currency.getDecimalPlaces(currency), min, max }], ['custom', { func: () => +Client.get('balance') >= +$txt_amount.val(), message: localize('Insufficient balance.') }]], request_field: 'amount' },
111+
{ selector: field_ids.txt_amount, validations: ['req', ['number', { type: 'float', decimals: Currency.getDecimalPlaces(currency), min, max, balance: Client.get('balance') }]], request_field: 'amount' },
112112
{ selector: field_ids.txt_payment_ref, validations: [['length', { min: 0, max: 30 }], ['regular', { regex: /^[0-9A-Za-z .,'-]{0,30}$/, message: localize('Only letters, numbers, space, hyphen, period, comma, and apostrophe are allowed.') }]], request_field: 'description', value: () => $txt_payment_ref.val() ? payment_ref_prefix + $txt_payment_ref.val() : '' },
113113

114114
{ request_field: 'currency', value: currency },

src/javascript/app/pages/user/account/payment_agent_transfer/payment_agent_transfer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const PaymentAgentTransfer = (() => {
6161

6262
FormManager.init(form_id, [
6363
{ selector: '#client_id', validations: ['req', ['regular', { regex: /^\w+\d+$/, message: localize('Please enter a valid Login ID.') }]], request_field: 'transfer_to' },
64-
{ selector: '#amount', validations: ['req', ['number', { type: 'float', decimals: getDecimalPlaces(currency), min: pa ? pa.min_withdrawal : 10, max: max_withdrawal(balance, pa, 2000) }], ['custom', { func: () => +Client.get('balance') >= +$('#amount').val(), message: localize('Insufficient balance.') }]] },
64+
{ selector: '#amount', validations: ['req', ['number', { type: 'float', decimals: getDecimalPlaces(currency), min: pa ? pa.min_withdrawal : 10, max: max_withdrawal(balance, pa, 2000),balance: Client.get('balance') }]] },
6565
{ selector: '#description', validations: ['general'] },
6666

6767
{ request_field: 'dry_run', value: 1 },

0 commit comments

Comments
 (0)