@@ -198,39 +198,12 @@ export default class BillOfMaterialsService {
198198
199199 if ( ! perms ) throw new AccessDeniedException ( 'Permission to copy materials denied' ) ;
200200
201- // Create copied materials and assemblies (all or none)
201+ // Create copied materials (all or none)
202202 return await prisma . $transaction ( async ( tx ) => {
203203 const assemblyMap = new Map < string , string > ( ) ;
204204 const newMaterialIds : string [ ] = [ ] ;
205205
206206 for ( const material of materials ) {
207- let newAssemblyId = null ;
208-
209- // Get or create assembly if needed
210- if ( material . assemblyId ) {
211- if ( assemblyMap . has ( material . assemblyId ) ) {
212- newAssemblyId = assemblyMap . get ( material . assemblyId ) ;
213- } else {
214- const oldAssembly = await tx . assembly . findUnique ( {
215- where : { assemblyId : material . assemblyId }
216- } ) ;
217- if ( ! oldAssembly ) throw new NotFoundException ( 'Assembly' , material . assemblyId ) ;
218- if ( oldAssembly . dateDeleted ) throw new DeletedException ( 'Assembly' , material . assemblyId ) ;
219-
220- const newAssembly = await tx . assembly . create ( {
221- data : {
222- name : oldAssembly . name ,
223- dateCreated : new Date ( ) ,
224- userCreatedId : user . userId ,
225- wbsElementId : destinationProject . wbsElementId ,
226- pdmFileName : oldAssembly . pdmFileName
227- }
228- } ) ;
229- assemblyMap . set ( material . assemblyId , newAssembly . assemblyId ) ;
230- newAssemblyId = newAssembly . assemblyId ;
231- }
232- }
233-
234207 const materialType = await tx . material_Type . findUnique ( {
235208 where : { id : material . materialTypeId }
236209 } ) ;
@@ -270,7 +243,7 @@ export default class BillOfMaterialsService {
270243 dateCreated : new Date ( ) ,
271244 userCreatedId : user . userId ,
272245 wbsElementId : destinationProject . wbsElementId ,
273- assemblyId : newAssemblyId
246+ assemblyId : null
274247 } ,
275248 ...getMaterialQueryArgs ( organization . organizationId )
276249 } ) ;
0 commit comments