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 all 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 @@ -323,6 +323,19 @@ export abstract class TransactionTypeBaseComponent implements OnInit, OnDestroy
return form.get(`contributor_${field}`) || form.get(`contributor_organization_${field}`);
}

getMemoCodeConstant(transactionType?: TransactionType): boolean | undefined {
/** Look at validation schema to determine if the memo_code has a constant value.
* If there is a constant value, return it, otherwise undefined
*/
const memoCodeSchema = transactionType?.schema.properties['memo_code'];
return memoCodeSchema?.const as boolean | undefined;
}

public isMemoCodeReadOnly(transactionType?: TransactionType): boolean {
// Memo Code is read-only if there is a constant value in the schema. Otherwise, it's mutable
return this.getMemoCodeConstant(transactionType) !== undefined;
}

doSave(navigateTo: NavigationDestination, payload: Transaction, transactionTypeToAdd?: ScheduleATransactionTypes) {
if (payload.transaction_type_identifier) {
if (payload.id) {
Expand Down Expand Up @@ -393,7 +406,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.getMemoCodeConstant(transactionType),
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
Expand Up @@ -35,7 +35,6 @@ export class PAC_RECEIPT implements TransactionType {
return SchATransaction.fromJSON({
form_type: 'SA11C',
transaction_type_identifier: ScheduleATransactionTypes.PAC_RECEIPT,
back_reference_sched_name: 'SA11C',
aggregation_group: AggregationGroups.GENERAL,
});
}
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,44 @@
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,
aggregation_group: AggregationGroups.RECOUNT_ACCOUNT,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class PARTY_RECEIPT implements TransactionType {
return SchATransaction.fromJSON({
form_type: 'SA11B',
transaction_type_identifier: ScheduleATransactionTypes.PARTY_RECEIPT,
back_reference_sched_name: 'SA11B',
aggregation_group: AggregationGroups.GENERAL,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class TRANSFER implements TransactionType {
return SchATransaction.fromJSON({
form_type: 'SA12',
transaction_type_identifier: ScheduleATransactionTypes.TRANSFER,
back_reference_sched_name: 'SA12',
aggregation_group: AggregationGroups.GENERAL,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { hasNoContact, isNewTransaction } from 'app/shared/interfaces/transactio
import { LabelUtils } from 'app/shared/utils/label.utils';
import { schema } from 'fecfile-validate/fecfile_validate_js/dist/TRIBAL_JF_TRANSFER_MEMO';
import {
AggregationGroups, SchATransaction, ScheduleATransactionTypeLabels, ScheduleATransactionTypes
AggregationGroups,
SchATransaction,
ScheduleATransactionTypeLabels,
ScheduleATransactionTypes,
} from '../scha-transaction.model';
import {
NavigationAction,
NavigationControl,
NavigationDestination,
SAVE_LIST_CONTROL,
TransactionNavigationControls
TransactionNavigationControls,
} from '../transaction-navigation-controls.model';

export class TRIBAL_JF_TRANSFER_MEMO implements TransactionType {
Expand Down
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(transactionType) }">
<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(transactionType)"
></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 @@ -36,7 +36,11 @@ <h3>Employer</h3>
<app-employer-input [form]="form" [formSubmitted]="formSubmitted"></app-employer-input>
<p-divider></p-divider>
<h3>Receipt Information</h3>
<app-amount-input [form]="form" [formSubmitted]="formSubmitted"></app-amount-input>
<app-amount-input
[form]="form"
[formSubmitted]="formSubmitted"
[memoCodeReadOnly]="isMemoCodeReadOnly(transactionType)"
></app-amount-input>
<p-divider></p-divider>
<h3>Additional Information</h3>
<app-additional-info-input [form]="form" [formSubmitted]="formSubmitted"></app-additional-info-input>
Expand Down Expand Up @@ -91,7 +95,7 @@ <h3>Receipt Information</h3>
<app-amount-input
[form]="childForm"
[formSubmitted]="formSubmitted"
[memoCodeReadOnly]="true"
[memoCodeReadOnly]="isMemoCodeReadOnly(transactionType?.childTransactionType)"
[contributionAmountReadOnly]="true"
></app-amount-input>
<p-divider></p-divider>
Expand Down
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(transactionType) }">
<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(transactionType)"
></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(transactionType) }">
<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(transactionType)"
></p-checkbox>
<div class="memo-checkbox-note">
{{ memoItemHelpText }}
Expand Down
Loading