09-18-2024 03:49 AM
ASPECT:"sgrFatture:productContentAspect" AND @sgrFatture:riferimentoFattura:36818518
ASPECT:"sgrFatture:productContentAspect" AND @sgrFatture:riferimentoFatturaTxt:36818518
<?xml version="1.0" encoding="UTF-8"?> <model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="sgrFatture:sgrmodel"> <description>SGR Fatture Model, modello ereditato da Davide Di Domenico HP, aggiunti i tipi di documento sintetica e anomalia rispetto al modello presente nel pacchetto AMP di Paolo Pasini</description> <author>Alessandro Celli</author> <imports> <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/> </imports> <namespaces> <namespace uri="http://www.sgr.it/model/Fatture/content/1.1" prefix="sgrFatture"/> </namespaces> <data-types/> <constraints/> <types/> <aspects> <aspect name="sgrFatture:productContentAspect"> <title>Fatture Gruppo SGR</title> <description>Aspetto con i metadati utilizzati da Gruppo SGR per la gestione delle fatture</description> <properties> <property name="sgrFatture:tipoDocumento"> <title>Tipologia documento</title> <description>E' il tipo di documento, può assumere uno dei seguenti valori: fattura, copertina, sintetica, rata o anomalia.</description> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> <facetable>false</facetable> </index> <constraints> <constraint name="sgrFatture:LIST_9489e71b-cb1f-44ca-8b13-eaa9553fa52a" type="LIST"> <parameter name="allowedValues"> <list> <value>fattura</value> <value>copertina</value> <value>sintetica</value> <value>rata</value> <value>anomalia</value> </list> </parameter> <parameter name="caseSensitive"> <value>true</value> </parameter> <parameter name="sorted"> <value>false</value> </parameter> </constraint> </constraints> </property> <property name="sgrFatture:codiceUfficio"> <title>Codice ufficio</title> <description>Corrisponde al CDUFFICI di Giada</description> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> <facetable>false</facetable> </index> </property> <property name="sgrFatture:dataEmissione"> <title>Data di emissione</title> <description>Corrisponde alla data di emissione della fattura in Giada</description> <type>d:datetime</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> </index> </property> <property name="sgrFatture:annoEsercizio"> <title>Anno di esercizio</title> <description>Corrispode al AAESERCI di Giada</description> <type>d:int</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> </index> </property> <property name="sgrFatture:numeroConto"> <title>Numero conto</title> <description>Corrisponde al NUCONTO di Giada</description> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> <facetable>false</facetable> </index> </property> <property name="sgrFatture:riferimentoFatturaTxt"> <title>Riferimento rata Txt</title> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> <facetable>false</facetable> </index> </property> <property name="sgrFatture:numeroFattura"> <title>Numero fattura</title> <description>Corrisponde al NUFATTUR di Giada</description> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> <facetable>false</facetable> </index> </property> <property name="sgrFatture:rifRata"> <title>Riferimento rata</title> <description>Corrisponde al Id della rata</description> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> <facetable>false</facetable> </index> </property> <property name="sgrFatture:riferimentoFattura"> <title>Riferimento fattura</title> <description>Corrisponde al CDFATTUR di giada</description> <type>d:int</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> </index> </property> <property name="sgrFatture:rifCopertina"> <title>Numero fascicolo</title> <description>Corrisponde al NUFASCIC di Giada</description> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> <facetable>false</facetable> </index> </property> <property name="sgrFatture:dataScadenza"> <title>Data di scadenza</title> <description>Indica la data di scadenza della fattura in Giada</description> <type>d:datetime</type> <mandatory>false</mandatory> <index enabled="true" stored="true"> <tokenised>TRUE</tokenised> </index> </property> </properties> <associations/> <overrides/> <mandatory-aspects/> </aspect> </aspects> </model>
//---- FUNCTION ------------------------------------------------------------------------------------
function createPathAsNeeded(path) {
var apath=path.split("/");
var node=companyhome;
for each (var adir in apath) {
if (node.childByNamePath(adir) == null) {
node=node.createFolder(adir);
} else {
node=node.childByNamePath(adir);
}
}
return node;
}
//---- MAIN PROGRAM --------------------------------------------------------------------------------
// Inizializzo le variabili di lavoro
var name = document.properties.name.split(".")[0];
var pieces = name.split("_");
var destFolderName = "Sites/fatture/documentLibrary/repository/"+pieces[4].substr(0,4)+"/"+pieces[4].substr(4,2)+"/"+pieces[4].substr(6,2);
// Imposto le proprietà dell'aspetto sgrFatture
if (pieces[0].length >= 11) {
document.properties["sgrFatture:riferimentoFattura"] = 0;
} else {
document.properties["sgrFatture:riferimentoFattura"] = pieces[0];
};
document.properties["sgrFatture:riferimentoFatturaTxt"] = pieces[0];
document.properties["sgrFatture:numeroFattura"] = pieces[1];
document.properties["sgrFatture:codiceUfficio"] = pieces[2];
document.properties["sgrFatture:annoEsercizio"] = pieces[3];
document.properties["sgrFatture:dataEmissione"] = new Date(pieces[4].substr(0,4),pieces[4].substr(4,2)-1,pieces[4].substr(6,2));
document.properties["sgrFatture:dataScadenza"] = new Date(pieces[5].substr(0,4),pieces[5].substr(4,2)-1,pieces[5].substr(6,2));
document.properties["sgrFatture:numeroConto"] = pieces[6];
// Identifico se è una fattura semplice che non prevede i fascicoli o se ci sono. Distinguo anche la fattura di dettaglio da quella sintetica
switch(pieces.length) {
case 7:
document.properties["sgrFatture:tipoDocumento"] = 'fattura';
document.properties["sgrFatture:rifCopertina"] = '0';
break;
case 9:
case 10:
switch(pieces[7]) {
case 'F':
type = 'fattura';
document.properties["sgrFatture:rifCopertina"] = pieces[8];
break;
case 'C':
type = 'copertina';
document.properties["sgrFatture:rifCopertina"] = pieces[8];
break;
case 'S':
type = 'sintetica';
document.properties["sgrFatture:rifCopertina"] = pieces[8];
break;
case 'R':
type = 'rata';
document.properties["sgrFatture:rifRata"] = pieces[8];
break;
default: // In questo caso c'è una anomalia
type='anomalia';
}
document.properties["sgrFatture:tipoDocumento"] = type;
break;
default: // In questo caso c'è una anomalia
type='E';
}
document.save();
// Creo, se non esiste, la cartella di destinazione
var destinationFolder=createPathAsNeeded(destFolderName);
// Controllo che il file non sia già presente, altrimenti lo elimino
var fileExist=destinationFolder.childByNamePath(document.properties.name)
if (fileExist != null) {
fileExist.remove();
}
// Sposto il file nella cartella di destinazione
document.move(destinationFolder);
// Faccio l'unlock del file se necessario
if (document.isLocked) {
document.unlock();
};
// Ed infine scrivo la riga nel log.
logger.system.out("SGR_METADATA_FILLER_EXT: Inserito documento #"+document.properties.name+"# nella cartella "+destinationFolder.displayPath);Explore our Alfresco products with the links below. Use labels to filter content by product module.