@@ -99,12 +99,12 @@ export class PartnerService {
99
99
}
100
100
101
101
async update ( input : UpdatePartner , session : Session ) : Promise < Partner > {
102
- const object = await this . readOne ( input . id , session ) ;
102
+ const partner = await this . readOne ( input . id , session ) ;
103
103
104
104
if (
105
105
! this . validateFinancialReportingType (
106
- input . financialReportingTypes ?? object . financialReportingTypes . value ,
107
- input . types ?? object . types . value ,
106
+ input . financialReportingTypes ?? partner . financialReportingTypes . value ,
107
+ input . types ?? partner . types . value ,
108
108
)
109
109
) {
110
110
if ( input . financialReportingTypes && input . types ) {
@@ -119,28 +119,44 @@ export class PartnerService {
119
119
} ;
120
120
}
121
121
122
- const changes = this . repo . getActualChanges ( object , input ) ;
123
- this . privileges . for ( session , Partner , object ) . verifyChanges ( changes ) ;
122
+ const changes = this . repo . getActualChanges ( partner , input ) ;
123
+ this . privileges . for ( session , Partner , partner ) . verifyChanges ( changes ) ;
124
124
const {
125
125
pointOfContactId,
126
126
languageOfWiderCommunicationId,
127
+ fieldRegions,
127
128
...simpleChanges
128
129
} = changes ;
129
130
130
- await this . repo . updateProperties ( object , simpleChanges ) ;
131
+ await this . repo . updateProperties ( partner , simpleChanges ) ;
131
132
132
133
if ( pointOfContactId ) {
133
134
await this . repo . updatePointOfContact ( input . id , pointOfContactId , session ) ;
134
135
}
136
+
135
137
if ( languageOfWiderCommunicationId ) {
136
138
await this . repo . updateRelation (
137
139
'languageOfWiderCommunication' ,
138
140
'Language' ,
139
- object . id ,
141
+ partner . id ,
140
142
languageOfWiderCommunicationId ,
141
143
) ;
142
144
}
143
145
146
+ if ( fieldRegions ) {
147
+ try {
148
+ await this . repo . updateRelationList ( {
149
+ id : partner . id ,
150
+ relation : 'fieldRegions' ,
151
+ newList : fieldRegions ,
152
+ } ) ;
153
+ } catch ( e ) {
154
+ throw e instanceof InputException
155
+ ? e . withField ( 'partner.fieldRegions' )
156
+ : e ;
157
+ }
158
+ }
159
+
144
160
return await this . readOne ( input . id , session ) ;
145
161
}
146
162
0 commit comments