Skip to content

Commit

Permalink
[5.3] MSTR-313, MSTR-314: Mask ACH amounts and fix accuracy errors (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
guillegr123 authored Jul 9, 2024
1 parent c7fc983 commit 3fbae78
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions src/apps/myaccount/submodules/ach/ach.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ define(function(require) {
container = args.container,
data = args.data,
bankData = data.bankData,
parseAmount = function parseAmount(value) {
var splitAmount = _.split(value, '.'),
integer = _.trimStart(splitAmount[0], '0'),
cents = splitAmount.length === 1 ? '00' : _.padEnd(splitAmount[1], 2, '0'),
amount = integer + cents;

return _.parseInt(amount);
},
appendTemplate = function appendTemplate() {
var template = $(self.getTemplate({
name: 'ach-section-verification',
Expand Down Expand Up @@ -304,6 +312,12 @@ define(function(require) {
enableVerifyButton();
};

template
.find('input[type="text"]')
.mask('#0.00', {
reverse: true
});

//set validation to false on load
_.each(self.appFlags.ach.validAchVerificationFormFields, (value, key) => {
self.appFlags.ach.validAchVerificationFormFields[key] = false;
Expand Down Expand Up @@ -356,13 +370,16 @@ define(function(require) {
next(null);
},
function confirmMicroDeposits(next) {
var depositAmount1 = parseAmount(verificationAmounts.deposit_amount_1),
depositAmount2 = parseAmount(verificationAmounts.deposit_amount_2);

self.confirmMicroDeposits({
data: {
verificationId: _.get(bankData, 'verification_id'),
data: {
deposits: [
Math.floor(verificationAmounts.deposit_amount_1 * 100),
Math.floor(verificationAmounts.deposit_amount_2 * 100)
depositAmount1,
depositAmount2
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
<div class="control-group">
<label class="control-label" for="deposit_amount_1">{{i18n.achDirectDebit.achVerification.achVerificationForm.depositAmount.label}}</label>
<div class="controls">
<input type="text" id="deposit_amount_1" name="deposit_amount_1" value="" placeholder="{{i18n.achDirectDebit.achVerification.achVerificationForm.depositAmount.placeholder}}">
<input type="text" id="deposit_amount_1" name="deposit_amount_1" value="" pattern="\d+(\.\d{2})?" placeholder="{{i18n.achDirectDebit.achVerification.achVerificationForm.depositAmount.placeholder}}">
</div>
</div>
<div class="control-group">
<label class="control-label" for="deposit_amount_2">{{i18n.achDirectDebit.achVerification.achVerificationForm.depositAmount.label}}</label>
<div class="controls">
<input type="text" id="deposit_amount_2" name="deposit_amount_2" value="" placeholder="{{i18n.achDirectDebit.achVerification.achVerificationForm.depositAmount.placeholder}}">
<input type="text" id="deposit_amount_2" name="deposit_amount_2" value="" pattern="\d+(\.\d{2})?" placeholder="{{i18n.achDirectDebit.achVerification.achVerificationForm.depositAmount.placeholder}}">
</div>
</div>
</fieldset>
Expand Down

0 comments on commit 3fbae78

Please sign in to comment.