Filter cancellation records for only cancellable records

Previously, I would cancel all the records associated with HistoryEntry that's
available for cancellation. This could cause unexpected behavior if we
cancelled a historyEntry which itself had cancelled records (in effect we would
negate the negation unintentionally). This is easily remedied by only
cancelling records which want to be cancelled.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167204383
This commit is contained in:
larryruili 2017-08-31 15:56:11 -07:00 committed by jianglai
parent d8c1501213
commit 3809ff59a5
5 changed files with 29 additions and 10 deletions

View file

@ -960,8 +960,11 @@ public class DomainFlowUtils {
ImmutableSet.Builder<DomainTransactionRecord> recordsBuilder = new ImmutableSet.Builder<>();
if (entryToCancel.isPresent()) {
for (DomainTransactionRecord record : entryToCancel.get().getDomainTransactionRecords()) {
int cancelledAmount = -1 * record.getReportAmount();
recordsBuilder.add(record.asBuilder().setReportAmount(cancelledAmount).build());
// Only cancel fields which are cancelable
if (cancelableFields.contains(record.getReportField())) {
int cancelledAmount = -1 * record.getReportAmount();
recordsBuilder.add(record.asBuilder().setReportAmount(cancelledAmount).build());
}
}
}
return recordsBuilder.build();