Skip to content

Commit

Permalink
Merge pull request #1148 from flexion/1140-filing-fee-fix
Browse files Browse the repository at this point in the history
1104: fix filing fee paid showing up in docket record multiple times
  • Loading branch information
codyseibert authored Mar 19, 2019
2 parents cd25dde + bfe4cfb commit 1357fb3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
27 changes: 23 additions & 4 deletions shared/src/business/entities/Case.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,22 @@ Case.prototype.markAsPaidByPayGov = function(payGovDate) {
};

let found;

this.docketRecord.forEach(docketRecord => {
found =
found ||
let docketRecordIndex;
let datesMatch;

this.docketRecord.forEach((docketRecord, index) => {
found = found || docketRecord.description === newDocketItem.description;
docketRecordIndex = found ? index : docketRecordIndex;
datesMatch =
datesMatch ||
(docketRecord.description === newDocketItem.description &&
docketRecord.filingDate === newDocketItem.filingDate);
});

if (payGovDate && !found) {
this.addDocketRecord(new DocketRecord(newDocketItem));
} else if (payGovDate && found && !datesMatch) {
this.updateDocketRecord(docketRecordIndex, new DocketRecord(newDocketItem));
}
return this;
};
Expand All @@ -552,6 +558,19 @@ Case.prototype.addDocketRecord = function(docketRecordEntity) {
return this;
};

/**
*
* @param docketRecordIndex
* @param docketRecordEntity
*/
Case.prototype.updateDocketRecord = function(
docketRecordIndex,
docketRecordEntity,
) {
this.docketRecord[docketRecordIndex] = docketRecordEntity;
return this;
};

/**
*
* @returns {*[]}
Expand Down
9 changes: 4 additions & 5 deletions shared/src/business/entities/Case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,11 @@ describe('Case entity', () => {

it('should only sets docket record once per time paid', () => {
const caseRecord = new Case(MOCK_CASE);
const payGovDate = new Date().toISOString();
caseRecord.markAsPaidByPayGov(payGovDate);
caseRecord.markAsPaidByPayGov(new Date().toISOString());
const docketLength = caseRecord.docketRecord.length;
caseRecord.markAsPaidByPayGov(payGovDate);
caseRecord.markAsPaidByPayGov(payGovDate);
caseRecord.markAsPaidByPayGov(payGovDate);
caseRecord.markAsPaidByPayGov(new Date().toISOString());
caseRecord.markAsPaidByPayGov(new Date().toISOString());
caseRecord.markAsPaidByPayGov(new Date().toISOString());
expect(docketLength).toEqual(caseRecord.docketRecord.length);
});
});
Expand Down

0 comments on commit 1357fb3

Please sign in to comment.