Skip to content

Commit

Permalink
Merge pull request #1086 from CruGlobal/2483-recurring-frequency
Browse files Browse the repository at this point in the history
[EP-2483] Include next draw date when changing frequency
  • Loading branch information
canac authored Jan 17, 2024
2 parents 829d0c4 + c4c73cf commit bc2b37f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/common/models/recurringGift.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,15 @@ export default class RecurringGiftModel {
}

get toObject () {
return this.gift
if (this.gift['updated-start-month'] === '') {
return this.gift
}

// When the start month changes the server needs the recurring day of month even if it didn't change
return {
...this.gift,
'updated-recurring-day-of-month': this.gift['updated-recurring-day-of-month'] || this.parentDonation['recurring-day-of-month']
}
}

clone () {
Expand Down
21 changes: 21 additions & 0 deletions src/common/models/recurringGift.model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,27 @@ describe('recurringGift model', () => {
it('should return the object to send to the api', () => {
expect(giftModel.toObject).toEqual(giftModel.gift)
})

it('should include the recurring day of month when the month changes', () => {
giftModel.startMonth = '6'
expect(giftModel.toObject).toEqual({
...giftModel.gift,
'updated-recurring-day-of-month': '15',
'updated-start-month': '06',
'updated-start-year': '2015',
})
})

it('should not override the modified recurring day of month when the month changes', () => {
giftModel.transactionDay = '20'
giftModel.startMonth = '6'
expect(giftModel.toObject).toEqual({
...giftModel.gift,
'updated-recurring-day-of-month': '20',
'updated-start-month': '06',
'updated-start-year': '2015',
})
})
})

describe('clone', () => {
Expand Down

0 comments on commit bc2b37f

Please sign in to comment.