Sistemato controllo su conto setup distinta incassi
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250520102717 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("getCmovrAcconti", "CREATE FUNCTION [dbo].[getCmovrAcconti] (@codAnag varchar(5))\n" +
|
||||
"RETURNS Table\n" +
|
||||
"as\n" +
|
||||
"Return\n" +
|
||||
"/* Estrazione movimenti di acconto dai documenti e dai saldi contabili*/\n" +
|
||||
" \n" +
|
||||
" select *,SUM(importo) OVER(PARTITION BY cod_anag ORDER BY data_cmov, num_cmov ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS saldo\n" +
|
||||
" from\n" +
|
||||
" (\n" +
|
||||
" /*Movimenti non agganciate a partita contabilie: appaiono tutti in ordine di data */\n" +
|
||||
" select '2' as GruppoConti, @CodAnag as cod_anag, 0 as num_cmov, '1900-01-01' as data_cmov, \n" +
|
||||
" null as descrizione_caus, null as conto, null as annoPart, null as ser_doc, \n" +
|
||||
" null as num_doc, 0 as Importo,null as perc_aliq, null as cod_jcom, null as data_ord, null as num_ord\n" +
|
||||
" union all\n" +
|
||||
" select '2' as GruppoConti, ctb_movr.cod_anag, ctb_movt.num_cmov, ctb_movt.data_cmov, ctb_movt.descrizione_caus, \n" +
|
||||
" ctb_cont.descrizione as conto,\n" +
|
||||
" isNull(ctb_movr.anno_part, year(data_doc)) as annoPart, \n" +
|
||||
" isNull(ctb_movr.ser_Doc,ctb_movt.ser_doc) as ser_doc, \n" +
|
||||
" isNull(ctb_movr.num_doc, ctb_movt.num_doc) as num_doc,\n" +
|
||||
" ctb_movr.imp_dare-ctb_movr.imp_avere as importo,\n" +
|
||||
" null as perc_aliq, null as cod_jcom, null as data_ord, null as num_ord\n" +
|
||||
" from ctb_movt, ctb_movr, ctb_cont, ctb_tipo_riep\n" +
|
||||
" where \n" +
|
||||
" ctb_cont.tipo_riep = ctb_tipo_riep.tipo_riep and\n" +
|
||||
" ctb_tipo_riep.consid_partita = 'N' and\n" +
|
||||
" ctb_movr.cod_ccon <> isNull((select value from stb_gest_setup where gest_name = 'W_VDIST_INCA_RC' and section = 'REGISTRAZIONE_CONTABILE'\n" +
|
||||
" and key_section = 'COD_CCON_ACCONTO'),'') and \n" +
|
||||
" ctb_movr.cod_ccon = ctb_cont.cod_ccon and\n" +
|
||||
" ctb_movt.num_cmov = ctb_movr.num_cmov and\n" +
|
||||
" (ctb_movr.anno_part is null or ctb_movr.ser_doc is null or ctb_movr.num_doc is null) and\n" +
|
||||
" ctb_movr.num_cmov not in (select num_cmov from dtb_doct where cod_anag = @CodAnag and num_cmov is not null) and\n" +
|
||||
" ctb_movr.cod_anag = @CodAnag\n" +
|
||||
" union all\n" +
|
||||
" Select '2' as GruppoConti, dtb_doct.cod_anag, dtb_doct.num_cmov, dtb_doct.data_reg, \n" +
|
||||
" dtb_tipi.descrizione as descrizione_caus,\n" +
|
||||
" ctb_cont.descrizione,\n" +
|
||||
" year(dtb_doct.data_doc), dtb_doct.ser_doc, dtb_doct.num_doc,\n" +
|
||||
" -round((dtb_Docr.qta_doc * dtb_docr.val_unt) * (1 + gtb_aliq.perc_aliq/100),2)*segno_val_scar as importo,\n" +
|
||||
" gtb_aliq.perc_aliq, dtb_docr.cod_jcom, dtb_doct.data_ord as data_ord, dtb_doct.num_ord as num_ord\n" +
|
||||
" from dtb_tipi, dtb_doct, dtb_docr, mtb_aart, ctb_cont, ctb_tipo_riep, gtb_aliq\n" +
|
||||
" where dtb_doct.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.cod_Dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc and\n" +
|
||||
" dtb_docr.cod_aliq = gtb_aliq.cod_aliq and\n" +
|
||||
" dtb_docr.cod_mart = mtb_aart.cod_mart and\n" +
|
||||
" mtb_aart.cod_ccon_ricavi = ctb_cont.cod_ccon and\n" +
|
||||
" ctb_cont.tipo_riep = ctb_tipo_riep.tipo_riep and\n" +
|
||||
" ctb_cont.cod_ccon <> isNull((select value from stb_gest_setup where gest_name = 'W_VDIST_INCA_RC' and section = 'REGISTRAZIONE_CONTABILE'\n" +
|
||||
" and key_section = 'COD_CCON_ACCONTO'),'') and \n" +
|
||||
" ctb_tipo_riep.consid_partita = 'N' and\n" +
|
||||
" dtb_tipi.tipo_emissione = 'DIRETTA' and\n" +
|
||||
" dtb_doct.cod_anag = @CodAnag\n" +
|
||||
" )q");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user