Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAC_RECOUNT_RECEIPT #671

Merged
merged 6 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions front-end/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@popperjs/core": "^2.10.2",
"bootstrap": "5.1.3",
"class-transformer": "^0.5.1",
"fecfile-validate": "https://github.com/fecgov/fecfile-validate#e040a9cac47623e91301a07477da2f49e22d9c42",
"fecfile-validate": "https://github.com/fecgov/fecfile-validate#a6cad3fb77681c50fd0d33fbb1a91341a559ac6e",
"intl-tel-input": "^17.0.18",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export abstract class TransactionTypeBaseComponent implements OnInit, OnDestroy
contactId$: Subject<string> = new BehaviorSubject<string>('');
formSubmitted = false;
memoItemHelpText = 'The dollar amount in a memo item is not incorporated into the total figure for the schedule.';
memoCodeConstant?: boolean; // If validation schema defines memo_code to be a constant value, set this to the const true/false value. Otherwise, undefined.

form: FormGroup = this.fb.group({});

Expand Down Expand Up @@ -66,6 +67,10 @@ export abstract class TransactionTypeBaseComponent implements OnInit, OnDestroy
validateService.formValidatorSchema = transactionType?.schema;
validateService.formValidatorForm = form;

// Look at validation schema to determine if the memo_code has a constant value.
const memoCodeSchema = this.transactionType?.schema.properties['memo_code'];
this.memoCodeConstant = memoCodeSchema?.const as boolean | undefined;

// Intialize form values
if (this.isExisting(transactionType?.transaction)) {
const txn = { ...transactionType?.transaction } as SchATransaction;
Expand Down Expand Up @@ -323,6 +328,10 @@ export abstract class TransactionTypeBaseComponent implements OnInit, OnDestroy
return form.get(`contributor_${field}`) || form.get(`contributor_organization_${field}`);
}

isMemoCodeReadOnly(): boolean {
return this.memoCodeConstant !== undefined;
}

doSave(navigateTo: NavigationDestination, payload: Transaction, transactionTypeToAdd?: ScheduleATransactionTypes) {
if (payload.transaction_type_identifier) {
if (payload.id) {
Expand Down Expand Up @@ -393,7 +402,7 @@ export abstract class TransactionTypeBaseComponent implements OnInit, OnDestroy
form.patchValue({
entity_type: this.contactTypeOptions[0]?.code,
contribution_aggregate: '0',
memo_code: (transactionType?.transaction as SchATransaction)?.memo_code,
memo_code: this.memoCodeConstant,
contribution_purpose_descrip: transactionType?.contributionPurposeDescripReadonly(),
});
}
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/app/shared/models/scha-transaction.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export enum ScheduleATransactionTypes {
BUSINESS_LABOR_ORG_RECEIPT_NON_CONTRIBUTION_ACCOUNT = 'BUS_LAB_NON_CONT_ACC',
INDIVIDUAL_RECOUNT_RECEIPT = 'IND_RECNT_REC',
PARTY_RECOUNT_RECEIPT = 'PARTY_RECNT_REC',
PAC_RECOUNT_RECEIPT = 'PAC_RECNT_REC',
PAC_RECOUNT_RECEIPT = 'PAC_RECOUNT_RECEIPT',
TRIBAL_RECOUNT_RECEIPT = 'TRIB_RECNT_REC',
INDIVIDUAL_NATIONAL_PARTY_RECOUNT_ACCOUNT = 'IND_NP_RECNT_ACC',
PARTY_NATIONAL_PARTY_RECOUNT_ACCOUNT = 'PARTY_NP_RECNT_ACC',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { SchATransaction, ScheduleATransactionTypes } from '../scha-transaction.model';
import { PAC_RECOUNT_RECEIPT } from './PAC_RECOUNT_RECEIPT.model';

describe('PAC_RECOUNT_RECEIPT', () => {
let transactionType: PAC_RECOUNT_RECEIPT;

beforeEach(() => {
transactionType = new PAC_RECOUNT_RECEIPT();
});

it('should create an instance', () => {
expect(transactionType).toBeTruthy();
expect(transactionType.scheduleId).toBe('A');
expect(transactionType.componentGroupId).toBe('F');
});

it('#factory() should return a SchATransaction', () => {
const txn: SchATransaction = transactionType.getNewTransaction();
expect(txn.form_type).toBe('SA17');
expect(txn.transaction_type_identifier).toBe(ScheduleATransactionTypes.PAC_RECOUNT_RECEIPT);
});

it('#contributionPurposeDescripReadonly() should return constant', () => {
const descrip = transactionType.contributionPurposeDescripReadonly();
expect(descrip).toBe('Recount Account');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
SchATransaction,
ScheduleATransactionTypes,
ScheduleATransactionTypeLabels,
AggregationGroups,
} from '../scha-transaction.model';
import { LabelUtils } from 'app/shared/utils/label.utils';
import { schema } from 'fecfile-validate/fecfile_validate_js/dist/PAC_RECOUNT_RECEIPT';
import { Transaction } from '../../interfaces/transaction.interface';
import {
CANCEL_CONTROL,
SAVE_ANOTHER_CONTROL,
SAVE_LIST_CONTROL,
TransactionNavigationControls,
} from '../transaction-navigation-controls.model';
import { TransactionType } from 'app/shared/interfaces/transaction-type.interface';

export class PAC_RECOUNT_RECEIPT implements TransactionType {
scheduleId = 'A';
componentGroupId = 'F';
isDependentChild = false;
title = LabelUtils.get(ScheduleATransactionTypeLabels, ScheduleATransactionTypes.PAC_RECOUNT_RECEIPT);
schema = schema;
transaction?: Transaction;
contact = undefined;
parent?: SchATransaction;
navigationControls?: TransactionNavigationControls = new TransactionNavigationControls(
[],
[CANCEL_CONTROL],
[SAVE_LIST_CONTROL, SAVE_ANOTHER_CONTROL]
);

contributionPurposeDescripReadonly(): string {
return 'Recount Account';
}

getNewTransaction() {
return SchATransaction.fromJSON({
form_type: 'SA17',
transaction_type_identifier: ScheduleATransactionTypes.PAC_RECOUNT_RECEIPT,
back_reference_sched_name: 'SA17',
mjtravers marked this conversation as resolved.
Show resolved Hide resolved
aggregation_group: AggregationGroups.RECOUNT_ACCOUNT,
});
}
}
2 changes: 2 additions & 0 deletions front-end/src/app/shared/utils/transaction-type.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { JOINT_FUNDRAISING_TRANSFER } from '../models/transaction-types/JOINT_FU
import { OFFSET_TO_OPERATING_EXPENDITURES } from '../models/transaction-types/OFFSET_TO_OPERATING_EXPENDITURES.model';
import { OTHER_RECEIPT } from '../models/transaction-types/OTHER_RECEIPT.model';
import { PAC_JF_TRANSFER_MEMO } from '../models/transaction-types/PAC_JF_TRANSFER_MEMO.model';
import { PAC_RECOUNT_RECEIPT } from '../models/transaction-types/PAC_RECOUNT_RECEIPT.model';
import { PAC_RECEIPT } from '../models/transaction-types/PAC_RECEIPT.model';
import { PARTY_JF_TRANSFER_MEMO } from '../models/transaction-types/PARTY_JF_TRANSFER_MEMO.model';
import { PARTY_RECEIPT } from '../models/transaction-types/PARTY_RECEIPT.model';
Expand All @@ -25,6 +26,7 @@ const transactionTypeClasses: any = { // eslint-disable-line @typescript-eslint/
OTHER_RECEIPT,
PAC_JF_TRANSFER_MEMO,
PAC_RECEIPT,
PAC_RECOUNT_RECEIPT,
PARTY_JF_TRANSFER_MEMO,
PARTY_RECEIPT,
TRIBAL_RECEIPT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ <h3>Receipt Information</h3>
</div>
<div class="grid">
<div class="col-12">
<div class="field" [ngClass]="{ readonly: readOnlyMemo }">
<div class="field" [ngClass]="{ readonly: isMemoCodeReadOnly() }">
<p-checkbox
[binary]="true"
inputId="memo_code"
Expand All @@ -203,7 +203,7 @@ <h3>Receipt Information</h3>
ariaLabel="have memo item"
[trueValue]="true"
[falseValue]="false"
[readonly]="readOnlyMemo"
[readonly]="isMemoCodeReadOnly()"
></p-checkbox>
<div class="memo-checkbox-note">
{{ memoItemHelpText }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class TransactionGroupAComponent extends TransactionTypeBaseComponent imp
'memo_code',
'memo_text_description',
];
readOnlyMemo = false;
override contactTypeOptions: PrimeOptions = LabelUtils.getPrimeOptions(ContactTypeLabels).filter((option) =>
[ContactTypes.INDIVIDUAL].includes(option.code as ContactTypes)
);
Expand All @@ -49,22 +48,17 @@ export class TransactionGroupAComponent extends TransactionTypeBaseComponent imp
protected override confirmationService: ConfirmationService,
protected override fb: FormBuilder,
protected override router: Router,
protected override fecDatePipe: FecDatePipe,
protected override fecDatePipe: FecDatePipe
) {
super(messageService, transactionService, contactService, validateService, confirmationService, fb, router, fecDatePipe);
}

override ngOnInit(): void {
super.ngOnInit();
if (this.memoCodeMustBeTrue()) {
this.readOnlyMemo = true;
this.form.get('memo_code')?.setValue(true);
}
}

protected memoCodeMustBeTrue(): boolean {
// Look at validation schema to determine if the memo_code must be true in all cases.
const memoCodeSchema = this.transactionType?.schema.properties['memo_code'];
return !!memoCodeSchema?.const;
super(
messageService,
transactionService,
contactService,
validateService,
confirmationService,
fb,
router,
fecDatePipe
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h3>Receipt Information</h3>
</div>
<div class="grid">
<div class="col-12">
<div class="field">
<div class="field" [ngClass]="{ readonly: isMemoCodeReadOnly() }">
<p-checkbox
[binary]="true"
inputId="memo_code"
Expand All @@ -205,6 +205,7 @@ <h3>Receipt Information</h3>
ariaLabel="have memo item"
[trueValue]="true"
[falseValue]="false"
[readonly]="isMemoCodeReadOnly()"
></p-checkbox>
<div class="memo-checkbox-note">
{{ memoItemHelpText }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ <h3>Receipt Information</h3>
</div>
<div class="grid">
<div class="col-12">
<div class="field">
<div class="field" [ngClass]="{ readonly: isMemoCodeReadOnly() }">
<p-checkbox
[binary]="true"
inputId="memo_code"
Expand All @@ -235,6 +235,7 @@ <h3>Receipt Information</h3>
ariaLabel="have memo item"
[trueValue]="true"
[falseValue]="false"
[readonly]="isMemoCodeReadOnly()"
></p-checkbox>
<div class="memo-checkbox-note">
{{ memoItemHelpText }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h3>Receipt Information</h3>
</div>
<div class="grid">
<div class="col-12">
<div class="field" [ngClass]="{ readonly: readOnlyMemo }">
<div class="field" [ngClass]="{ readonly: isMemoCodeReadOnly() }">
<p-checkbox
[binary]="true"
inputId="memo_code"
Expand All @@ -137,7 +137,7 @@ <h3>Receipt Information</h3>
ariaLabel="have memo item"
[trueValue]="true"
[falseValue]="false"
[readonly]="readOnlyMemo"
[readonly]="isMemoCodeReadOnly()"
></p-checkbox>
<div class="memo-checkbox-note">
{{ memoItemHelpText }}
Expand Down
Loading