diff --git a/build_utils b/build_utils index cf6578da..4e6aae0f 160000 --- a/build_utils +++ b/build_utils @@ -1 +1 @@ -Subproject commit cf6578dac794859b0495c812761ce5b94c11bbaf +Subproject commit 4e6aae0f31885d3c56d09c72de7ef8d432149dbf diff --git a/src/app/claim-mgt/claim/conversation/conversation.component.html b/src/app/claim-mgt/claim/conversation/conversation.component.html index ab5aac32..9c5ac1b4 100644 --- a/src/app/claim-mgt/claim/conversation/conversation.component.html +++ b/src/app/claim-mgt/claim/conversation/conversation.component.html @@ -3,12 +3,26 @@ - +
{{ item.action | actionName }} by {{ item.user_info.username }} at {{ item.created_at | date: 'dd.MM.yyyy HH:mm:ss' }} ({{ item.created_at | humanizedDuration: { largest: 1, hasAgoEnding: true } }}) - +
+
+ + + + +
{{ item.action | actionIcon }} diff --git a/src/app/claim-mgt/claim/conversation/conversation.component.ts b/src/app/claim-mgt/claim/conversation/conversation.component.ts index 599817d7..b3ff2c22 100644 --- a/src/app/claim-mgt/claim/conversation/conversation.component.ts +++ b/src/app/claim-mgt/claim/conversation/conversation.component.ts @@ -8,10 +8,11 @@ import { SimpleChanges, } from '@angular/core'; import { MatBottomSheet } from '@angular/material/bottom-sheet'; +import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Router } from '@angular/router'; import { from } from 'rxjs'; -import { map, scan, switchMap } from 'rxjs/operators'; +import { filter, map, scan, switchMap } from 'rxjs/operators'; import { AppAuthGuardService } from '../../../app-auth-guard.service'; import { ClaimStatus } from '../../../papi/model'; @@ -21,10 +22,12 @@ import { } from '../../../party-modification-creator'; import { extractClaimStatus } from '../../../shared/extract-claim-status'; import { getUnionKey } from '../../../shared/utils'; +import { Questionary } from '../../../thrift-services/ank/gen-model/questionary_manager'; import { Claim, Modification } from '../../../thrift-services/damsel/gen-model/claim_management'; import { PartyModification } from '../../../thrift-services/damsel/gen-model/payment_processing'; import { RecreateClaimService } from '../recreate-claim'; import { ConversationService } from './conversation.service'; +import { ExtractPartyModificationComponent } from './extract-party-modifications/extract-party-modification.component'; import { QuestionaryService } from './questionary.service'; import { SavePartyModificationsService } from './save-party-modifications.service'; import { TimelineAction } from './to-timeline-info/model'; @@ -60,7 +63,8 @@ export class ConversationComponent implements OnChanges, OnInit { private recreateClaimService: RecreateClaimService, private partyModEmitter: PartyModificationEmitter, private snackBar: MatSnackBar, - private appAuthGuardService: AppAuthGuardService + private appAuthGuardService: AppAuthGuardService, + private dialog: MatDialog ) {} ngOnChanges(changes: SimpleChanges) { @@ -126,4 +130,26 @@ export class ConversationComponent implements OnChanges, OnInit { }, }); } + + extractPartyModification(questionary: Questionary) { + const dialog = this.dialog.open(ExtractPartyModificationComponent, { + disableClose: true, + data: { questionary }, + }); + dialog + .afterClosed() + .pipe(filter((r) => r.length > 0)) + .subscribe((result) => { + this.snackBar.open('Party modifications extracted successfully', 'OK', { + duration: 1500, + }); + this.partyModificationsChanged(result); + }); + } + + canUseActionsForQuestionary(modifications: Modification[]) { + return ( + modifications.filter((m) => !!m?.claim_modification?.document_modification).length > 0 + ); + } } diff --git a/src/app/claim-mgt/claim/conversation/conversation.module.ts b/src/app/claim-mgt/claim/conversation/conversation.module.ts index 16b4e906..cd9f39c6 100644 --- a/src/app/claim-mgt/claim/conversation/conversation.module.ts +++ b/src/app/claim-mgt/claim/conversation/conversation.module.ts @@ -11,6 +11,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatListModule } from '@angular/material/list'; +import { MatMenuModule } from '@angular/material/menu'; import { MatSelectModule } from '@angular/material/select'; import { MonacoEditorModule } from '../../../monaco-editor'; @@ -26,6 +27,7 @@ import { ActionIconPipe } from './action-icon.pipe'; import { ActionNamePipe } from './action-name.pipe'; import { CommentComponent } from './comment/comment.component'; import { ConversationComponent } from './conversation.component'; +import { ExtractPartyModificationModule } from './extract-party-modifications/extract-party-modification.module'; import { FileContainerModule } from './file-container'; import { FileUploaderModule } from './file-uploader/file-uploader.module'; import { QuestionaryModule } from './questionary/questionary.module'; @@ -60,6 +62,8 @@ import { SendCommentComponent } from './send-comment'; UnsavedPartyModificationsModule, PartyModificationCreatorModule, MatDividerModule, + ExtractPartyModificationModule, + MatMenuModule, ], declarations: [ ConversationComponent, diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/index.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/index.ts new file mode 100644 index 00000000..273638e6 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/index.ts @@ -0,0 +1,2 @@ +export * from './to-individual-entity-party-modification'; +export * from './to-legal-entity-party-modification'; diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-contractor-modification.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-contractor-modification.ts new file mode 100644 index 00000000..1e522afe --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-contractor-modification.ts @@ -0,0 +1,16 @@ +import * as uuid from 'uuid/v4'; + +import { + ContractorModification, + PartyModification, +} from '../../../../../thrift-services/damsel/gen-model/claim_management'; + +export const toContractorModification = ( + modification: ContractorModification, + id: string = uuid() +): PartyModification => ({ + contractor_modification: { + id, + modification, + }, +}); diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-individual-entity-party-modification.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-individual-entity-party-modification.ts new file mode 100644 index 00000000..2bd28468 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-individual-entity-party-modification.ts @@ -0,0 +1,52 @@ +import { getOr } from '../../../../../shared/utils'; +import { QuestionaryData } from '../../../../../thrift-services/ank/gen-model/questionary_manager'; +import { PartyModification } from '../../../../../thrift-services/damsel/gen-model/claim_management'; +import { createRussianBankAccount } from '../creators/create-russian-bank-account'; +import { toContractorModification } from './to-contractor-modification'; + +const path = 'contractor.individual_entity.russian_individual_entity'; + +export const toIndividualEntityPartyModification = ( + d: QuestionaryData, + contractorID: string +): PartyModification => + toContractorModification( + { + creation: { + legal_entity: { + russian_legal_entity: { + registered_name: getOr(d, `${path}.name`, ''), + registered_number: getOr( + d, + `${path}.registration_info.individual_registration_info.ogrnip`, + '' + ), + inn: getOr(d, `${path}.inn`, '') || '', + actual_address: getOr( + d, + `${path}.registration_info.individual_registration_info.registration_place`, + '' + ), + post_address: getOr( + d, + `${path}.registration_info.individual_registration_info.registration_place`, + '' + ), + representative_position: '', + representative_full_name: getOr( + d, + `${path}.russian_private_entity.fio`, + '' + ), + representative_document: getOr( + d, + `${path}.identity_document.russian_domestic_password.series_number`, + '' + ), + russian_bank_account: createRussianBankAccount(d), + }, + }, + }, + }, + contractorID + ); diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-legal-entity-party-modification.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-legal-entity-party-modification.ts new file mode 100644 index 00000000..01d6c8d8 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/converters/to-legal-entity-party-modification.ts @@ -0,0 +1,64 @@ +import { getOr } from '../../../../../shared/utils'; +import { QuestionaryData } from '../../../../../thrift-services/ank/gen-model/questionary_manager'; +import { PartyModification } from '../../../../../thrift-services/damsel/gen-model/claim_management'; +import { createRussianBankAccount } from '../creators/create-russian-bank-account'; +import { toContractorModification } from './to-contractor-modification'; + +const path = 'contractor.legal_entity.russian_legal_entity'; + +export const toLegalEntityPartyModification = ( + d: QuestionaryData, + contractorID: string +): PartyModification => + toContractorModification( + { + creation: { + legal_entity: { + russian_legal_entity: { + registered_name: getOr(d, `${path}.name`, ''), + registered_number: getOr( + d, + `${path}.registration_info.legal_registration_info.ogrn`, + '' + ), + inn: getOr(d, `${path}.inn`, ''), + actual_address: + getOr( + d, + `${path}.registration_info.legal_registration_info.actual_address`, + '' + ) || + getOr( + d, + `${path}.registration_info.legal_registration_info.registration_address`, + '' + ), + post_address: + getOr(d, `${path}.postal_address`, '') || + getOr( + d, + `${path}.registration_info.legal_registration_info.registration_address`, + '' + ), + representative_position: getOr( + d, + `${path}.legal_owner_info.head_position`, + '' + ), + representative_full_name: getOr( + d, + `${path}.legal_owner_info.russian_private_entity.fio`, + '' + ), + representative_document: getOr( + d, + `${path}.legal_owner_info.identity_document.russian_domestic_password.series_number`, + '' + ), + russian_bank_account: createRussianBankAccount(d), + }, + }, + }, + }, + contractorID + ); diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-contract-creation.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-contract-creation.ts new file mode 100644 index 00000000..fbaefbcd --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-contract-creation.ts @@ -0,0 +1,20 @@ +import { QuestionaryData } from '../../../../../thrift-services/ank/gen-model/questionary_manager'; +import { PartyModification } from '../../../../../thrift-services/damsel/gen-model/claim_management'; +import { PaymentInstitutionRef } from '../../../../../thrift-services/damsel/gen-model/domain'; + +export const createContractCreation = ( + d: QuestionaryData, + contractorID: string, + contractID: string, + payment_institution: PaymentInstitutionRef +): PartyModification => ({ + contract_modification: { + id: contractID, + modification: { + creation: { + contractor_id: contractorID, + payment_institution, + }, + }, + }, +}); diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-contractor.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-contractor.ts new file mode 100644 index 00000000..0c1e051c --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-contractor.ts @@ -0,0 +1,25 @@ +import get from 'lodash-es/get'; + +import { QuestionaryData } from '../../../../../thrift-services/ank/gen-model/questionary_manager'; +import { PartyModification } from '../../../../../thrift-services/damsel/gen-model/claim_management'; +import { toIndividualEntityPartyModification, toLegalEntityPartyModification } from '../converters'; + +export const createContractor = (d: QuestionaryData, contractorID: string): PartyModification => { + const isLegalEntityExist = get(d, 'contractor.legal_entity', false); + const isIndividualEntityExist = get(d, 'contractor.individual_entity', false); + + const legalEntityCreation = isLegalEntityExist + ? toLegalEntityPartyModification(d, contractorID) + : null; + const individualEntityCreation = isIndividualEntityExist + ? toIndividualEntityPartyModification(d, contractorID) + : null; + + if (isLegalEntityExist) { + return legalEntityCreation; + } else if (isIndividualEntityExist) { + return individualEntityCreation; + } else { + return null; + } +}; diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-payout-tool-creation.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-payout-tool-creation.ts new file mode 100644 index 00000000..ddcacc0e --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-payout-tool-creation.ts @@ -0,0 +1,28 @@ +import { QuestionaryData } from '../../../../../thrift-services/ank/gen-model/questionary_manager'; +import { PartyModification } from '../../../../../thrift-services/damsel/gen-model/claim_management'; +import { createRussianBankAccount } from './create-russian-bank-account'; + +export const createPayoutToolCreation = ( + d: QuestionaryData, + contractID: string, + payoutToolID: string +): PartyModification => ({ + contract_modification: { + id: contractID, + modification: { + payout_tool_modification: { + payout_tool_id: payoutToolID, + modification: { + creation: { + currency: { + symbolic_code: 'RUB', + }, + tool_info: { + russian_bank_account: createRussianBankAccount(d), + }, + }, + }, + }, + }, + }, +}); diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-russian-bank-account.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-russian-bank-account.ts new file mode 100644 index 00000000..7bee2270 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-russian-bank-account.ts @@ -0,0 +1,13 @@ +import { getOr } from '../../../../../shared/utils'; +import { QuestionaryData } from '../../../../../thrift-services/ank/gen-model/questionary_manager'; +import { RussianBankAccount } from '../../../../../thrift-services/damsel/gen-model/domain'; + +const path = 'bank_account.russian_bank_account'; + +export const createRussianBankAccount = (d: QuestionaryData): RussianBankAccount => { + const account = getOr(d, `${path}.account`, ''); + const bank_name = getOr(d, `${path}.bank_name`, ''); + const bank_bik = getOr(d, `${path}.bank_bik`, ''); + const bank_post_account = getOr(d, `${path}.bank_post_account`, ''); + return { account, bank_name, bank_bik, bank_post_account }; +}; diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-shop-account-creation.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-shop-account-creation.ts new file mode 100644 index 00000000..36f88001 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-shop-account-creation.ts @@ -0,0 +1,10 @@ +import { PartyModification } from '../../../../../thrift-services/damsel/gen-model/claim_management'; + +export const createShopAccountCreation = (shopID: string): PartyModification => ({ + shop_modification: { + id: shopID, + modification: { + shop_account_creation: { currency: { symbolic_code: 'RUB' } }, + }, + }, +}); diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-shop-creation.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-shop-creation.ts new file mode 100644 index 00000000..356db150 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/create-shop-creation.ts @@ -0,0 +1,35 @@ +import { getOr } from '../../../../../shared/utils'; +import { QuestionaryData } from '../../../../../thrift-services/ank/gen-model/questionary_manager'; +import { PartyModification } from '../../../../../thrift-services/damsel/gen-model/claim_management'; + +export const createShopCreation = ( + d: QuestionaryData, + contract_id: string, + payout_tool_id: string, + categoryID: number, + shopID: string +): PartyModification => { + const defaultLocation = { url: '' }; + const location = getOr(d, 'shop_info.location', defaultLocation); + + const defaultDetails = { + name: '', + description: '', + }; + const details = getOr(d, 'shop_info.details', defaultDetails); + + return { + shop_modification: { + id: shopID, + modification: { + creation: { + contract_id, + payout_tool_id, + location, + details, + category: { id: categoryID }, + }, + }, + }, + }; +}; diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/index.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/index.ts new file mode 100644 index 00000000..54afdcf2 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/creators/index.ts @@ -0,0 +1,3 @@ +export * from './create-contract-creation'; +export * from './create-payout-tool-creation'; +export * from './create-shop-creation'; diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-form-checkbox-name.pipe.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-form-checkbox-name.pipe.ts new file mode 100644 index 00000000..2e608787 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-form-checkbox-name.pipe.ts @@ -0,0 +1,19 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'ccExtractFormCheckboxName', +}) +export class ExtractFormCheckboxNamePipe implements PipeTransform { + transform(value: string): string { + switch (value) { + case 'contractCreation': + return 'Contract creation'; + case 'payoutToolCreation': + return 'Payout tool creation'; + case 'shopCreation': + return 'Shop creation'; + default: + return value; + } + } +} diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-form-value.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-form-value.ts new file mode 100644 index 00000000..6f08b26c --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-form-value.ts @@ -0,0 +1,16 @@ +import { + CategoryRef, + PaymentInstitutionRef, +} from '../../../../thrift-services/damsel/gen-model/domain'; + +interface ExtractParamsFormValue { + contractCreation: boolean; + payoutToolCreation: boolean; + shopCreation: boolean; +} + +export interface ExtractFormValue { + params: ExtractParamsFormValue; + category: CategoryRef; + payment_institution: PaymentInstitutionRef; +} diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.component.html b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.component.html new file mode 100644 index 00000000..f10269e5 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.component.html @@ -0,0 +1,37 @@ +

Party modifications extraction params

+
+
+
Party modifications types:
+
+
+ {{ control.key | ccExtractFormCheckboxName }} + +
+
+
+ + +
+
+ + + + +
diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.component.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.component.ts new file mode 100644 index 00000000..0af0303e --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.component.ts @@ -0,0 +1,34 @@ +import { Component, Inject } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; + +import { Questionary } from '../../../../thrift-services/ank/gen-model/questionary_manager'; +import { ExtractPartyModificationsService } from './extract-party-modifications.service'; + +export interface ExtractPartyModification { + questionary: Questionary; +} + +@Component({ + templateUrl: 'extract-party-modification.component.html', + providers: [ExtractPartyModificationsService], +}) +export class ExtractPartyModificationComponent { + form = this.extractPartyModificationsService.form; + + constructor( + private dialogRef: MatDialogRef, + private extractPartyModificationsService: ExtractPartyModificationsService, + @Inject(MAT_DIALOG_DATA) private data: ExtractPartyModification + ) {} + + extract() { + this.dialogRef.close( + this.extractPartyModificationsService.mapToModifications(this.data.questionary.data) + ); + } + + getParamsControls() { + return (this.form.get('params') as FormGroup).controls; + } +} diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.module.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.module.ts new file mode 100644 index 00000000..5ee7178f --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modification.module.ts @@ -0,0 +1,29 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FlexModule } from '@angular/flex-layout'; +import { ReactiveFormsModule } from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatDialogModule } from '@angular/material/dialog'; +import { MatInputModule } from '@angular/material/input'; + +import { PartyModificationCreationModule } from '../../../../party-modification-creator/party-modification-creation'; +import { ExtractFormCheckboxNamePipe } from './extract-form-checkbox-name.pipe'; +import { ExtractPartyModificationComponent } from './extract-party-modification.component'; + +@NgModule({ + declarations: [ExtractPartyModificationComponent, ExtractFormCheckboxNamePipe], + exports: [ExtractPartyModificationComponent], + imports: [ + FlexModule, + MatDialogModule, + MatButtonModule, + MatInputModule, + ReactiveFormsModule, + MatCheckboxModule, + CommonModule, + PartyModificationCreationModule, + ], + entryComponents: [ExtractPartyModificationComponent], +}) +export class ExtractPartyModificationModule {} diff --git a/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modifications.service.ts b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modifications.service.ts new file mode 100644 index 00000000..9f8b6ff5 --- /dev/null +++ b/src/app/claim-mgt/claim/conversation/extract-party-modifications/extract-party-modifications.service.ts @@ -0,0 +1,73 @@ +import { Injectable } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; +import * as uuid from 'uuid/v4'; + +import { QuestionaryData } from '../../../../thrift-services/ank/gen-model/questionary_manager'; +import { PartyModification } from '../../../../thrift-services/damsel/gen-model/claim_management'; +import { createContractCreation, createPayoutToolCreation, createShopCreation } from './creators'; +import { createContractor } from './creators/create-contractor'; +import { createShopAccountCreation } from './creators/create-shop-account-creation'; +import { ExtractFormValue } from './extract-form-value'; + +@Injectable() +export class ExtractPartyModificationsService { + form = this.fb.group({ + params: this.fb.group({ + contractCreation: true, + payoutToolCreation: true, + shopCreation: true, + }), + category: this.fb.group({}), + payment_institution: this.fb.group({}), + }); + + constructor(private fb: FormBuilder) {} + + mapToModifications(d: QuestionaryData): PartyModification[] { + const { + params: { contractCreation, payoutToolCreation, shopCreation }, + category, + payment_institution, + }: ExtractFormValue = this.form.value; + const shopID = shopCreation ? uuid() : ''; + const contractID = contractCreation ? uuid() : ''; + const contractorID = contractCreation ? uuid() : ''; + const payoutToolID = payoutToolCreation ? uuid() : ''; + + const result = []; + + if (contractCreation) { + const contractorCreationModification = createContractor(d, contractorID); + const contractCreationModification = createContractCreation( + d, + contractorID, + contractID, + payment_institution + ); + result.push(contractorCreationModification, contractCreationModification); + } + + if (payoutToolCreation) { + const payoutToolCreationModification = createPayoutToolCreation( + d, + contractID, + payoutToolID + ); + result.push(payoutToolCreationModification); + } + + if (shopCreation) { + const shopCreationModification = createShopCreation( + d, + contractID, + payoutToolID, + category.id, + shopID + ); + const shopAccountCreation = createShopAccountCreation(shopID); + result.push(shopCreationModification, shopAccountCreation); + } + + return result; + } +} diff --git a/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.html b/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.html index 839808f4..a4d11f49 100644 --- a/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.html +++ b/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.html @@ -1,13 +1,17 @@ -
+ - + {{ paymentInstitution.ref.id }} {{ paymentInstitution.data.name }} +
diff --git a/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.ts b/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.ts index c1e122fa..d98f78f8 100644 --- a/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.ts +++ b/src/app/party-modification-creator/party-modification-creation/contract/payment-institution/payment-institution-ref.component.ts @@ -1,8 +1,10 @@ import { Component, Input, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { MatSnackBar } from '@angular/material/snack-bar'; import get from 'lodash-es/get'; import sortBy from 'lodash-es/sortBy'; import { Observable } from 'rxjs'; +import { tap } from 'rxjs/internal/operators'; import { map } from 'rxjs/operators'; import { DomainTypedManager } from '../../../../thrift-services'; @@ -25,18 +27,35 @@ export class PaymentInstitutionRefComponent implements OnInit { @Input() initialValue: PaymentInstitutionRef; + isLoading = true; + paymentInstitutions$: Observable; - constructor(private fb: FormBuilder, private dtm: DomainTypedManager) {} + constructor( + private fb: FormBuilder, + private dtm: DomainTypedManager, + private snackBar: MatSnackBar + ) {} ngOnInit() { - this.paymentInstitutions$ = this.dtm - .getPaymentInstitutions() - .pipe( - map((paymentInstitutions) => - sortBy(paymentInstitutions, (paymentInstitution) => paymentInstitution.ref.id) - ) - ); + this.paymentInstitutions$ = this.dtm.getPaymentInstitutions().pipe( + map((paymentInstitutions) => + sortBy(paymentInstitutions, (paymentInstitution) => paymentInstitution.ref.id) + ), + tap( + () => { + this.form.controls.id.enable(); + this.isLoading = false; + }, + () => { + this.isLoading = false; + this.snackBar.open( + 'An error occurred while payment institutions receiving', + 'OK' + ); + } + ) + ); const paymentInstitutionId = get(this, 'initialValue.id', ''); this.form.registerControl( 'id', diff --git a/src/app/party-modification-creator/party-modification-creation/party-modification-creation.component.html b/src/app/party-modification-creator/party-modification-creation/party-modification-creation.component.html index ef331181..85880eb6 100644 --- a/src/app/party-modification-creator/party-modification-creation/party-modification-creation.component.html +++ b/src/app/party-modification-creator/party-modification-creation/party-modification-creation.component.html @@ -50,6 +50,7 @@ *ngIf="action.name === shopModificationNames.categoryModification" [form]="form.get('modification')" [initialValue]="modification?.category_modification" + [required]="true" > +
- - + + {{ category.id }} {{ category.name }} diff --git a/src/app/party-modification-creator/party-modification-creation/shop/shop-params/shop-params.component.html b/src/app/party-modification-creator/party-modification-creation/shop/shop-params/shop-params.component.html index 8c58bfcb..a7ebea90 100644 --- a/src/app/party-modification-creator/party-modification-creation/shop/shop-params/shop-params.component.html +++ b/src/app/party-modification-creator/party-modification-creation/shop/shop-params/shop-params.component.html @@ -23,7 +23,7 @@ diff --git a/src/app/party/shop-details/shop-details.module.ts b/src/app/party/shop-details/shop-details.module.ts index 868cab29..aa68cd03 100644 --- a/src/app/party/shop-details/shop-details.module.ts +++ b/src/app/party/shop-details/shop-details.module.ts @@ -88,5 +88,6 @@ import { TerminalsComponent } from './terminals/terminals.component'; EditTerminalDecisionPriorityComponent, EditTerminalDecisionWeightComponent, ], + exports: [CategoryComponent], }) export class ShopDetailsModule {} diff --git a/src/app/shared/components/timeline/timeline-item/timeline-item-title/timeline-item-title.component.html b/src/app/shared/components/timeline/timeline-item/timeline-item-title/timeline-item-title.component.html index d521d399..b6f9f5ba 100644 --- a/src/app/shared/components/timeline/timeline-item/timeline-item-title/timeline-item-title.component.html +++ b/src/app/shared/components/timeline/timeline-item/timeline-item-title/timeline-item-title.component.html @@ -1,3 +1,3 @@
-
+
diff --git a/src/app/shared/utils/get-or.ts b/src/app/shared/utils/get-or.ts new file mode 100644 index 00000000..0a3513da --- /dev/null +++ b/src/app/shared/utils/get-or.ts @@ -0,0 +1,7 @@ +import get from 'lodash-es/get'; +import isEmpty from 'lodash-es/isEmpty'; + +export const getOr = (object: any, path: string | string[], defaultValue: any): any => { + const val = get(object, path); + return isEmpty(val) ? defaultValue : val; +}; diff --git a/src/app/shared/utils/index.ts b/src/app/shared/utils/index.ts index 75ebef04..4752384a 100644 --- a/src/app/shared/utils/index.ts +++ b/src/app/shared/utils/index.ts @@ -6,3 +6,4 @@ export * from './map-values-to-thrift-enum'; export * from './map-values-to-number'; export * from './is-numeric'; export * from './wrap-values-to-array'; +export * from './get-or';