File tree 1 file changed +6
-4
lines changed 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -330,20 +330,22 @@ pub mod update_campaign {
330
330
. checked_sub ( & current_budget)
331
331
. and_then ( |delta_budget| old_remaining. checked_add ( & delta_budget) )
332
332
. ok_or ( Error :: Calculation ) ?;
333
+ // new remaining > old remaining
333
334
let increase_by = new_remaining
334
335
. checked_sub ( & old_remaining)
335
336
. ok_or ( Error :: Calculation ) ?;
336
337
337
338
DeltaBudget :: Increase ( increase_by)
338
339
}
339
340
DeltaBudget :: Decrease ( ( ) ) => {
340
- // delta budget = New budget - Old budget ( the difference between the new and old when New > Old)
341
+ // delta budget = Old budget - New budget ( the difference between the new and old when New < Old)
341
342
let new_remaining = & current_budget
342
343
. checked_sub ( & new_budget)
343
- . and_then ( |delta_budget| old_remaining. checked_add ( & delta_budget) )
344
+ . and_then ( |delta_budget| old_remaining. checked_sub ( & delta_budget) )
344
345
. ok_or ( Error :: Calculation ) ?;
345
- let decrease_by = new_remaining
346
- . checked_sub ( & old_remaining)
346
+ // old remaining > new remaining
347
+ let decrease_by = old_remaining
348
+ . checked_sub ( & new_remaining)
347
349
. ok_or ( Error :: Calculation ) ?;
348
350
349
351
DeltaBudget :: Decrease ( decrease_by)
You can’t perform that action at this time.
0 commit comments