diff --git a/Bewital/20_hooks.groovy b/Bewital/20_hooks.groovy index c4ba7b8..92c869d 100644 --- a/Bewital/20_hooks.groovy +++ b/Bewital/20_hooks.groovy @@ -89,11 +89,33 @@ class Hook { } + @Entrypoint( entrypoint = 'hook_validate_update_entry_10' ) + public int hookValidateUpdateEntry10( D3Interface d3, User user, DocumentType docType, Document doc, String nextcall ){ + d3.log.info("START | hookValidateUpdateEntry10 "); + validateValues(d3, docType, doc); + d3.log.info("ENDE | hookValidateUpdateEntry10 "); + return 0; + } + @Entrypoint( entrypoint = "hook_insert_entry_10" ) public int hookInsertEntry10(D3Interface d3, User user, DocumentType docType, Document doc) { d3.log.info("START | hookInsertEntry10 "); + validateValues(d3, docType, doc); + def dokuart_liste = "DIE01;DIE02;DIE03;DIE04;DIE05;DIE06;DIE07;DIE08;DNV01;DNV02;DNV03;DNV04;DNV05;DNV06;DNV07;DNV08;DFE01;DFE02;DFE03;DQM01"; + + if ( dokuart_liste.contains( docType.id() ) ) + { + doc.status = Document.DocStatus.DOC_STAT_RELEASE; + } + + + d3.log.info("ENDE | hookInsertEntry10 "); + return 0; + } + + public void validateValues(D3Interface d3, DocumentType docType, Document doc){ //////////////////////////////////////// // Validierung Kundennummer calb/d.velop 2025.12.08 START @@ -103,24 +125,24 @@ class Hook { { if ( doc.field[ 2 ].indexOf( "|" ) > 0 ) { - def werte = doc.field[ 2 ].tokenize( " | " ); + def werte = doc.field[ 2 ].tokenize( "|" ); // Kundennummer if ( werte[ 0 ].length() > 0 ) { - doc.field[ 2 ] = werte[ 0 ]; + doc.field[ 2 ] = werte[ 0 ].trim(); } // Kundenname if ( werte[ 1 ].length() > 0 ) { - doc.field[ 1 ] = werte[ 1 ]; + doc.field[ 1 ] = werte[ 1 ].trim(); } // Land if ( werte[ 2 ].length() > 0 ) { - doc.field[ 4 ] = werte[ 2 ]; + doc.field[ 4 ] = werte[ 2 ].trim(); } } } @@ -138,18 +160,18 @@ class Hook { { if ( doc.field[ 12 ].indexOf( "|" ) > 0 ) { - def werte = doc.field[ 12 ].tokenize( " | " ); + def werte = doc.field[ 12 ].tokenize( "|" ); // Artikelnummer if ( werte[ 0 ].length() > 0 ) { - doc.field[ 12 ] = werte[ 0 ]; + doc.field[ 12 ] = werte[ 0 ].trim(); } // Artikelname if ( werte[ 1 ].length() > 0 ) { - doc.field[ 13 ] = werte[ 1 ]; + doc.field[ 13 ] = werte[ 1 ].trim(); } } @@ -168,18 +190,18 @@ class Hook { { if ( doc.field[ 15 ].indexOf( "|" ) > 0 ) { - def werte = doc.field[ 15 ].tokenize( " | " ); + def werte = doc.field[ 15 ].tokenize( "|" ); - // Artikelnummer + // Mandant if ( werte[ 0 ].length() > 0 ) { - doc.field[ 15 ] = werte[ 0 ]; + doc.field[ 15 ] = werte[ 0 ].trim(); } - // Artikelname + // Mandantenname if ( werte[ 1 ].length() > 0 ) { - doc.field[ 19 ] = werte[ 1 ]; + doc.field[ 19 ] = werte[ 1 ].trim(); } } @@ -198,18 +220,18 @@ class Hook { { if ( doc.field[ 32 ].indexOf( "|" ) > 0 ) { - def werte = doc.field[ 32 ].tokenize( " | " ); + def werte = doc.field[ 32 ].tokenize( "|" ); // Artikelnummer if ( werte[ 0 ].length() > 0 ) { - doc.field[ 32 ] = werte[ 0 ]; + doc.field[ 32 ] = werte[ 0 ].trim(); } // Artikelname if ( werte[ 1 ].length() > 0 ) { - doc.field[ 35 ] = werte[ 1 ]; + doc.field[ 35 ] = werte[ 1 ].trim(); } } } @@ -217,19 +239,8 @@ class Hook { // Validierung Vertreter ENDE //////////////////////////////////////// - - - d3.log.info("ENDE | hookInsertEntry10 "); - return 0; } - - - - - - - private boolean isRepoIdInDocType( D3Interface d3, String docTypeShort, int repoId ) { boolean isRepoIdInDocType = false;