diff --git a/cg/cg0500a.uml b/cg/cg0500a.uml index e1c661daa..8a2554603 100755 --- a/cg/cg0500a.uml +++ b/cg/cg0500a.uml @@ -1,291 +1,291 @@ -#include "cg0500.h" - -TOOLBAR "" 0 20 0 2 - -#include - -ENDPAGE - -PAGE "" -1 -1 77 20 - -GROUPBOX DLG_NULL -1 3 -BEGIN - PROMPT 1 0 "" -END - -STRING F_COD_CAUS 3 -BEGIN - PROMPT 3 1 "Codice " - FIELD LF_CAUSALI->CODCAUS - KEY 1 - FLAGS "U" - USE LF_CAUSALI - INPUT CODCAUS F_COD_CAUS - DISPLAY "Cod. causale" CODCAUS - DISPLAY "Descrizione @50" DESCR - DISPLAY "Tipo documento" TIPODOC - DISPLAY "Codice registro" REG - DISPLAY "Tipo movimento" TIPOMOV - OUTPUT F_COD_CAUS CODCAUS - OUTPUT F_DESCR DESCR - HELP "Codice causale" - CHECKTYPE REQUIRED -END - -STRING F_DESCR 40 -BEGIN - PROMPT 17 1 "Descrizione " - FIELD LF_CAUSALI->DESCR - COPY USE F_COD_CAUS - INPUT CODCAUS F_COD_CAUS - INPUT DESCR F_DESCR - DISPLAY "Cod. causale" CODCAUS - DISPLAY "Descrizione @50" DESCR - DISPLAY "Tipo documento" TIPODOC - DISPLAY "Codice registro" REG - DISPLAY "Tipo movimento" TIPOMOV - OUTPUT F_COD_CAUS CODCAUS - OUTPUT F_DESCR DESCR - HELP "Descrizione della causale" -END - -STRING F_TIPO_DOC 2 -BEGIN - PROMPT 2 4 "Tipo doc. " - FIELD LF_CAUSALI->TIPODOC - USE %TPD - INPUT CODTAB F_TIPO_DOC - DISPLAY "Tipo " CODTAB - DISPLAY "Descrizione @50 " S0 - OUTPUT F_TIPO_DOC CODTAB - HELP "Tipo documento" - CHECKTYPE NORMAL -// MESSAGE SHOW, 2@ -// MESSAGE EMPTY HIDE, 2@ - FLAGS "U" -END - -STRING F_COD_REG 3 -BEGIN - PROMPT 23 4 "Cod. reg. " - FIELD LF_CAUSALI->REG - USE REG - INPUT CODTAB[1,4] F_ANNOES - INPUT CODTAB[5,7] F_COD_REG - DISPLAY "Anno" CODTAB[1,4] - DISPLAY "Codice registro " CODTAB[5,7] - DISPLAY "Tipo" I0 - DISPLAY "Registro corrispettivi" B0 - DISPLAY "Descrizione @50" S0 - OUTPUT F_ANNOES CODTAB[1,4] - OUTPUT F_COD_REG CODTAB[5,7] - OUTPUT F_TIPO_REG I0 - OUTPUT F_CORRISP B0 - HELP "Codice registro" - CHECKTYPE NORMAL - FLAGS "D" -END - -// Questo rimane sempre nascosto -STRING F_TIPO_MOV 2 -BEGIN - PROMPT 68 4 "" - FIELD LF_CAUSALI->TIPOMOV - FLAGS "H" -END - -// Viene mostrato questo se TPD non vuoto e diverso da IN AN PG -LISTBOX F_TIPO_MOV_1 1 20 -BEGIN - PROMPT 44 4 "Tipo mov. " - FIELD LF_CAUSALI->TIPOMOV - HELP "Tipo movimento" - ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV - ITEM "1|Fattura" MESSAGE COPY,F_TIPO_MOV - ITEM "2|Nota credito" MESSAGE COPY,F_TIPO_MOV -// GROUP 2 -END - -// Viene mostrato questo se TPD vuoto o uguale a IN AN PG -LISTBOX F_TIPO_MOV_2 1 20 -BEGIN - PROMPT 44 4 "Tipo mov. " - FIELD LF_CAUSALI->TIPOMOV - HELP "Inserire il tipo movimento" - ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV - ITEM "3|Incasso/pagamento " MESSAGE COPY,F_TIPO_MOV - ITEM "5|Insoluto" MESSAGE COPY,F_TIPO_MOV - ITEM "6|Pagamento insoluto" MESSAGE COPY,F_TIPO_MOV - FLAGS "H" -END - -STRING F_ANNOES 4 -BEGIN - PROMPT 2 6 "" - FLAGS "H" -END - -STRING F_TIPO_REG 4 -BEGIN - PROMPT 23 5 "" - FLAGS "H" -END - -BOOLEAN F_CORRISP -BEGIN - PROMPT 33 5 "" - FLAGS "H" -END - -SPREADSHEET F_SHEET_GCS -BEGIN - PROMPT 0 7 "" - ITEM "Tipo conto@21" - ITEM "C/F" - ITEM "Gr." - ITEM "Co." - ITEM "Sottoc." - ITEM "D/A" - ITEM "Descrizione@50" - ITEM "Descr. agg." - ITEM "Iva" - ITEM "Cod.Iva" -END - -ENDPAGE - -PAGE "" -1 -1 77 20 - -GROUPBOX DLG_NULL -1 3 -BEGIN - PROMPT 1 0 "@BCampi obbligatori in caricamento documenti" -END - -BOOLEAN F_DATA_DOC -BEGIN - PROMPT 2 1 "Data documento" - FIELD LF_CAUSALI->DATADOC - HELP "" - CHECKTYPE NORMAL -END - -BOOLEAN F_NUM_DOC -BEGIN - PROMPT 34 1 "Numero documento" - FIELD LF_CAUSALI->NUMDOC - CHECKTYPE NORMAL -END - -BOOLEAN F_AUTO_FAT -BEGIN - PROMPT 2 4 "Autofattura art.34" - FIELD LF_CAUSALI->AUTOFATT - CHECKTYPE NORMAL - GROUP 2 -END - -BOOLEAN F_ALLEGAT -BEGIN - PROMPT 34 4 "Doc. non va in allegati fine anno" - FIELD LF_CAUSALI->ALLEG - GROUP 2 -END - -BOOLEAN F_FAT_RITARDO -BEGIN - PROMPT 2 6 "Fattura in ritardo" - FIELD LF_CAUSALI->RITFATT - GROUP 2 -END - -STRING F_COD_CAUS_IM 3 -BEGIN - PROMPT 34 6 "Codice causale per l'incasso immediato " - FIELD LF_CAUSALI->CODCAUSIM - COPY USE F_COD_CAUS - INPUT CODCAUS F_COD_CAUS_IM - COPY DISPLAY F_COD_CAUS - OUTPUT F_COD_CAUS_IM CODCAUS - CHECKTYPE NORMAL -// MESSAGE CLEAR, F_M_770 - GROUP 2 -END - -BOOLEAN F_OP_INTRACOM -BEGIN - PROMPT 2 8 "Operazione intracomunitaria" - FIELD LF_CAUSALI->INTRACOM -// MESSAGE TRUE "X", F_MOV_VALU | DISABLE, F_MOV_VALU -// MESSAGE FALSE "", F_MOV_VALU | ENABLE, F_MOV_VALU - GROUP 2 -END - -BOOLEAN F_VALINTRA -BEGIN - PROMPT 34 8 "Gestione valuta per operazioni intrac." - FIELD LF_CAUSALI->VALINTRA - GROUP 2 -END - -BOOLEAN F_MOV_VALU -BEGIN - PROMPT 2 10 "Movimento in valuta" - FIELD LF_CAUSALI->MOVVAL - GROUP 2 -END - -BOOLEAN F_MOV_SEZ -BEGIN - PROMPT 34 10 "Movimento solo sezionale" - FIELD LF_CAUSALI->MOVSEZ - FLAGS "H" -END - -LISTBOX F_OP_FINE_ANNO 1 10 -BEGIN - PROMPT 2 12 "Operazioni di fine anno " - ITEM " | " - ITEM "C|Chiusura" - ITEM "A|Apertura" - FIELD LF_CAUSALI->MOVAP - FLAGS "H" -END - - -LISTBOX F_COLL_CESP 1 40 -BEGIN - PROMPT 2 14 "Collegamento cespiti " - FIELD LF_CAUSALI->COLLCESP - HELP "Inserire il tipo di collegamento cespiti" - ITEM " |Nessuno" - ITEM "A|Acquisto cespite" - ITEM "B|Rettifica acquisto" - ITEM "C|Sostenimento costi" - ITEM "E|Eliminazione dal processo produttivo" - ITEM "M|Rivalutazione monetaria" - ITEM "P|Reinvestimento plusvalenze" - ITEM "R|Rivalutazione economica" - ITEM "T|Trasferimento" - ITEM "V|Vendita cespite" - ITEM "Z|Rettifica vendita" -END - -LISTBOX F_M_770 1 40 -BEGIN - PROMPT 2 16 "Collegamento Mod.770 " - FIELD LF_CAUSALI->M770 - HELP "Inserire il tipo di collegamento Mod.770" - ITEM " |Nessuno" // MESSAGE ENABLE,F_COD_CAUS_IM - ITEM "1|Ricevuta e/o pagamento fattura percip." // MESSAGE CLEAR,F_COD_CAUS_IM - ITEM "2|Versamento ritenute percip." // MESSAGE CLEAR,F_COD_CAUS_IM - ITEM "3|Versamento ritenute dipendente" // MESSAGE CLEAR,F_COD_CAUS_IM - ITEM "4|Versamento contributi dipendente" // MESSAGE CLEAR,F_COD_CAUS_IM - ITEM "5|Compensi non soggetti" // MESSAGE CLEAR,F_COD_CAUS_IM - ITEM "6|Ritenute per operazioni occasionali" // MESSAGE CLEAR,F_COD_CAUS_IM -END - -ENDPAGE - -ENDMASK - -#include "cg0500b.uml" +#include "cg0500.h" + +TOOLBAR "" 0 20 0 2 + +#include + +ENDPAGE + +PAGE "" -1 -1 77 20 + +GROUPBOX DLG_NULL -1 3 +BEGIN + PROMPT 1 0 "" +END + +STRING F_COD_CAUS 3 +BEGIN + PROMPT 3 1 "Codice " + FIELD LF_CAUSALI->CODCAUS + KEY 1 + FLAGS "U" + USE LF_CAUSALI + INPUT CODCAUS F_COD_CAUS + DISPLAY "Cod. causale" CODCAUS + DISPLAY "Descrizione @50" DESCR + DISPLAY "Tipo documento" TIPODOC + DISPLAY "Codice registro" REG + DISPLAY "Tipo movimento" TIPOMOV + OUTPUT F_COD_CAUS CODCAUS + OUTPUT F_DESCR DESCR + HELP "Codice causale" + CHECKTYPE REQUIRED +END + +STRING F_DESCR 40 +BEGIN + PROMPT 17 1 "Descrizione " + FIELD LF_CAUSALI->DESCR + COPY USE F_COD_CAUS + INPUT CODCAUS F_COD_CAUS + INPUT DESCR F_DESCR + DISPLAY "Cod. causale" CODCAUS + DISPLAY "Descrizione @50" DESCR + DISPLAY "Tipo documento" TIPODOC + DISPLAY "Codice registro" REG + DISPLAY "Tipo movimento" TIPOMOV + OUTPUT F_COD_CAUS CODCAUS + OUTPUT F_DESCR DESCR + HELP "Descrizione della causale" +END + +STRING F_TIPO_DOC 2 +BEGIN + PROMPT 2 4 "Tipo doc. " + FIELD LF_CAUSALI->TIPODOC + USE %TPD + INPUT CODTAB F_TIPO_DOC + DISPLAY "Tipo " CODTAB + DISPLAY "Descrizione @50 " S0 + OUTPUT F_TIPO_DOC CODTAB + HELP "Tipo documento" + CHECKTYPE NORMAL +// MESSAGE SHOW, 2@ +// MESSAGE EMPTY HIDE, 2@ + FLAGS "U" +END + +STRING F_COD_REG 3 +BEGIN + PROMPT 23 4 "Cod. reg. " + FIELD LF_CAUSALI->REG + USE REG + INPUT CODTAB[1,4] F_ANNOES + INPUT CODTAB[5,7] F_COD_REG + DISPLAY "Anno" CODTAB[1,4] + DISPLAY "Codice registro " CODTAB[5,7] + DISPLAY "Tipo" I0 + DISPLAY "Registro corrispettivi" B0 + DISPLAY "Descrizione @50" S0 + OUTPUT F_ANNOES CODTAB[1,4] + OUTPUT F_COD_REG CODTAB[5,7] + OUTPUT F_TIPO_REG I0 + OUTPUT F_CORRISP B0 + HELP "Codice registro" + CHECKTYPE NORMAL + FLAGS "D" +END + +// Questo rimane sempre nascosto +STRING F_TIPO_MOV 2 +BEGIN + PROMPT 68 4 "" + FIELD LF_CAUSALI->TIPOMOV + FLAGS "H" +END + +// Viene mostrato questo se TPD non vuoto e diverso da IN AN PG +LISTBOX F_TIPO_MOV_1 1 20 +BEGIN + PROMPT 44 4 "Tipo mov. " + FIELD LF_CAUSALI->TIPOMOV + HELP "Tipo movimento" + ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV + ITEM "1|Fattura" MESSAGE COPY,F_TIPO_MOV + ITEM "2|Nota credito" MESSAGE COPY,F_TIPO_MOV +// GROUP 2 +END + +// Viene mostrato questo se TPD vuoto o uguale a IN AN PG +LISTBOX F_TIPO_MOV_2 1 20 +BEGIN + PROMPT 44 4 "Tipo mov. " + FIELD LF_CAUSALI->TIPOMOV + HELP "Inserire il tipo movimento" + ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV + ITEM "3|Incasso/pagamento " MESSAGE COPY,F_TIPO_MOV + ITEM "5|Insoluto" MESSAGE COPY,F_TIPO_MOV + ITEM "6|Pagamento insoluto" MESSAGE COPY,F_TIPO_MOV + FLAGS "H" +END + +STRING F_ANNOES 4 +BEGIN + PROMPT 2 6 "" + FLAGS "H" +END + +STRING F_TIPO_REG 4 +BEGIN + PROMPT 23 5 "" + FLAGS "H" +END + +BOOLEAN F_CORRISP +BEGIN + PROMPT 33 5 "" + FLAGS "H" +END + +SPREADSHEET F_SHEET_GCS +BEGIN + PROMPT 0 7 "" + ITEM "Tipo conto@21" + ITEM "C/F" + ITEM "Gr." + ITEM "Co." + ITEM "Sottoc." + ITEM "D/A" + ITEM "Descrizione@50" + ITEM "Descr. agg." + ITEM "Iva" + ITEM "Cod.Iva" +END + +ENDPAGE + +PAGE "" -1 -1 77 20 + +GROUPBOX DLG_NULL -1 3 +BEGIN + PROMPT 1 0 "@BCampi obbligatori in caricamento documenti" +END + +BOOLEAN F_DATA_DOC +BEGIN + PROMPT 2 1 "Data documento" + FIELD LF_CAUSALI->DATADOC + HELP "" + CHECKTYPE NORMAL +END + +BOOLEAN F_NUM_DOC +BEGIN + PROMPT 34 1 "Numero documento" + FIELD LF_CAUSALI->NUMDOC + CHECKTYPE NORMAL +END + +BOOLEAN F_AUTO_FAT +BEGIN + PROMPT 2 4 "Autofattura art.34" + FIELD LF_CAUSALI->AUTOFATT + CHECKTYPE NORMAL + GROUP 2 +END + +BOOLEAN F_ALLEGAT +BEGIN + PROMPT 34 4 "Doc. non va in allegati fine anno" + FIELD LF_CAUSALI->ALLEG + GROUP 2 +END + +BOOLEAN F_FAT_RITARDO +BEGIN + PROMPT 2 6 "Fattura in ritardo" + FIELD LF_CAUSALI->RITFATT + GROUP 2 +END + +STRING F_COD_CAUS_IM 3 +BEGIN + PROMPT 34 6 "Codice causale per l'incasso immediato " + FIELD LF_CAUSALI->CODCAUSIM + COPY USE F_COD_CAUS + INPUT CODCAUS F_COD_CAUS_IM + COPY DISPLAY F_COD_CAUS + OUTPUT F_COD_CAUS_IM CODCAUS + CHECKTYPE NORMAL +// MESSAGE CLEAR, F_M_770 + GROUP 2 +END + +BOOLEAN F_OP_INTRACOM +BEGIN + PROMPT 2 8 "Operazione intracomunitaria" + FIELD LF_CAUSALI->INTRACOM +// MESSAGE TRUE "X", F_MOV_VALU | DISABLE, F_MOV_VALU +// MESSAGE FALSE "", F_MOV_VALU | ENABLE, F_MOV_VALU + GROUP 2 +END + +BOOLEAN F_VALINTRA +BEGIN + PROMPT 34 8 "Gestione valuta per operazioni intrac." + FIELD LF_CAUSALI->VALINTRA + GROUP 2 +END + +BOOLEAN F_MOV_VALU +BEGIN + PROMPT 2 10 "Movimento in valuta" + FIELD LF_CAUSALI->MOVVAL + GROUP 2 +END + +BOOLEAN F_MOV_SEZ +BEGIN + PROMPT 34 10 "Movimento solo sezionale" + FIELD LF_CAUSALI->MOVSEZ + FLAGS "H" +END + +LISTBOX F_OP_FINE_ANNO 1 10 +BEGIN + PROMPT 2 12 "Operazioni di fine anno " + ITEM " | " + ITEM "C|Chiusura" + ITEM "A|Apertura" + FIELD LF_CAUSALI->MOVAP + FLAGS "H" +END + + +LISTBOX F_COLL_CESP 1 40 +BEGIN + PROMPT 2 14 "Collegamento cespiti " + FIELD LF_CAUSALI->COLLCESP + HELP "Inserire il tipo di collegamento cespiti" + ITEM " |Nessuno" + ITEM "A|Acquisto cespite" + ITEM "B|Rettifica acquisto" + ITEM "C|Sostenimento costi" + ITEM "E|Eliminazione dal processo produttivo" + ITEM "M|Rivalutazione monetaria" + ITEM "P|Reinvestimento plusvalenze" + ITEM "R|Rivalutazione economica" + ITEM "T|Trasferimento" + ITEM "V|Vendita cespite" + ITEM "Z|Rettifica vendita" +END + +LISTBOX F_M_770 1 40 +BEGIN + PROMPT 2 16 "Collegamento Mod.770 " + FIELD LF_CAUSALI->M770 + HELP "Inserire il tipo di collegamento Mod.770" + ITEM " |Nessuno" // MESSAGE ENABLE,F_COD_CAUS_IM + ITEM "1|Ricevuta e/o pagamento fattura percip." // MESSAGE CLEAR,F_COD_CAUS_IM + ITEM "2|Versamento ritenute percip." // MESSAGE CLEAR,F_COD_CAUS_IM + ITEM "3|Versamento ritenute dipendente" // MESSAGE CLEAR,F_COD_CAUS_IM + ITEM "4|Versamento contributi dipendente" // MESSAGE CLEAR,F_COD_CAUS_IM + ITEM "5|Compensi non soggetti" // MESSAGE CLEAR,F_COD_CAUS_IM + ITEM "6|Ritenute per operazioni occasionali" // MESSAGE CLEAR,F_COD_CAUS_IM +END + +ENDPAGE + +ENDMASK + +#include "cg0500b.uml" diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 5e3aa83ca..fbf36e775 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -1,766 +1,769 @@ -#include -#include -#include -#include -#include - -#include "cg2100.h" -#include "cg2102.h" - -// Nomi dei campi -#include -#include -#include - - -TPrimanota_application::TPrimanota_application() - : _rel(NULL), _lastreg(0), _mode(0), _iva(nessuna_iva) -{ - memset(_msk, 0, sizeof(_msk)); -} - - -TMask* TPrimanota_application::load_mask(int n) -{ - if (_msk[n] != NULL) - return _msk[n]; - - TFilename name("cg2100"); name << char(n == 3 ? 'o' : 'a'+n); - TMask* m = new TMask(name); - - switch (n) - { - case 0: - { - m->set_handler(F_NUMREG, num_handler); - m->set_handler(F_CODCAUS, caus_query_handler); - m->set_handler(F_DATAREG, datareg_handler); - m->set_handler(F_DATACOMP, datacomp_handler); - TConfig c(CONFIG_STUDIO, "cg"); - const bool dr = c.get_bool("PoCuDr"); // Scelta primo campo col focus - m->first_focus(dr ? F_DATAREG : F_CODCAUS); - } - break; - case 1: - m->set_handler(F_VISVAL, visval_handler); - m->set_handler(F_DESCR, descr_handler); - break; - case 2: -{ - m->set_handler(F_CODREG, reg_handler); - m->set_handler(F_CLIENTE, clifo_handler); - m->set_handler(F_FORNITORE, clifo_handler); - m->set_handler(F_TOTALE, totale_handler); - m->set_handler(F_RITFIS, ritfis_handler); - m->set_handler(F_RITSOC, ritsoc_handler); - m->set_handler(F_CODIVA, main_codiva_handler); - m->set_handler(F_VISVAL, visval_handler); - m->set_handler(F_OCCASEDIT, occas_handler); - m->set_handler(F_SOLAIVA, solaiva_handler); - m->set_handler(F_SHEETIVA, iva_handler); - - TSheet_field& is = (TSheet_field&)m->field(F_SHEETIVA); - is.set_notify(iva_notify); - TMask& ism = is.sheet_mask(); - ism.set_handler(101, imponibile_handler); - ism.set_handler(102, codiva_handler); - ism.set_handler(104, imposta_handler); - ism.set_handler(109, suspended_handler); - ism.set_handler(209, suspended_handler); - ism.set_handler(309, suspended_handler); -} -break; - case 3: - m->set_handler(O_CODICE, occas_code_handler); - break; -default: -CHECKD(0, "Che cavolo di maschera e' la ", n); -break; -} -if (n == 1 || n == 2) -{ - m->set_handler(F_DATAREG, datareg_handler); - m->set_handler(F_DATACOMP, datacomp_handler); - m->set_handler(F_CODCAUS, caus_modify_handler); - m->set_handler(F_SHEETCG, cg_handler); - - TSheet_field& cg = (TSheet_field&)m->field(F_SHEETCG); - cg.set_notify(cg_notify); - TMask& cgm = cg.sheet_mask(); - cgm.set_handler(101, dareavere_handler); - cgm.set_handler(102, dareavere_handler); - cgm.set_handler(105, suspended_handler); - cgm.set_handler(106, suspended_handler); - cgm.set_handler(206, suspended_handler); - cgm.set_handler(306, suspended_handler); - cgm.set_handler(112, suspended_handler); - cgm.set_handler(113, suspended_handler); - cgm.set_handler(213, suspended_handler); - cgm.set_handler(313, suspended_handler); -} - -return _msk[n] = m; -} - - -bool TPrimanota_application::user_create() -{ - _tabcom = new TLocalisamfile(LF_TABCOM); - _tab = new TLocalisamfile(LF_TAB); - _caus = new TLocalisamfile(LF_CAUSALI); - _rcaus = new TLocalisamfile(LF_RCAUSALI); - _clifo = new TLocalisamfile(LF_CLIFO); - _pcon = new TLocalisamfile(LF_PCON); - _attiv = new TLocalisamfile(LF_ATTIV); - _saldo = new TLocalisamfile(LF_SALDI); - _comuni = new TLocalisamfile(LF_COMUNI); - _occas = new TLocalisamfile(LF_OCCAS); - _nditte = new TLocalisamfile(LF_NDITTE); - - _rel = new TMovimentoPN; - _rel->lfile()->last(); - _lastreg = _rel->lfile()->get_long(MOV_NUMREG); // Init last registration number - - set_search_field(F_NUMREG); // Set field for default search - - return TRUE; -} - - -bool TPrimanota_application::user_destroy() -{ - if (_msk[3] != NULL) delete _msk[3]; - if (_msk[2] != NULL) delete _msk[2]; - if (_msk[1] != NULL) delete _msk[1]; - if (_msk[0] != NULL) delete _msk[0]; - - delete _rel; - delete _nditte; - delete _occas; - delete _comuni; - delete _saldo; - delete _attiv; - delete _pcon; - delete _clifo; - delete _rcaus; - delete _caus; - delete _tab; - delete _tabcom; - return TRUE; -} - - -void TPrimanota_application::print() -{ - TExternal_app stampa("cg3 -0"); - stampa.run(); -} - -// Legge la causale di codice cod ed il relativo registro dell'anno year -// Certified 99% -bool TPrimanota_application::read_caus(const char* cod, int year) -{ - const bool ok = causale().read(cod, year); - - bool nob = FALSE, dob = FALSE; - if (ok) - { - nob = _causale.num_doc(); - dob = _causale.data_doc(); - } - - TMask& m = *load_mask(causale().iva() == nessuna_iva ? 1 : 2); - TEdit_field& nd = (TEdit_field&)m.field(F_NUMDOC); // Numero documento obbligatorio? - nd.check_type(nob ? CHECK_REQUIRED : CHECK_NORMAL); - TEdit_field& dd = (TEdit_field&)m.field(F_DATADOC); // Data documento obbligatoria? - dd.check_type(dob ? CHECK_REQUIRED : CHECK_NORMAL); - - return ok; -} - - -bool TPrimanota_application::changing_mask(int mode) -{ - if (mode == MODE_QUERY) - return _mode != MODE_QUERY; - - TipoIVA oliva = _iva; - - _iva = nessuna_iva; - - TString16 causale; - // TString16 registro; - int annoes = 0, annoiva = 0; - - switch (mode) - { - case MODE_INS: - annoes = _msk[0]->get_int(F_ANNOES); - annoiva = _msk[0]->get_int(F_ANNOIVA); - causale = _msk[0]->get(F_CODCAUS); - read_caus(causale, annoiva); - break; - case MODE_MOD: - annoes = _rel->lfile()->get_int("ANNOES"); - annoiva = _rel->lfile()->get_int("ANNOIVA"); - causale = _rel->lfile()->get("CODCAUS"); - giornale().read(annoes); - // registro = _rel->lfile()->get("REG"); - // _causale.read(causale, 0); - // _causale.reg().read(registro, annoiva); - read_caus(causale, annoiva); - break; - default: - break; - } - _iva = _causale.iva(); - - return _mode == MODE_QUERY || _iva != oliva; -} - - -TMask* TPrimanota_application::get_mask(int mode) -{ - _mode = mode; - const int m = (mode == MODE_QUERY) ? 0 : (iva() == nessuna_iva ? 1 : 2); - return load_mask(m); -} - - -void TPrimanota_application::init_mask(TMask& m) -{ - disable_menu_item(M_FILE_PRINT); - - fill_sheet(m); - - // Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_VISVAL (GROUP 3) - m.send_key(K_SHIFT+K_CTRL+(_causale.valuta() ? 's' : 'h'), -3); - m.set(F_VISVAL, _causale.valuta() ? "X" : " "); - - if (_iva != nessuna_iva) - { - char clig, forg; - if (_iva == iva_acquisti) - { - forg = 's'; - clig = 'h'; - } - else - { - forg = 'h'; - clig = causale().corrispettivi() ? 'h' : 's'; - } - m.send_key(K_SHIFT+K_CTRL+clig, -1); // group 1 (clienti) - m.send_key(K_SHIFT+K_CTRL+forg, -2); // group 2 (fornitori) - - const bool intra = _causale.intra(); - m.show(F_CORRLIRE, intra); - - const bool corrval = intra && _causale.corrval(); - m.show(F_CORRVALUTA, corrval); - } - - m.disable(DLG_NEWREC); -} - - -void TPrimanota_application::init_query_mode(TMask& m) -{ - enable_menu_item(M_FILE_PRINT); - m.enable(DLG_NEWREC); -} - - -void TPrimanota_application::fill_sheet(TMask& m) const -{ - TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG); - for (int r = cgs.items(); r < 16; r++) - cgs.row(r); - - if (_iva != nessuna_iva) - { - TSheet_field& ivas = (TSheet_field&)m.field(F_SHEETIVA); - for (r = ivas.items(); r < 16; r++) ivas.row(r); - ivas.enable_column(4, _iva == iva_acquisti); - } -} - - -// Ritorna il prossimo numero di registrazione libero -// Certified 100% -const char* TPrimanota_application::get_next_key() -{ - return format("%d|%ld", F_NUMREG, _lastreg+1); -} - - -void TPrimanota_application::init_insert_mode(TMask& m) -{ - m.set(F_DATAREG, _msk[0]->get(F_DATAREG)); - m.set(F_DATACOMP, _msk[0]->get(F_DATACOMP)); - m.set(F_ANNOES, _msk[0]->get(F_ANNOES)); - m.set(F_ANNOIVA, _msk[0]->get(F_ANNOIVA)); - occas_mask().reset(); - - init_mask(m); - _saldi.reset(); // Inizializza saldi - _saldi.set_movprovv(_rel->lfile()->get_char("PROVVIS") > ' ' ? TRUE : FALSE); - _saldi.set_movap(_causale.apertura()); - _saldi.set_anno_es(m.get_int(F_ANNOES)); - _saldi.set_num_ulmov(m.get_long(F_NUMREG)); - const TDate datareg(m.get(F_DATAREG)); - _saldi.set_data_ulmov(datareg); - - if (_iva != nessuna_iva) - { - const long protiva = causale().reg().protocol(); - m.set(F_PROTIVA, protiva+1); - - TMask_field& vv = m.field(F_VISVAL); - if (vv.active() && vv.get() == "X") // Se e' un movimento in valuta - { - const bool ok = m.field(F_VALUTA).on_key(K_F9); // Richiedi valuta - vv.set(ok ? "X" : " "); - if (ok) vv.on_hit(); // Cambia decimali - } - } - - if (m.get(F_CODCAUS).empty()) return; - - TString80 desc; - for (int i = 1; i < _causale.size(); i++) - { - TRectype* rcaus = (TRectype*)_causale.objptr(i); - if (rcaus == NULL) continue; // Evita eventuali righe nulle - - const int nriga = rcaus->get_int(RCA_NRIGA); - if (nriga < 1) continue; // Considera solo righe reali (non riempimenti) - - TConto tc; _causale.bill(nriga, tc); - if (tc.conto() < 1) continue; // Considera solo conti validi - - char sezione = rcaus->get_char(RCA_SEZIONE); - if (sezione != 'A') sezione = 'D'; - const TImporto zero(sezione, ZERO); - - desc = rcaus->get(RCA_DESC); - - if (nriga == 1) m.set(F_DESCR, desc); - - if (iva() == nessuna_iva) - { - const int n = set_cgs_row(-1,zero,tc,desc,' '); - cgs().disable_cell(n, sezione == 'D' ? 1 : 0); - } - else - { - if (nriga == 3 || nriga == 4 || nriga == 8 || nriga == 9) - continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali - - const bool rigaiva = rcaus->get_bool(RCA_RIGAIVA); - if (nriga == 2 || (nriga >= 5 && nriga <= 7) || rigaiva) - { - const TString16 codiva(rcaus->get(RCA_CODIVA)); - set_ivas_row(-1,codiva,tc,desc); - } - else - { - const char tipo = nriga < 2 ? 'T' : ' '; - set_cgs_row(-1,zero,tc,desc,tipo); - - if (nriga == 1 && tc.tipo() > ' ' && tc.sottoconto() > 0) - m.set(tc.tipo() == 'C' ? F_CLIENTE : F_FORNITORE, tc.sottoconto()); - } - } - } -} - - -void TPrimanota_application::init_modify_mode(TMask& m) -{ - init_mask(m); -} - - -bool TPrimanota_application::get_conto(const TRectype& r, TConto& c) const -{ - c.set(r.get_int("GRUPPO"), r.get_int("CONTO"), - r.get_long("SOTTOCONTO"), r.get_char("TIPOC")); - return c.ok(); -} - -void TPrimanota_application::put_conto(TRectype& r, const TConto& c) const -{ - r.put("TIPOC", c.tipo()); - r.put("GRUPPO", c.gruppo()); - r.put("CONTO", c.conto()); - r.put("SOTTOCONTO", c.sottoconto()); -} - -bool TPrimanota_application::test_swap(bool ritsoc) -{ - bool s = FALSE; - - const char sez = ritsoc ? causale().sezione_ritsoc() : causale().sezione_clifo(); - s = (iva() == iva_vendite) ^ sez == 'D'; - return s; -} - - -int TPrimanota_application::read(TMask& m) -{ - m.autoload(_rel); - - if (_iva != nessuna_iva) - { - const TString16 occode(_rel->lfile()->get("OCFPI")); - occas_mask().set(O_CODICE, occode); - - const char clifo = toupper(m.get(F_CLIFO)[0]); - - if (_iva == iva_acquisti && clifo == 'C') - error_box("Registrazione di acquisto attribuita ad un cliente"); else - if (_iva == iva_vendite && clifo == 'F') - error_box("Registrazione di vendita attribuita ad un fornitore"); - - if (_iva == iva_vendite) - { - TEdit_field& f = (TEdit_field&)m.field(F_CLIENTE); - f.check_type(clifo == 'C' ? CHECK_REQUIRED : CHECK_NORMAL); - } - } - - TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG); - cgs.reset(); - - _saldi.reset(); // Azzera saldi - _saldi.set_movprovv(_rel->lfile()->get_char("PROVVIS") > ' ' ? TRUE : FALSE); - _saldi.set_movap(_causale.apertura()); - _saldi.set_anno_es(m.get_int(F_ANNOES)); - _saldi.set_num_ulmov(m.get_long(F_NUMREG)); - _saldi.set_data_ulmov((TDate)m.get(F_DATAREG)); - - TToken_string riga(255); - - for (int i = 0; i < _rel->cg_items(); i++) - { - const TRectype& r = _rel->cg(i); - riga.cut(0); // Vuota la riga - - const int rcontr = r.get_int("RCONTR") -1; -#ifdef DBG - if (rcontr < -1 || rcontr >= _rel->cg_items() || rcontr == i) - error_box("La riga %d non puo' avere per contropartita la %d", i+1, rcontr+1); -#endif - - const real im(r.get_real("IMPORTO")); - const char sezione = toupper(r.get_char("SEZIONE")); - - TImporto import(sezione, im); - import.add_to(riga); // Dare/Avere 101-102 - - TConto conto; get_conto(r, conto); - riga.add(conto.string(0x3)); // Conto 103-107 - if (conto.ok()) - _saldi.aggiorna(conto, im, sezione, FALSE); - - riga.add(""); // Codice descrizione 108 - riga.add(r.get("DESCR")); // Descrizione riga 109 - - if (rcontr >= 0 && rcontr < _rel->cg_items()) - { - get_conto(_rel->cg(rcontr), conto); - riga.add(conto.string(0x3)); // Contropartita 110-114 - } - else riga.add(" | | | | "); - - const char tipo = r.get_char("ROWTYPE"); - riga.add(tipo); // Tipo di riga 115 - - cgs.row(i) = riga; - disable_cgs_cells(i, tipo); - } - - if (_iva == nessuna_iva) - return _rel->status(); - - const bool solaiva = i == 0; - m.set(F_SOLAIVA, solaiva ? "X" : " "); - m.field(F_SOLAIVA).on_hit(); - - TSheet_field& ivas = (TSheet_field&)m.field(F_SHEETIVA); - ivas.reset(); - - const bool to_swap = test_swap(FALSE); - - for (i = 0; i < _rel->iva_items(); i++) - { - TRectype& r = _rel->iva(i); - riga.cut(0); - - real imponibile(r.get("IMPONIBILE")); - if (to_swap) imponibile = -imponibile; - riga.add(imponibile.string()); // Imponibile 101 - - riga.add(r.get("CODIVA")); // IVA 102 - riga.add(r.get("TIPODET")); // Detrazione 103 - riga.add(r.get("IMPOSTA")); // Imposta 104 - - TConto c; get_conto(r, c); - if (c.ok()) - c.add_to(riga, 4, 0x7); // 105-110 - else - riga.add(" | | | | | "); - - ivas.row(i) = riga; - } - - TMask_field& vv = m.field(F_VISVAL); - if (vv.active()) vv.on_hit(); - - return _rel->status(); -} - - - -void TPrimanota_application::mask2rel(const TMask& m) -{ - _rel->lfile()->zero(); - m.autosave(_rel); - - const long numreg = m.get_long(F_NUMREG); - const TDate datareg(m.get(F_DATAREG)); - const int annoes = (int) m.get_long(F_ANNOES); - - _saldi.set_movprovv(m.get_bool(F_PROVVISORIO)); - _saldi.set_movap(_causale.apertura()); - _saldi.set_anno_es(annoes); - - _rel->destroy_rows(); // Destroy all records - cgs_pack(); // Destroy all null rows - - TArray& rows = cgs().rows_array(); - int cur = 1; - - // Controlla se e' un movimento con righe contabili - if (iva() == nessuna_iva || !m.get_bool(F_SOLAIVA)) - { - for (int i = 0; i < rows.items(); i++) - { - TToken_string& row = (TToken_string&)rows[i]; - - TImporto n; n = row; - const TConto conto(row, 2, 0x3); - if (conto.ok()) - _saldi.aggiorna(conto, n.valore(), n.sezione(), TRUE); - - TRectype &r = _rel->cg(cur-1); - r.zero(); - - r.put("IMPORTO", n.valore()); // Importo - r.put("SEZIONE", n.sezione()); // Sezione - - r.put("NUMREG", numreg); - r.put("ANNOES", annoes); - r.put("DATAREG", datareg); - r.put("NUMRIG", cur); - - put_conto(r, conto); // Conto - - row.get(); // Codice descrizione - r.put("DESCR", row.get()); // Descrizione riga - - int rcontr = 0; // Riga contropartita - const TConto contro(row, -1, 0x3); // Conto contropartita - if (contro.ok()) - { - rcontr = bill2contr(contro, n.sezione())+1; - if (rcontr < 1) - { - warning_box("La riga contabile %d non ha una contropartita", cur); - rcontr = 0; - } - } - r.put("RCONTR", rcontr); // Contropartita - - const char tipo = row.get_char(); - r.put("ROWTYPE", tipo); - - cur++; - } - } - if (_iva == nessuna_iva) return; - - if (causale().corrispettivi()) - { - TRectype& rec = _rel->lfile()->curr(); - rec.put("TIPO", ""); - rec.put("CODCF", ""); // Azzera il cliente nei movimenti dei corrispettivi - } - else - { - int err = ~NOERR; - if (m.get_bool(F_OCCASIONALE)) - { - TRelation occas(LF_OCCAS); - const TMask& om = occas_mask(); - om.autosave(&occas); - - err = occas.write(); - if (err == _isreinsert) - err = occas.rewrite(); - - if (err == NOERR) - _rel->lfile()->put("OCFPI", occas_mask().get(O_CODICE)); - else - error_box("Errore di scrittura sul file dei clienti/fornitori occasionali: %d", err); - } - if (err) _rel->lfile()->zero("OCFPI"); - } - - const bool to_swap = test_swap(FALSE); - TArray& irows = ivas().rows_array(); - cur = 1; - for (int i = 0; i < irows.items(); i++) - { - TToken_string& row = (TToken_string&)irows[i]; - if (row.empty_items()) - continue; - - TRectype &r = _rel->iva(cur-1); - r.zero(); - r.put("ANNOES", annoes); - r.put("NUMREG", numreg); - r.put("NUMRIG", cur); - - real imponibile(row.get(0)); - if (to_swap) imponibile = -imponibile; - r.put("IMPONIBILE", imponibile); - - r.put("CODIVA", row.get()); - r.put("TIPODET", row.get()); - r.put("IMPOSTA", row.get()); - r.put("TIPOCR", row.get()); - - const TConto c(row, -1, 0x1); - const int rimp = bill2pos(c, 'I')+1; - r.put("RIGAIMP", rimp); - put_conto(r, c); - - cur++; - } - - // Resetta il flag di calcolato sulla liquidazione IVA del mese di registrazione - const TDate d(m.get(F_DATAREG)); - TString16 chiave; chiave << d.year() << d.month(); - TTable lim("LIM"); - lim.put("CODTAB", chiave); - if (lim.read() == NOERR) - { - const bool calcolato = lim.get_bool("B0"); - if (calcolato) - { - lim.put("B0", FALSE); - lim.rewrite(); - } - } -} - - -int TPrimanota_application::write(const TMask& m) -{ - const long numreg = m.get_long(F_NUMREG); - if (numreg > _lastreg) _lastreg = numreg; // Aggiorna ultima registrazione - - mask2rel(m); - const int err = _rel->write(TRUE); - if (err == NOERR) - { - _saldi.registra(); - const TString16 causimm(_causale.causale_inc_imm()); - if (causimm.not_empty()) - genera_incasso(causimm); - } - return err; -} - - -int TPrimanota_application::rewrite(const TMask& m) -{ - mask2rel(m); - const int err = _rel->rewrite(TRUE); - if (err == NOERR) - _saldi.registra(); - return err; -} - - -bool TPrimanota_application::remove() -{ - const bool ok = TRelation_application::remove(); - if (ok) - _saldi.registra(); - return ok; -} - - -void TPrimanota_application::genera_incasso(const char* causimm) -{ - TMask m("cg2100i"); - m.set_handler(F_DATAREG, datareg_handler); - m.set_handler(F_DATACOMP, datacomp_handler); - - TFilename tmp; tmp.temp(); // File temporaneo di scambio - _msk[2]->set_workfile(tmp); - _msk[2]->save(); // Copia la maschera principale ... - m.set_workfile(tmp); - m.load(); // ... nella maschera di incasso - ::remove(tmp); // Cancella file temporaneo - - const TCausale caus(causimm); // Causale da usare - m.set(F_NUMREG, ++_lastreg); // Incrementa numero di registrazione - m.set(F_CODCAUS, causimm); // Cambia causale e ... - m.set(F_TIPODOC, caus.tipo_doc()); // relativo tipo documento - - if (m.run() == K_SAVE) - { - TMovimentoPN inc; // Nuovo movimento di incasso immediato - - TRectype r(_rel->cg(0)); // Copia la prima riga contabile - m.autosave(&inc); - - inc.lfile()->put("REG", ""); // Annulla eventuale registro IVA - - const real imp(m.get(F_TOTALE)); - const char sez = r.get_char("SEZIONE"); - - r.put("NUMREG", _lastreg); - r.put("NUMRIG", 1); - r.put("IMPORTO", imp); - r.put("ROWTYPE", ' '); - r.put("SEZIONE", sez == 'A' ? 'D' : 'A'); - inc.cg(0) = r; - - TConto conto; caus.bill(2, conto); // Conto della seconda riga della causale - - r.put("TIPOC", conto.tipo()); - r.put("GRUPPO", conto.gruppo()); - r.put("CONTO", conto.conto()); - r.put("SOTTOCONTO", conto.sottoconto()); - - r.put("NUMRIG", 2); - r.put("SEZIONE", sez); - inc.cg(1) = r; - - while (inc.write() == _isreinsert) // In caso di riscrittura - inc.lfile()->put("NUMREG", ++_lastreg); // Incrementa numero registrazione - } -} - - -int cg2100 (int argc, char** argv) -{ - TPrimanota_application a; - a.run(argc, argv, "Prima nota"); - return 0; -} +#include +#include +#include +#include +#include + +#include "cg2100.h" +#include "cg2102.h" + +// Nomi dei campi +#include +#include +#include + + +TPrimanota_application::TPrimanota_application() +: _rel(NULL), _lastreg(0), _mode(0), _iva(nessuna_iva) +{ + memset(_msk, 0, sizeof(_msk)); +} + + +TMask* TPrimanota_application::load_mask(int n) +{ + if (_msk[n] != NULL) + return _msk[n]; + + TFilename name("cg2100"); name << char(n == 3 ? 'o' : 'a'+n); + TMask* m = new TMask(name); + + switch (n) + { + case 0: + { + m->set_handler(F_NUMREG, num_handler); + m->set_handler(F_CODCAUS, caus_query_handler); + m->set_handler(F_DATAREG, datareg_handler); + m->set_handler(F_DATACOMP, datacomp_handler); + TConfig c(CONFIG_STUDIO, "cg"); + const bool dr = c.get_bool("PoCuDr"); // Scelta primo campo col focus + m->first_focus(dr ? F_DATAREG : F_CODCAUS); + } + break; + case 1: + m->set_handler(F_VISVAL, visval_handler); + m->set_handler(F_DESCR, descr_handler); + break; + case 2: +{ + m->set_handler(F_CODREG, reg_handler); + m->set_handler(F_CLIENTE, clifo_handler); + m->set_handler(F_FORNITORE, clifo_handler); + m->set_handler(F_TOTALE, totale_handler); + m->set_handler(F_RITFIS, ritfis_handler); + m->set_handler(F_RITSOC, ritsoc_handler); + m->set_handler(F_CODIVA, main_codiva_handler); + m->set_handler(F_VISVAL, visval_handler); + m->set_handler(F_OCCASEDIT, occas_handler); + m->set_handler(F_SOLAIVA, solaiva_handler); + m->set_handler(F_SHEETIVA, iva_handler); + + TSheet_field& is = (TSheet_field&)m->field(F_SHEETIVA); + is.set_notify(iva_notify); + TMask& ism = is.sheet_mask(); + ism.set_handler(101, imponibile_handler); + ism.set_handler(102, codiva_handler); + ism.set_handler(104, imposta_handler); + ism.set_handler(109, suspended_handler); + ism.set_handler(209, suspended_handler); + ism.set_handler(309, suspended_handler); +} +break; + case 3: + m->set_handler(O_CODICE, occas_code_handler); + break; +default: +CHECKD(0, "Che cavolo di maschera e' la ", n); +break; +} +if (n == 1 || n == 2) +{ + m->set_handler(F_DATAREG, datareg_handler); + m->set_handler(F_DATACOMP, datacomp_handler); + m->set_handler(F_CODCAUS, caus_modify_handler); + m->set_handler(F_SHEETCG, cg_handler); + + TSheet_field& cg = (TSheet_field&)m->field(F_SHEETCG); + cg.set_notify(cg_notify); + TMask& cgm = cg.sheet_mask(); + cgm.set_handler(101, dareavere_handler); + cgm.set_handler(102, dareavere_handler); + cgm.set_handler(105, suspended_handler); + cgm.set_handler(106, suspended_handler); + cgm.set_handler(206, suspended_handler); + cgm.set_handler(306, suspended_handler); + cgm.set_handler(112, suspended_handler); + cgm.set_handler(113, suspended_handler); + cgm.set_handler(213, suspended_handler); + cgm.set_handler(313, suspended_handler); +} + +return _msk[n] = m; +} + + +bool TPrimanota_application::user_create() +{ + _tabcom = new TLocalisamfile(LF_TABCOM); + _tab = new TLocalisamfile(LF_TAB); + _caus = new TLocalisamfile(LF_CAUSALI); + _rcaus = new TLocalisamfile(LF_RCAUSALI); + _clifo = new TLocalisamfile(LF_CLIFO); + _pcon = new TLocalisamfile(LF_PCON); + _attiv = new TLocalisamfile(LF_ATTIV); + _saldo = new TLocalisamfile(LF_SALDI); + _comuni = new TLocalisamfile(LF_COMUNI); + _occas = new TLocalisamfile(LF_OCCAS); + _nditte = new TLocalisamfile(LF_NDITTE); + + _rel = new TMovimentoPN; + _rel->lfile()->last(); + _lastreg = _rel->lfile()->get_long(MOV_NUMREG); // Init last registration number + + set_search_field(F_NUMREG); // Set field for default search + + load_mask(0); // Try to reduce visible loading times + load_mask(2); + + return TRUE; +} + + +bool TPrimanota_application::user_destroy() +{ + if (_msk[3] != NULL) delete _msk[3]; + if (_msk[2] != NULL) delete _msk[2]; + if (_msk[1] != NULL) delete _msk[1]; + if (_msk[0] != NULL) delete _msk[0]; + + delete _rel; + delete _nditte; + delete _occas; + delete _comuni; + delete _saldo; + delete _attiv; + delete _pcon; + delete _clifo; + delete _rcaus; + delete _caus; + delete _tab; + delete _tabcom; + return TRUE; +} + + +void TPrimanota_application::print() +{ + TExternal_app stampa("cg3 -0"); + stampa.run(); +} + +// Legge la causale di codice cod ed il relativo registro dell'anno year +// Certified 99% +bool TPrimanota_application::read_caus(const char* cod, int year) +{ + const bool ok = causale().read(cod, year); + + bool nob = FALSE, dob = FALSE; + if (ok) + { + nob = _causale.num_doc(); + dob = _causale.data_doc(); + } + + TMask& m = *load_mask(causale().iva() == nessuna_iva ? 1 : 2); + TEdit_field& nd = (TEdit_field&)m.field(F_NUMDOC); // Numero documento obbligatorio? + nd.check_type(nob ? CHECK_REQUIRED : CHECK_NORMAL); + TEdit_field& dd = (TEdit_field&)m.field(F_DATADOC); // Data documento obbligatoria? + dd.check_type(dob ? CHECK_REQUIRED : CHECK_NORMAL); + + return ok; +} + + +bool TPrimanota_application::changing_mask(int mode) +{ + if (mode == MODE_QUERY) + return _mode != MODE_QUERY; + + TipoIVA oliva = _iva; + + _iva = nessuna_iva; + + TString16 causale; + // TString16 registro; + int annoes = 0, annoiva = 0; + + switch (mode) + { + case MODE_INS: + annoes = _msk[0]->get_int(F_ANNOES); + annoiva = _msk[0]->get_int(F_ANNOIVA); + causale = _msk[0]->get(F_CODCAUS); + read_caus(causale, annoiva); + break; + case MODE_MOD: + annoes = _rel->lfile()->get_int("ANNOES"); + annoiva = _rel->lfile()->get_int("ANNOIVA"); + causale = _rel->lfile()->get("CODCAUS"); + giornale().read(annoes); + // registro = _rel->lfile()->get("REG"); + // _causale.read(causale, 0); + // _causale.reg().read(registro, annoiva); + read_caus(causale, annoiva); + break; + default: + break; + } + _iva = _causale.iva(); + + return _mode == MODE_QUERY || _iva != oliva; +} + + +TMask* TPrimanota_application::get_mask(int mode) +{ + _mode = mode; + const int m = (mode == MODE_QUERY) ? 0 : (iva() == nessuna_iva ? 1 : 2); + return load_mask(m); +} + + +void TPrimanota_application::init_mask(TMask& m) +{ + disable_menu_item(M_FILE_PRINT); + + fill_sheet(m); + + // Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_VISVAL (GROUP 3) + m.send_key(K_SHIFT+K_CTRL+(_causale.valuta() ? 's' : 'h'), -3); + m.set(F_VISVAL, _causale.valuta() ? "X" : " "); + + if (_iva != nessuna_iva) + { + char clig, forg; + if (_iva == iva_acquisti) + { + forg = 's'; + clig = 'h'; + } + else + { + forg = 'h'; + clig = causale().corrispettivi() ? 'h' : 's'; + } + m.send_key(K_SHIFT+K_CTRL+clig, -1); // group 1 (clienti) + m.send_key(K_SHIFT+K_CTRL+forg, -2); // group 2 (fornitori) + + const bool intra = _causale.intra(); + m.show(F_CORRLIRE, intra); + + const bool corrval = intra && _causale.corrval(); + m.show(F_CORRVALUTA, corrval); + } + + m.disable(DLG_NEWREC); +} + + +void TPrimanota_application::init_query_mode(TMask& m) +{ + enable_menu_item(M_FILE_PRINT); + m.enable(DLG_NEWREC); +} + + +void TPrimanota_application::fill_sheet(TMask& m) const +{ + TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG); + for (int r = cgs.items(); r < 16; r++) + cgs.row(r); + + if (_iva != nessuna_iva) + { + TSheet_field& ivas = (TSheet_field&)m.field(F_SHEETIVA); + for (r = ivas.items(); r < 16; r++) ivas.row(r); + ivas.enable_column(4, _iva == iva_acquisti); + } +} + + +// Ritorna il prossimo numero di registrazione libero +// Certified 100% +const char* TPrimanota_application::get_next_key() +{ + return format("%d|%ld", F_NUMREG, _lastreg+1); +} + + +void TPrimanota_application::init_insert_mode(TMask& m) +{ + m.set(F_DATAREG, _msk[0]->get(F_DATAREG)); + m.set(F_DATACOMP, _msk[0]->get(F_DATACOMP)); + m.set(F_ANNOES, _msk[0]->get(F_ANNOES)); + m.set(F_ANNOIVA, _msk[0]->get(F_ANNOIVA)); + occas_mask().reset(); + + init_mask(m); + _saldi.reset(); // Inizializza saldi + _saldi.set_movprovv(_rel->lfile()->get_char("PROVVIS") > ' ' ? TRUE : FALSE); + _saldi.set_movap(_causale.apertura()); + _saldi.set_anno_es(m.get_int(F_ANNOES)); + _saldi.set_num_ulmov(m.get_long(F_NUMREG)); + const TDate datareg(m.get(F_DATAREG)); + _saldi.set_data_ulmov(datareg); + + if (_iva != nessuna_iva) + { + const long protiva = causale().reg().protocol(); + m.set(F_PROTIVA, protiva+1); + + TMask_field& vv = m.field(F_VISVAL); + if (vv.active() && vv.get() == "X") // Se e' un movimento in valuta + { + const bool ok = m.field(F_VALUTA).on_key(K_F9); // Richiedi valuta + vv.set(ok ? "X" : " "); + if (ok) vv.on_hit(); // Cambia decimali + } + } + + if (m.get(F_CODCAUS).empty()) return; + + TString80 desc; + for (int i = 1; i < _causale.size(); i++) + { + TRectype* rcaus = (TRectype*)_causale.objptr(i); + if (rcaus == NULL) continue; // Evita eventuali righe nulle + + const int nriga = rcaus->get_int(RCA_NRIGA); + if (nriga < 1) continue; // Considera solo righe reali (non riempimenti) + + TConto tc; _causale.bill(nriga, tc); + if (tc.conto() < 1) continue; // Considera solo conti validi + + char sezione = rcaus->get_char(RCA_SEZIONE); + if (sezione != 'A') sezione = 'D'; + const TImporto zero(sezione, ZERO); + + desc = rcaus->get(RCA_DESC); + + if (nriga == 1) m.set(F_DESCR, desc); + + if (iva() == nessuna_iva) + { + const int n = set_cgs_row(-1,zero,tc,desc,' '); + cgs().disable_cell(n, sezione == 'D' ? 1 : 0); + } + else + { + if (nriga == 3 || nriga == 4 || nriga == 8 || nriga == 9) + continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali + + const bool rigaiva = rcaus->get_bool(RCA_RIGAIVA); + if (nriga == 2 || (nriga >= 5 && nriga <= 7) || rigaiva) + { + const TString16 codiva(rcaus->get(RCA_CODIVA)); + set_ivas_row(-1,codiva,tc,desc); + } + else + { + const char tipo = nriga < 2 ? 'T' : ' '; + set_cgs_row(-1,zero,tc,desc,tipo); + + if (nriga == 1 && tc.tipo() > ' ' && tc.sottoconto() > 0) + m.set(tc.tipo() == 'C' ? F_CLIENTE : F_FORNITORE, tc.sottoconto()); + } + } + } +} + + +void TPrimanota_application::init_modify_mode(TMask& m) +{ + init_mask(m); +} + + +bool TPrimanota_application::get_conto(const TRectype& r, TConto& c) const +{ + c.set(r.get_int("GRUPPO"), r.get_int("CONTO"), + r.get_long("SOTTOCONTO"), r.get_char("TIPOC")); + return c.ok(); +} + +void TPrimanota_application::put_conto(TRectype& r, const TConto& c) const +{ + r.put("TIPOC", c.tipo()); + r.put("GRUPPO", c.gruppo()); + r.put("CONTO", c.conto()); + r.put("SOTTOCONTO", c.sottoconto()); +} + +bool TPrimanota_application::test_swap(bool ritsoc) +{ + bool s = FALSE; + + const char sez = ritsoc ? causale().sezione_ritsoc() : causale().sezione_clifo(); + s = (iva() == iva_vendite) ^ sez == 'D'; + return s; +} + + +int TPrimanota_application::read(TMask& m) +{ + m.autoload(_rel); + + if (_iva != nessuna_iva) + { + const TString16 occode(_rel->lfile()->get("OCFPI")); + occas_mask().set(O_CODICE, occode); + + const char clifo = toupper(m.get(F_CLIFO)[0]); + + if (_iva == iva_acquisti && clifo == 'C') + error_box("Registrazione di acquisto attribuita ad un cliente"); else + if (_iva == iva_vendite && clifo == 'F') + error_box("Registrazione di vendita attribuita ad un fornitore"); + + if (_iva == iva_vendite) + { + TEdit_field& f = (TEdit_field&)m.field(F_CLIENTE); + f.check_type(clifo == 'C' ? CHECK_REQUIRED : CHECK_NORMAL); + } + } + + TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG); + cgs.reset(); + + _saldi.reset(); // Azzera saldi + _saldi.set_movprovv(_rel->lfile()->get_char("PROVVIS") > ' ' ? TRUE : FALSE); + _saldi.set_movap(_causale.apertura()); + _saldi.set_anno_es(m.get_int(F_ANNOES)); + _saldi.set_num_ulmov(m.get_long(F_NUMREG)); + _saldi.set_data_ulmov((TDate)m.get(F_DATAREG)); + + TToken_string riga(255); + + for (int i = 0; i < _rel->cg_items(); i++) + { + const TRectype& r = _rel->cg(i); + riga.cut(0); // Vuota la riga + + const int rcontr = r.get_int("RCONTR") -1; +#ifdef DBG + if (rcontr < -1 || rcontr >= _rel->cg_items() || rcontr == i) + error_box("La riga %d non puo' avere per contropartita la %d", i+1, rcontr+1); +#endif + + const real im(r.get_real("IMPORTO")); + const char sezione = toupper(r.get_char("SEZIONE")); + + TImporto import(sezione, im); + import.add_to(riga); // Dare/Avere 101-102 + + TConto conto; get_conto(r, conto); + riga.add(conto.string(0x3)); // Conto 103-107 + if (conto.ok()) + _saldi.aggiorna(conto, im, sezione, FALSE); + + riga.add(""); // Codice descrizione 108 + riga.add(r.get("DESCR")); // Descrizione riga 109 + + if (rcontr >= 0 && rcontr < _rel->cg_items()) + { + get_conto(_rel->cg(rcontr), conto); + riga.add(conto.string(0x3)); // Contropartita 110-114 + } + else riga.add(" | | | | "); + + const char tipo = r.get_char("ROWTYPE"); + riga.add(tipo); // Tipo di riga 115 + + cgs.row(i) = riga; + disable_cgs_cells(i, tipo); + } + + if (_iva == nessuna_iva) + return _rel->status(); + + const bool solaiva = i == 0; + m.set(F_SOLAIVA, solaiva ? "X" : " "); + m.field(F_SOLAIVA).on_hit(); + + TSheet_field& ivas = (TSheet_field&)m.field(F_SHEETIVA); + ivas.reset(); + + const bool to_swap = test_swap(FALSE); + + for (i = 0; i < _rel->iva_items(); i++) + { + TRectype& r = _rel->iva(i); + riga.cut(0); + + real imponibile(r.get("IMPONIBILE")); + if (to_swap) imponibile = -imponibile; + riga.add(imponibile.string()); // Imponibile 101 + + riga.add(r.get("CODIVA")); // IVA 102 + riga.add(r.get("TIPODET")); // Detrazione 103 + riga.add(r.get("IMPOSTA")); // Imposta 104 + + TConto c; get_conto(r, c); + if (c.ok()) + c.add_to(riga, 4, 0x7); // 105-110 + else + riga.add(" | | | | | "); + + ivas.row(i) = riga; + } + + TMask_field& vv = m.field(F_VISVAL); + if (vv.active()) vv.on_hit(); + + return _rel->status(); +} + + + +void TPrimanota_application::mask2rel(const TMask& m) +{ + _rel->lfile()->zero(); + m.autosave(_rel); + + const long numreg = m.get_long(F_NUMREG); + const TDate datareg(m.get(F_DATAREG)); + const int annoes = (int) m.get_long(F_ANNOES); + + _saldi.set_movprovv(m.get_bool(F_PROVVISORIO)); + _saldi.set_movap(_causale.apertura()); + _saldi.set_anno_es(annoes); + + _rel->destroy_rows(); // Destroy all records + cgs_pack(); // Destroy all null rows + + TArray& rows = cgs().rows_array(); + int cur = 1; + + // Controlla se e' un movimento con righe contabili + if (iva() == nessuna_iva || !m.get_bool(F_SOLAIVA)) + { + for (int i = 0; i < rows.items(); i++) + { + TToken_string& row = (TToken_string&)rows[i]; + + TImporto n; n = row; + const TConto conto(row, 2, 0x3); + if (conto.ok()) + _saldi.aggiorna(conto, n.valore(), n.sezione(), TRUE); + + TRectype &r = _rel->cg(cur-1); + r.zero(); + + r.put("IMPORTO", n.valore()); // Importo + r.put("SEZIONE", n.sezione()); // Sezione + + r.put("NUMREG", numreg); + r.put("ANNOES", annoes); + r.put("DATAREG", datareg); + r.put("NUMRIG", cur); + + put_conto(r, conto); // Conto + + row.get(); // Codice descrizione + r.put("DESCR", row.get()); // Descrizione riga + + int rcontr = 0; // Riga contropartita + const TConto contro(row, -1, 0x3); // Conto contropartita + if (contro.ok()) + { + rcontr = bill2contr(contro, n.sezione())+1; + if (rcontr < 1) + { + warning_box("La riga contabile %d non ha una contropartita", cur); + rcontr = 0; + } + } + r.put("RCONTR", rcontr); // Contropartita + + const char tipo = row.get_char(); + r.put("ROWTYPE", tipo); + + cur++; + } + } + if (_iva == nessuna_iva) return; + + if (causale().corrispettivi()) + { + TRectype& rec = _rel->lfile()->curr(); + rec.put("TIPO", ""); + rec.put("CODCF", ""); // Azzera il cliente nei movimenti dei corrispettivi + } + else + { + int err = ~NOERR; + if (m.get_bool(F_OCCASIONALE)) + { + TRelation occas(LF_OCCAS); + const TMask& om = occas_mask(); + om.autosave(&occas); + + err = occas.write(); + if (err == _isreinsert) + err = occas.rewrite(); + + if (err == NOERR) + _rel->lfile()->put("OCFPI", occas_mask().get(O_CODICE)); + else + error_box("Errore di scrittura sul file dei clienti/fornitori occasionali: %d", err); + } + if (err) _rel->lfile()->zero("OCFPI"); + } + + const bool to_swap = test_swap(FALSE); + TArray& irows = ivas().rows_array(); + cur = 1; + for (int i = 0; i < irows.items(); i++) + { + TToken_string& row = (TToken_string&)irows[i]; + if (row.empty_items()) + continue; + + TRectype &r = _rel->iva(cur-1); + r.zero(); + r.put("ANNOES", annoes); + r.put("NUMREG", numreg); + r.put("NUMRIG", cur); + + real imponibile(row.get(0)); + if (to_swap) imponibile = -imponibile; + r.put("IMPONIBILE", imponibile); + + r.put("CODIVA", row.get()); + r.put("TIPODET", row.get()); + r.put("IMPOSTA", row.get()); + r.put("TIPOCR", row.get()); + + const TConto c(row, -1, 0x1); + const int rimp = bill2pos(c, 'I')+1; + r.put("RIGAIMP", rimp); + put_conto(r, c); + + cur++; + } + + // Resetta il flag di calcolato sulla liquidazione IVA del mese di registrazione + const TDate d(m.get(F_DATAREG)); + TString16 chiave; chiave << d.year() << d.month(); + TTable lim("LIM"); + lim.put("CODTAB", chiave); + if (lim.read() == NOERR) + { + const bool calcolato = lim.get_bool("B0"); + if (calcolato) + { + lim.put("B0", FALSE); + lim.rewrite(); + } + } +} + + +int TPrimanota_application::write(const TMask& m) +{ + const long numreg = m.get_long(F_NUMREG); + if (numreg > _lastreg) _lastreg = numreg; // Aggiorna ultima registrazione + + mask2rel(m); + const int err = _rel->write(TRUE); + if (err == NOERR) + { + _saldi.registra(); + const TString16 causimm(_causale.causale_inc_imm()); + if (causimm.not_empty()) + genera_incasso(causimm); + } + return err; +} + + +int TPrimanota_application::rewrite(const TMask& m) +{ + mask2rel(m); + const int err = _rel->rewrite(TRUE); + if (err == NOERR) + _saldi.registra(); + return err; +} + + +bool TPrimanota_application::remove() +{ + const bool ok = TRelation_application::remove(); + if (ok) + _saldi.registra(); + return ok; +} + + +void TPrimanota_application::genera_incasso(const char* causimm) +{ + TMask m("cg2100i"); + m.set_handler(F_DATAREG, datareg_handler); + m.set_handler(F_DATACOMP, datacomp_handler); + + TFilename tmp; tmp.temp(); // File temporaneo di scambio + _msk[2]->set_workfile(tmp); + _msk[2]->save(); // Copia la maschera principale ... + m.set_workfile(tmp); + m.load(); // ... nella maschera di incasso + ::remove(tmp); // Cancella file temporaneo + + const TCausale caus(causimm); // Causale da usare + m.set(F_NUMREG, ++_lastreg); // Incrementa numero di registrazione + m.set(F_CODCAUS, causimm); // Cambia causale e ... + m.set(F_TIPODOC, caus.tipo_doc()); // relativo tipo documento + + if (m.run() == K_SAVE) + { + TMovimentoPN inc; // Nuovo movimento di incasso immediato + + TRectype r(_rel->cg(0)); // Copia la prima riga contabile + m.autosave(&inc); + + inc.lfile()->put("REG", ""); // Annulla eventuale registro IVA + + const real imp(m.get(F_TOTALE)); + const char sez = r.get_char("SEZIONE"); + + r.put("NUMREG", _lastreg); + r.put("NUMRIG", 1); + r.put("IMPORTO", imp); + r.put("ROWTYPE", ' '); + r.put("SEZIONE", sez == 'A' ? 'D' : 'A'); + inc.cg(0) = r; + + TConto conto; caus.bill(2, conto); // Conto della seconda riga della causale + + r.put("TIPOC", conto.tipo()); + r.put("GRUPPO", conto.gruppo()); + r.put("CONTO", conto.conto()); + r.put("SOTTOCONTO", conto.sottoconto()); + + r.put("NUMRIG", 2); + r.put("SEZIONE", sez); + inc.cg(1) = r; + + while (inc.write() == _isreinsert) // In caso di riscrittura + inc.lfile()->put("NUMREG", ++_lastreg); // Incrementa numero registrazione + } +} + + +int cg2100 (int argc, char** argv) +{ + TPrimanota_application a; + a.run(argc, argv, "Prima nota"); + return 0; +} diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index e94231160..2a5c4b0a4 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -1,1196 +1,1196 @@ -#include -#include -#include -#include - -#include "cg2100.h" -#include "cg2102.h" - - -// Certified 100% -inline TPrimanota_application& app() -{ return (TPrimanota_application&)*MainApp(); } - -/////////////////////////////////////////////////////////// -// Funzioni di decodifica/calcolo -/////////////////////////////////////////////////////////// - -// Determina il tipo IVA da causale+anno -// Certified 100% -TipoIVA TPrimanota_application::cau2IVA(const char* causale, int annoiva) -{ - TipoIVA i = iva_errata; - - if (*causale > ' ') - { - TCausale c; - if (c.read(causale, annoiva)) - i = c.iva(); - else - error_box("Causale errata: '%s'", causale); - } else i = nessuna_iva; - - return i; -} - -// Calcolo della percentuale di un dato codice IVA -// Certified 99% -const real& TPrimanota_application::cod2IVA(const TMask& m) -{ - static TString16 _codiva; - static real _percent; - - const TString& codiva = m.get(102); - if (_codiva != codiva) - { - _codiva = codiva; - TCodiceIVA c(_codiva); - _percent = c.percentuale(); - } - - return _percent; -} - -real TPrimanota_application::scorpora(real& imponibile, const real& percent) -{ - real imposta = abs(imponibile) * percent / (percent + 100.0); imposta.ceil(); - if (imponibile.sign() < 0) imposta = -imposta; - imponibile -= imposta; - return imposta; -} - -real TPrimanota_application::totale_documento() -{ - const TMask& m = mask(); - - const bool swapt = test_swap(FALSE); // Totale invertito ? - const bool swaps = test_swap(TRUE); // Ritenute sociali invertite ? - - real tot(m.get(F_TOTALE)); - const real ritfis(m.get(F_RITFIS)); - tot += ritfis; - - real ritsoc(m.get(F_RITSOC)); - if (swapt ^ swaps) - ritsoc = -ritsoc; - - tot += ritsoc; - return tot; -} - -// Determina se un codice sospeso o no -// Certified 90% -bool TPrimanota_application::suspended_handler(TMask_field& f, KEY k) -{ - if (f.to_check(k)) - { - CHECKD(f.is_edit(), "Can't check suspension of a non edit-field ", f.dlg()); - const TEdit_field& c = (const TEdit_field&)f; - const TBrowse* b = c.browse(); - CHECKD(b, "Can't check suspension of a edit-field without a USE ", f.dlg()); - const TLocalisamfile* i = b->cursor()->file(); - - const char* sf = i->tab() ? "B2" : "SOSPESO"; - const bool suspended = i->get_bool(sf); - if (suspended) - { - sf = f.get(); - return f.error_box("Il codice '%s' e' sospeso e non puo' essere utilizzato", sf); - } - } - return TRUE; -} - - -// Determina se un codice detrazione e' di tipo detraibile o no -// Certified 70% -bool TPrimanota_application::detraibile(int tipodet) -{ - if (tipodet) - return FALSE; - if (app().iva() != iva_acquisti) - return TRUE; - - TString16 chiave; - chiave << app().mask().get(F_ANNOIVA) << app().causale().reg().attivita(); - - TTable pla("PLA"); - pla.put("CODTAB", chiave); - const int err = pla.read(); - real prorata; - if (err == NOERR) - prorata = pla.get_real("R8"); - - return prorata != 100.0; -} - -/////////////////////////////////////////////////////////// -// Funzioni di ricerca -/////////////////////////////////////////////////////////// - -int TPrimanota_application::type2pos(char tipo) -{ - TSheet_field& cg = app().cgs(); - for (int i = 0; i < cg.items(); i++) - { - TToken_string& s = cg.row(i); - if (s[s.len()-1] == tipo) - return i; - } - return -1; -} - - -int TPrimanota_application::bill2pos(const TConto& conto, char tipo) -{ - TSheet_field& cg = app().cgs(); - for (int i = 0; i < cg.items(); i++) - { - TToken_string& s = cg.row(i); - if (s[s.len()-1] == tipo) - { - const TConto c(s, 3, 0x0); - if (c == conto) - return i; - } - } - return -1; -} - - -int TPrimanota_application::bill2contr(const TConto& conto, char sezione) const -{ - const TArray& rows = cgs().rows_array(); - for (int i = 0; i < rows.items(); i++) - { - TToken_string& row = (TToken_string&)rows[i]; - const char sez = row.get(0)[0] > ' ' ? 'D' : 'A'; - if (sez == sezione) // Devo cercare sezione contraria - continue; - const TConto c(row, 3, 0x0); - if (conto == c) - return i; - } - return -1; -} - - -// Controlla se un conto e' usato nelle righe IVA -int TPrimanota_application::bill_used(const TConto& conto) const -{ - int users = 0; - - const TArray& rows = ivas().rows_array(); - for (int i = 0; i < rows.items(); i++) - { - TToken_string& row = (TToken_string&)rows[i]; - if (!row.empty_items()) - { - const TConto c(row, 6, 0x0); - if (conto == c) users++; - } - } - - return users; -} - - -int TPrimanota_application::det_used(char det) const -{ - int users = 0; - - const bool detraib = det == 'D'; - const TArray& rows = ivas().rows_array(); - for (int i = 0; i < rows.items(); i++) - { - TToken_string& row = (TToken_string&)rows[i]; - if (!row.empty_items()) - { - const bool d = detraibile(row.get_int(4)); - if (detraib == d) users++; - } - } - - return users; -} - - -/////////////////////////////////////////////////////////// -// Gestione sheet CG -/////////////////////////////////////////////////////////// - -TMask& TPrimanota_application::mask() const -{ - TipoIVA i = app().iva(); - return *_msk[i == nessuna_iva ? 1 : 2]; -} - - -TSheet_field& TPrimanota_application::cgs() const -{ - TSheet_field& s = (TSheet_field&)mask().field(F_SHEETCG); - return s; -} - - -// Certified 99% -// Scrive l'importo imp nella opportuna sezione della riga n -void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp) -{ - imp.add_to(cgs().row(n)); - cgs().force_update(n); -} - -// Legge l'importo della riga n e lo ritorna col segno dovuto -// Certified 99% -TImporto TPrimanota_application::get_cgs_imp(int n) -{ - TImporto importo; - importo = cgs().row(n); - return importo; -} - -// Certified 90% -void TPrimanota_application::add_cgs_imp(int n, const TImporto& imp) -{ - TImporto tot(get_cgs_imp(n)); - tot.set(imp.sezione(), tot.valore() + imp.valore()); - set_cgs_imp(n, tot); -} - -// Certified 90% -void TPrimanota_application::sub_cgs_imp(int n, const real& imp) -{ - TImporto tot(get_cgs_imp(n)); - tot.set(tot.sezione(), tot.valore() - imp); - set_cgs_imp(n, tot); -} - - -TImporto TPrimanota_application::real2imp(const real& r, char row_type) -{ - bool dare; - if (row_type == 'S') - { - dare = causale().sezione_ritsoc() == 'D'; - } - else - { - dare = causale().sezione_clifo() == 'D'; - if (row_type != 'T' && row_type != 'F') dare = !dare; - } - - TImporto importo(dare ? 'D' : 'A', r); - return importo; -} - -// Disabilita le celle della riga contabile n in base al suo tipo -void TPrimanota_application::disable_cgs_cells(int n, char tipo) -{ - int last; - switch(tipo) - { - case 'F': // Ritenute Fiscali - case 'S': // Ritenute Sociali - case 'D': // IVA Detraibile - case 'N': - last = 3; // IVA Non detraibile - break; - case 'T': // Totale documento - case 'I': - last = 7; // Imponibile - break; - default : - last = 0; // Solo contabile - break; - } - - TSheet_field& cg = cgs(); - for (int i = 0; i < last; i++) - cg.disable_cell(n, i); - - if (tipo == 'T') - { - cg.enable_cell(n, 3); - cg.enable_cell(n, 4); - } -} - - -int TPrimanota_application::set_cgs_row(int n, const TImporto& imp, - TConto& conto, const char* desc, - char tipo) -{ - TSheet_field& cg = cgs(); - if (n < 0) n = cg.first_empty(); - TToken_string& row = cg.row(n); - row = ""; - imp.add_to(row); - row.add(conto.string(0x3)); - row.add(""); - row.add(desc); - - int pos = 0; - if (tipo == 'I' && (pos = type2pos('T')) >= 0) - { - TConto contro(cg.row(pos), 2, 0x3); - row.add(contro.string(0x3)); - } - else - { - row.add(" | | | | "); // Contropartita - } - row << '|' << tipo; - - disable_cgs_cells(n, tipo); - cg.force_update(n); - - return n; -} - - -HIDDEN int compare_rows(const TObject** o1, const TObject** o2) -{ - // Totale, Rit.Fisc., Rit.Soc., da riga IVA, riga contabile, IVA detr., IVA non detr. - static char* sort_order = "TFSI DN"; - - const TToken_string* r1 = (const TToken_string*)*o1; - const TToken_string* r2 = (const TToken_string*)*o2; - const char c1 = r1->right(1)[0]; - const char c2 = r2->right(1)[0]; - return int(strchr(sort_order, c1) - strchr(sort_order, c2)); -} - - -void TPrimanota_application::cgs_pack() -{ - TArray& rows = cgs().rows_array(); - - const int max = rows.items(); - for (int i = 0; i < max; i++) - { - TToken_string& r = (TToken_string&)rows[i]; - bool del = FALSE; - if (r.empty_items()) // Remove all empty strings - del = TRUE; - else - { - const TImporto& imp = get_cgs_imp(i); - if (imp.valore() == ZERO) - del = TRUE; - } - if (del) - rows.destroy(i, FALSE); - } - - rows.sort(compare_rows); // Pack and sort array -} - - -real TPrimanota_application::calcola_saldo() const -{ - TArray& rows = cgs().rows_array(); - const int max = rows.items(); - - real tdare, tavere; - for (int i = 0; i < max; i++) - { - TToken_string& r = (TToken_string&)rows[i]; - tdare += real(r.get(0)); - tavere += real(r.get()); - } - - real sbilancio = abs(tdare)-abs(tavere); - switch (sbilancio.sign()) - { - case 1: - mask().set(F_DARE, (tdare-tavere).string()); - mask().reset(F_AVERE); - break; - case -1: - mask().reset(F_DARE); - mask().set(F_AVERE, (tavere-tdare).string()); - break; - default: - mask().reset(F_DARE); - mask().reset(F_AVERE); - break; - } - - return sbilancio; -} - - -// Handler dello sheet di contabilita' -// Certified 90% -bool TPrimanota_application::cg_handler(TMask_field& f, KEY k) -{ - if ((k == K_TAB && !f.mask().is_running()) || k == K_ENTER) - { - TSheet_field& cg = app().cgs(); - const real saldo = app().calcola_saldo(); - - if (k == K_ENTER) - { - if (saldo != ZERO) - { - const char* ss = saldo.string("."); - return f.error_box("Il movimento e' sbilanciato di %s lire.", ss); - } - else - if (app().get_cgs_imp(0).valore() == ZERO) - return f.error_box("Il movimento non ha una prima riga contabile valida!"); - } - } - return TRUE; -} - - -bool TPrimanota_application::cg_notify(int r, KEY k) -{ - TSheet_field& cg = app().cgs(); - TToken_string& row = cg.row(r); - const char tipo = row.empty() ? ' ' : row.right(1)[0]; - - switch(k) - { - case K_SPACE: - cg.sheet_mask().enable(DLG_DELREC, tipo == ' '); - break; - case K_ENTER: - if (r == 0 && app().iva() == nessuna_iva && cg.row(1).empty_items()) - { - TImporto i; i = row; i.swap_section(); - TConto contro(row, 9, 0x3); - app().set_cgs_row(1, i, contro, "", ' '); - TConto conto(row, 2, 0x3); - conto.add_to(cg.row(1), 9, 0x3); - app().cgs().force_update(1); - } - app().calcola_saldo(); - break; - case K_DEL: - if (tipo != ' ') - return error_box("La riga %d non puo' essere cancellata", r+1); - break; - default: - break; - } - return TRUE; -} - -bool TPrimanota_application::descr_handler(TMask_field& f, KEY k) -{ - if (k == K_ENTER && f.get().empty()) - { - if (f.mask().get(F_CODCAUS).empty()) - return error_box("Descrizione documento necessaria in mancanza della causale"); - } - return TRUE; -} - - -// Handler per le colonne 'Dare' e 'Avere' dello sheet contabile. -// Scrivendo qualcosa in dare (101) cancella l'importo in avere (102) e viceversa -bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k) -{ - if (k == K_TAB && f.focusdirty() && !f.get().empty()) - { - const int id = 203-f.dlg(); // Calcola id del campo da resettare - f.mask().reset(id); - } - return TRUE; -} - -/////////////////////////////////////////////////////////// -// Gestione sheet IVA -/////////////////////////////////////////////////////////// - -TSheet_field& TPrimanota_application::ivas() const -{ - TSheet_field& s = (TSheet_field&)_msk[2]->field(F_SHEETIVA); - return s; -} - - -void TPrimanota_application::set_ivas_row(int nriga, const char* codiva, TConto& tc, - const char* desc) -{ - TToken_string& riga = ivas().row(nriga); - riga = " "; // Importo - riga.add (codiva); // codiva - riga.add (" | "); // Det - Imposta - riga.add(tc.string(0x7)); // Conto - riga.add(desc); // Descrizione -} - - -bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB && f.dirty()) - { - TString16 iva(f.mask().get(102)); - if (iva.empty()) - { - iva = app().mask().get(F_CODIVA); - f.mask().set(102, iva); - } - if (iva.not_empty()) // Se c'e' il codice IVA - { - const real& percent = cod2IVA(f.mask()); - const real imponibile(f.get()); - real imposta = abs(imponibile) * percent / 100.0; imposta.ceil(); - if (imponibile.sign() < 0) imposta = -imposta; - f.mask().set(104, imposta.string()); - } - } - - return TRUE; -} - - -bool TPrimanota_application::codiva_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB && f.dirty()) - { - TMask_field& i = f.mask().field(101); - i.set_dirty(); - return imponibile_handler(i, key); - } else - if (key == K_ENTER) - { - if (f.get().empty() && f.mask().get(101).not_empty()) - return f.error_box("Codice IVA obbligatorio"); - } - return TRUE; -} - - -bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) -{ - if (key == K_ENTER) - { - const real imponibile(f.mask().get(101)); - const real& percent = cod2IVA(f.mask()); - real imposta = abs(imponibile) * percent / 100.0; - imposta.ceil(); - if (imponibile < ZERO) imposta = -imposta; - - const real val(f.get()); - if (val != imposta) - { - if (val != 0.0 || !app().causale().corrispettivi()) - { - const TString16 wrong(val.string(".")); - const TString16 right(imposta.string(".")); - f.warning_box("Imposta di '%s' errata: dovrebbe essere '%s'", - (const char*)wrong, (const char*)right); - } - } - } else - if (key == K_F8 && f.get().empty()) - { - real imponibile(f.mask().get(101)); - const real& percent = cod2IVA(f.mask()); - const real imposta = scorpora(imponibile, percent); - f.mask().set(101, imponibile.string()); - f.set(imposta.string()); - } - - return TRUE; -} - - -real TPrimanota_application::calcola_imp() const -{ - TArray& rows = ivas().rows_array(); - const int max = rows.items(); - - real imponibili, imposte; - for (int r = 0; r < max; r++) - { - TToken_string& row = (TToken_string&)rows[r]; - imponibili += real(row.get(0)); - imposte += real(row.get(3)); - } - - mask().set(F_IMPONIBILI, imponibili.string()); - mask().set(F_IMPOSTE, imposte.string()); - - return imponibili+imposte; -} - -// Certified 50% -bool TPrimanota_application::iva_notify(int r, KEY k) -{ - static int oldpos,oldposiva; - static real oldimp, oldiva; - - TSheet_field& iva = app().ivas(); - TToken_string& row = iva.row(r); - - if (k == K_SPACE) - { - oldimp = real(row.get(0)); // Imponibile 0 - oldiva = real(row.get(3)); // Imposta 3 - - const char tipod = detraibile(row.get_int()) ? 'D' : 'N'; - oldposiva = type2pos(tipod); // Tipodet 4 - if (oldposiva < 0 && oldiva != ZERO) - { - TConto c; app().causale().bill(tipod == 'D' ? 3 : 4, c); - oldposiva = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, "", tipod); - } - - TConto oldconto(row, 5, 0x1); // t/g/c/s 5 6 7 8 - oldpos = bill2pos(oldconto, 'I'); - if (oldpos < 0 && oldconto.ok()) - oldpos = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), oldconto, "", 'I'); - } - if (k == K_DEL) - { - row.add("0", 0); // Azzera imponibile - row.add("0", 3); // Azzera imposta - k = K_ENTER; // Elegante o Sporco trucco (dipende dai gusti!) - } - if (k == K_ENTER) - { - if (oldpos >= 0) // Il conto esisteva anche prima - { - app().sub_cgs_imp(oldpos, oldimp); - } - if (oldposiva >= 0) // Il conto IVA esisteva anche prima - { - app().sub_cgs_imp(oldposiva, oldiva); - } - - // Aggiorna conto sulla riga contabile - real imp(row.get(0)); // Imponibile - TConto conto(row, 5, 0x3); - const int newpos = bill2pos(conto, 'I'); - - if (newpos < 0) - { - const TImporto val(app().real2imp(imp, 'I')); - if (val.valore() != ZERO) - app().set_cgs_row(-1, val, conto, "", 'I'); - } - else - { - const TImporto val(app().real2imp(imp, 'I')); - app().add_cgs_imp(newpos, val); - } - oldimp = imp; - oldpos = newpos; - - // Aggiorna conto IVA sulla riga contabile - - imp = real(row.get(3)); // Imposta - const bool detrarre = detraibile(row.get_int()); // Determina se IVA detraibile - app().causale().bill(detrarre ? 3 : 4, conto); - const char tipod = detrarre ? 'D' : 'N'; - const int newposiva = type2pos(tipod); - - if (newposiva < 0) - { - const TImporto val(app().real2imp(imp, 'I')); - if (val.valore() != ZERO) - app().set_cgs_row(-1, val, conto, "", tipod); - } - else - { - const TImporto val(app().real2imp(imp, 'I')); - app().add_cgs_imp(newposiva, val); - } - oldiva = imp; - oldposiva = newposiva; - - app().calcola_imp(); - app().calcola_saldo(); - } - return TRUE; -} - - -// Handler dello sheet di contabilita' -// Certified 90% -bool TPrimanota_application::iva_handler(TMask_field& f, KEY k) -{ - if ((k == K_TAB && !f.mask().is_running()) || k == K_ENTER) - { - const real imp = app().calcola_imp(); - const real tot = app().totale_documento(); - if (k == K_ENTER) - { - if (imp != tot) - { - TString16 t(tot.string(".")); - TString16 i(imp.string(".")); - return error_box("La somma del totale documento e delle ritenute (%s) e' diverso dalla " - "somma degli imponibili e delle imposte (%s)", (const char*)t, (const char*)i); - } - } - } - return TRUE; -} - - -/////////////////////////////////////////////////////////// -// Handlers dei campi della testata -/////////////////////////////////////////////////////////// - - -// Handler of the F_NUMREG field on the query mask -// Certified 90% -bool TPrimanota_application::num_handler(TMask_field& f, KEY key) -{ - if (!f.mask().is_running()) return TRUE; - - if (key == K_TAB && f.get().not_empty()) - { - if (app().find(1)) - dispatch_e_char(f.parent(), K_AUTO_ENTER); - } - return TRUE; -} - - -// Handler of the F_CODCAUS field on the query mask -// Certified 99% -bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key) -{ - if (!f.mask().is_running()) return TRUE; - - if (key == K_TAB && f.focusdirty()) - { - const int ann = f.mask().get_int(F_ANNOIVA); - const char* cau = f.get(); - - const TipoIVA i = cau2IVA(cau, ann); // Cerca causale e suo tipo - if (i != iva_errata) - { - const bool ok = suspended_handler(f, key); // Controlla sospensione - if (ok) - f.mask().stop_run(K_INS); // Entra in modo inserimento - } - else return FALSE; - } - - return TRUE; -} - -// Handler of the F_CODCAUS field on the modify mask -// Certified 99% -bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key) -{ - if (f.to_check(key)) - { - bool ok = suspended_handler(f, key); - if (!ok) return FALSE; - - const int ann = f.mask().get_int(F_ANNOIVA); - const char* cau = f.get(); - TCausale c(cau, ann); - if (!c.ok()) return FALSE; - - - ok = app().causale().similar(c); - if (!ok) - { - f.error_box("Causale incongruente con quella precedentemente inserita"); - return FALSE; - } - app().read_caus(cau, ann); - } - - return TRUE; -} - - -// Handler of the F_DATAREG field -// Certified 70% -bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key) -{ - bool ok = TRUE; - - if ((key == K_TAB && f.focusdirty()) || key == K_ENTER) - { - const TDate dr(f.get()); // Data dell'operazione - if (dr > TDate(TODAY)) - return f.error_box("La data dell'operazione e' superiore quella di sistema"); - - TMask& m = f.mask(); - - const int ae = date2esc(dr); // Anno esercizio - if (ae == 0) - return f.error_box("La data dell'operazione non appartiene a nessun esercizio"); - - if (m.query_mode() || app().giornale().year() != ae) - ok = app().giornale().read(ae); - else - ok = TRUE; - - if (!ok) - return f.error_box("Non esiste il libro giornale dell'esercizio %d", ae); - - if (f.dirty() || f.mask().query_mode()) - { - const TLibro_giornale& gio = app().giornale(); - if (dr <= gio.last_print()) - return f.error_box("La data dell'operazione e' antecedente al %s, ultima stampa\n" - "del libro giornale dell'esercizio %d", gio.last_reg().string(), ae); - if (dr < gio.last_reg()) - warning_box("La data dell'operazione e' antecedente al %s, ultima registrazione\n" - "sul libro giornale dell'esercizio %d", - gio.last_reg().string(), ae); - - if (m.query_mode()) - app().read_caus(m.get(F_CODCAUS), dr.year()); - - TRegistro& reg = app().causale().reg(); - const TString16 codreg(reg.name()); - if (codreg.not_empty()) - { - - if (reg.year() != dr.year()) - { - const bool ok = reg.read(codreg, dr.year()); - if (!ok) return FALSE; - } - - if (dr <= reg.last_print()) - return error_box("La data dell'operazione e' antecedente al %s, ultima\n" - "data di stampa del registro '%s' dell'anno %d", - reg.last_print().string(), (const char*)codreg, dr.year()); - if (dr < reg.last_reg()) - warning_box("La data dell'operazione e' antecedente al %s, ultima registrazione\n" - "sul registro '%s' dell'anno %d", - reg.last_reg().string(), (const char*)codreg, dr.year()); - } - } - } - return ok; -} - -// Handler of the F_DATACOMP field on the modify mask -// Certified 90% -bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key) -{ - if (!f.to_check(key, TRUE)) - return TRUE; - - const TDate dc(f.get()); // Data di competenza - const int ae = date2esc(dc); // Esercizio corrispondente - TMask& m = f.mask(); - - if (ae) - { - const char* data = ""; - if (f.dlg() == F_DATACOMP) - { - m.set(F_ANNOES, ae); - data = "di competenza"; - } - else - data = "del 74/ter"; - - const TDate dr(m.get(F_DATAREG)); // Data operazione - int pr; // Esercizio precedente - const int ar = date2esc(dr, &pr); // Esercizio in corso - if (ae != ar && ae != pr) - { - TString80 e; - e << "La data " << data << " deve appartenere all'esercizio " << ar; - if (pr > 0) e << " o al " << pr; - return f.error_box(e); - } - } - else - return f.error_box("La data non appartiene a nessun esercizio"); - - return TRUE; -} - -// Handler of the F_DATA74TER field on the modify mask -// Certified 90% -bool TPrimanota_application::data74ter_handler(TMask_field& f, KEY key) -{ - if (!f.to_check(key)) return TRUE; - bool ok = datacomp_handler(f, key); - if (ok) - { - const TDate d74(f.get()); - const TLibro_giornale& g = app().giornale(); - if (d74 < g.last_print()) - { - ok = f.error_box("La data per il 74/ter e' antecedente alla data di stampa " - "del libro giornale dell'esercizio %d", g.year()); - } - } - return ok; -} - -// Handler of the F_CODREG field on the modify mask -// Certified 99% -bool TPrimanota_application::reg_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB) - { - TRegistro& reg = app().causale().reg(); - const bool av = reg.agenzia_viaggi(); - f.mask().show(F_DATA74TER, av); - if (!av) f.mask().reset(F_DATA74TER); - } - return TRUE; -} - -bool TPrimanota_application::occas_code_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB) - { - const char* code = f.get(); - if (*code) - { - TRelation occas(LF_OCCAS); - occas.lfile()->put("CFPI", code); - if (occas.read() == NOERR) - { - f.mask().autoload(&occas); - f.mask().send_key(K_TAB, O_COMUNE); // Forza decodifica comuni - f.mask().send_key(K_TAB, O_COMUNENAS); - } - } - } else - if (key == K_ENTER) - { - const TFixed_string codice(f.get()); - if (codice.not_empty()) - app().mask().set(app().iva() == iva_vendite ? F_PIVACLIENTE : F_PIVAFORNITORE, codice); - else - return f.error_box("Il codice e' obbligatorio"); - } - return TRUE; -} - -bool TPrimanota_application::occas_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE && f.mask().is_running()) - { - TMask& om = app().occas_mask(); - om.run(); - f.set_focus(); - } - return TRUE; -} - -// Crea o aggiorna la riga contabile col totale documento -// Certified 99% -void TPrimanota_application::add_cgs_tot(TMask& m) -{ - // Lettura del conto dalla maschera - char tipo = m.get(F_CLIFO)[0]; - int gruppo = m.get_int(F_GRUPPOCLIFO); - int conto = m.get_int(F_CONTOCLIFO); - long codice = m.get_long(tipo == 'C' ? F_CLIENTE : F_FORNITORE); - - // Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale - if (conto == 0) - { - TConto bill; _causale.bill(1, bill); - gruppo = bill.gruppo(); m.set(F_GRUPPOCLIFO, gruppo); - conto = bill.conto(); m.set(F_CONTOCLIFO, conto); - } - - if (tipo == 'C' && causale().corrispettivi()) - tipo = ' '; - TConto c(gruppo, conto, codice, tipo); - real tot(m.get(F_TOTALE)); - - // Creazione/Aggiornamento riga totale - const int pos = type2pos('T'); - set_cgs_row(pos, real2imp(tot, 'T'), c, "Totale documento", 'T'); - calcola_saldo(); -} - - -// Handler of the F_CLIENTE & F_FORNITORE field on the modify mask -// Certified 99% -bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) -{ - if (!suspended_handler(f, key)) - return FALSE; - - if (key == K_TAB && f.focusdirty()) - { - app().add_cgs_tot(f.mask()); - TLocalisamfile clifo(LF_CLIFO); - const int alleg = clifo.get_int("ALLEG"); - TEdit_field& upi = (TEdit_field&)f.mask().field(F_RIEPILOGO); - upi.check_type(alleg == 3 ? CHECK_REQUIRED : CHECK_NORMAL); - } - return TRUE; -} - - -// Handler of the F_CODIVA -// Certified 99% -bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB && f.focusdirty() && f.get().not_empty()) - { - TToken_string& row = app().ivas().row(0); - const real imp(row.get(0)); - if (imp == ZERO) - { - iva_notify(0, K_SPACE); - - const TCodiceIVA iva(f.get()); - real tot = app().totale_documento(); - - real imposta; - if (!app().causale().corrispettivi()) - imposta = app().scorpora(tot, iva.percentuale()); - - row.add(tot.string(), 0); // imponibile - row.add(iva.codice(), 1); // codice IVA - row.add(imposta.string(), 3); // imposta - - TConto bill; // Conto della prima riga IVA - const TString& tipo = iva.tipo(); - if (tipo.not_empty()) - { - if (tipo == "ES") app().causale().bill(5, bill); else - if (tipo == "NI") app().causale().bill(6, bill); else - if (tipo == "NS") app().causale().bill(7, bill); - } - if (!bill.ok() && !app().causale().corrispettivi()) - { - const TMask& m = f.mask(); - bill.set(m.get_int(F_GRUPPORIC), m.get_int(F_CONTORIC), m.get_long(F_SOTTOCONTORIC)); - } - if (!bill.ok()) - app().causale().bill(2, bill); - row.add(bill.tipo(), 5); - row.add(bill.gruppo(), 6); - row.add(bill.conto(), 7); - row.add(bill.sottoconto(), 8); - row.add(bill.descrizione(), 9); - - app().ivas().force_update(0); - iva_notify(0, K_ENTER); - } - } - return TRUE; -} - -// Handler of the F_TOTALE -// Certified 99% -bool TPrimanota_application::totale_handler(TMask_field& f, KEY key) -{ - bool ok = TRUE; - if (key == K_TAB && f.focusdirty()) - app().add_cgs_tot(f.mask()); - - if (key == K_ENTER && f.get().empty()) - ok = f.yesno_box("Totale documento nullo: continuare ugualmente?"); - return ok; -} - - -void TPrimanota_application::add_cgs_rit(bool fiscali) -{ - const real imp(_msk[2]->get(fiscali ? F_RITFIS : F_RITSOC)); - - const char tipo = fiscali ? 'F' : 'S'; - int pos = type2pos(tipo); - if (pos < 0) - { - const int riga = fiscali ? 8 : 9; - TConto conto; _causale.bill(riga, conto); - - TString80 desc("Ritenute "); - desc << (fiscali ? "fiscali" : "sociali"); - - set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo); - } - else - set_cgs_imp(pos, real2imp(imp, tipo)); -} - - -// Handler of the F_RITFIS -// Certified 99% -bool TPrimanota_application::ritfis_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB && f.focusdirty()) - app().add_cgs_rit(TRUE); - return TRUE; -} - - -// Handler of F_RITSOC -// Certified 99% -bool TPrimanota_application::ritsoc_handler(TMask_field& f, KEY key) -{ - if (key == K_TAB && f.focusdirty()) - app().add_cgs_rit(FALSE); - return TRUE; -} - - -// Handler of F_VISVAL -// Certified 90% -bool TPrimanota_application::visval_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - { - TMask& m = f.mask(); - const real e(f.get() == "X" ? m.get(F_CAMBIO) : "1"); - m.set_exchange(e); - } - return TRUE; -} - - -bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - { - TMask& m = f.mask(); - const bool anchecg = !m.get_bool(F_SOLAIVA); - - app().cgs().show(anchecg); - - if (m.is_running() && anchecg) - { - TSheet_field& iva = app().ivas(); - const int righe = iva.items(); - TProgind pi(righe, "Generazione righe contabilita'", FALSE, TRUE, 16); - - app().cgs().reset(); - app().add_cgs_tot(m); - if (m.get(F_RITFIS).not_empty()) app().add_cgs_rit(TRUE); - if (m.get(F_RITSOC).not_empty()) app().add_cgs_rit(FALSE); - - TToken_string oldrow(128); - for (int i = 0; i < righe; i++) - { - TToken_string& r = iva.row(i); - if (!r.empty_items()) - { - oldrow = r; - r = ""; - iva_notify(i, K_SPACE); - r = oldrow; - iva_notify(i, K_ENTER); - } - pi.setstatus(i+1); - } - app().fill_sheet(m); - app().cgs().force_update(); - } - } - return TRUE; -} - - +#include +#include +#include +#include + +#include "cg2100.h" +#include "cg2102.h" + + +// Certified 100% +inline TPrimanota_application& app() +{ return (TPrimanota_application&)main_app(); } + +/////////////////////////////////////////////////////////// +// Funzioni di decodifica/calcolo +/////////////////////////////////////////////////////////// + +// Determina il tipo IVA da causale+anno +// Certified 100% +TipoIVA TPrimanota_application::cau2IVA(const char* causale, int annoiva) +{ + TipoIVA i = iva_errata; + + if (*causale > ' ') + { + TCausale c; + if (c.read(causale, annoiva)) + i = c.iva(); + else + error_box("Causale errata: '%s'", causale); + } else i = nessuna_iva; + + return i; +} + +// Calcolo della percentuale di un dato codice IVA +// Certified 99% +const real& TPrimanota_application::cod2IVA(const TMask& m) +{ + static TString16 _codiva; + static real _percent; + + const TString& codiva = m.get(102); + if (_codiva != codiva) + { + _codiva = codiva; + TCodiceIVA c(_codiva); + _percent = c.percentuale(); + } + + return _percent; +} + +real TPrimanota_application::scorpora(real& imponibile, const real& percent) +{ + real imposta = abs(imponibile) * percent / (percent + 100.0); imposta.ceil(); + if (imponibile.sign() < 0) imposta = -imposta; + imponibile -= imposta; + return imposta; +} + +real TPrimanota_application::totale_documento() +{ + const TMask& m = mask(); + + const bool swapt = test_swap(FALSE); // Totale invertito ? + const bool swaps = test_swap(TRUE); // Ritenute sociali invertite ? + + real tot(m.get(F_TOTALE)); + const real ritfis(m.get(F_RITFIS)); + tot += ritfis; + + real ritsoc(m.get(F_RITSOC)); + if (swapt ^ swaps) + ritsoc = -ritsoc; + + tot += ritsoc; + return tot; +} + +// Determina se un codice sospeso o no +// Certified 90% +bool TPrimanota_application::suspended_handler(TMask_field& f, KEY k) +{ + if (f.to_check(k)) + { + CHECKD(f.is_edit(), "Can't check suspension of a non edit-field ", f.dlg()); + const TEdit_field& c = (const TEdit_field&)f; + const TBrowse* b = c.browse(); + CHECKD(b, "Can't check suspension of a edit-field without a USE ", f.dlg()); + const TLocalisamfile* i = b->cursor()->file(); + + const char* sf = i->tab() ? "B2" : "SOSPESO"; + const bool suspended = i->get_bool(sf); + if (suspended) + { + sf = f.get(); + return f.error_box("Il codice '%s' e' sospeso e non puo' essere utilizzato", sf); + } + } + return TRUE; +} + + +// Determina se un codice detrazione e' di tipo detraibile o no +// Certified 70% +bool TPrimanota_application::detraibile(int tipodet) +{ + if (tipodet) + return FALSE; + if (app().iva() != iva_acquisti) + return TRUE; + + TString16 chiave; + chiave << app().mask().get(F_ANNOIVA) << app().causale().reg().attivita(); + + TTable pla("PLA"); + pla.put("CODTAB", chiave); + const int err = pla.read(); + real prorata; + if (err == NOERR) + prorata = pla.get_real("R8"); + + return prorata != 100.0; +} + +/////////////////////////////////////////////////////////// +// Funzioni di ricerca +/////////////////////////////////////////////////////////// + +int TPrimanota_application::type2pos(char tipo) +{ + TSheet_field& cg = app().cgs(); + for (int i = 0; i < cg.items(); i++) + { + TToken_string& s = cg.row(i); + if (s[s.len()-1] == tipo) + return i; + } + return -1; +} + + +int TPrimanota_application::bill2pos(const TConto& conto, char tipo) +{ + TSheet_field& cg = app().cgs(); + for (int i = 0; i < cg.items(); i++) + { + TToken_string& s = cg.row(i); + if (s[s.len()-1] == tipo) + { + const TConto c(s, 3, 0x0); + if (c == conto) + return i; + } + } + return -1; +} + + +int TPrimanota_application::bill2contr(const TConto& conto, char sezione) const +{ + const TArray& rows = cgs().rows_array(); + for (int i = 0; i < rows.items(); i++) + { + TToken_string& row = (TToken_string&)rows[i]; + const char sez = row.get(0)[0] > ' ' ? 'D' : 'A'; + if (sez == sezione) // Devo cercare sezione contraria + continue; + const TConto c(row, 3, 0x0); + if (conto == c) + return i; + } + return -1; +} + + +// Controlla se un conto e' usato nelle righe IVA +int TPrimanota_application::bill_used(const TConto& conto) const +{ + int users = 0; + + const TArray& rows = ivas().rows_array(); + for (int i = 0; i < rows.items(); i++) + { + TToken_string& row = (TToken_string&)rows[i]; + if (!row.empty_items()) + { + const TConto c(row, 6, 0x0); + if (conto == c) users++; + } + } + + return users; +} + + +int TPrimanota_application::det_used(char det) const +{ + int users = 0; + + const bool detraib = det == 'D'; + const TArray& rows = ivas().rows_array(); + for (int i = 0; i < rows.items(); i++) + { + TToken_string& row = (TToken_string&)rows[i]; + if (!row.empty_items()) + { + const bool d = detraibile(row.get_int(4)); + if (detraib == d) users++; + } + } + + return users; +} + + +/////////////////////////////////////////////////////////// +// Gestione sheet CG +/////////////////////////////////////////////////////////// + +TMask& TPrimanota_application::mask() const +{ + TipoIVA i = app().iva(); + return *_msk[i == nessuna_iva ? 1 : 2]; +} + + +TSheet_field& TPrimanota_application::cgs() const +{ + TSheet_field& s = (TSheet_field&)mask().field(F_SHEETCG); + return s; +} + + +// Certified 99% +// Scrive l'importo imp nella opportuna sezione della riga n +void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp) +{ + imp.add_to(cgs().row(n)); + cgs().force_update(n); +} + +// Legge l'importo della riga n e lo ritorna col segno dovuto +// Certified 99% +TImporto TPrimanota_application::get_cgs_imp(int n) +{ + TImporto importo; + importo = cgs().row(n); + return importo; +} + +// Certified 90% +void TPrimanota_application::add_cgs_imp(int n, const TImporto& imp) +{ + TImporto tot(get_cgs_imp(n)); + tot.set(imp.sezione(), tot.valore() + imp.valore()); + set_cgs_imp(n, tot); +} + +// Certified 90% +void TPrimanota_application::sub_cgs_imp(int n, const real& imp) +{ + TImporto tot(get_cgs_imp(n)); + tot.set(tot.sezione(), tot.valore() - imp); + set_cgs_imp(n, tot); +} + + +TImporto TPrimanota_application::real2imp(const real& r, char row_type) +{ + bool dare; + if (row_type == 'S') + { + dare = causale().sezione_ritsoc() == 'D'; + } + else + { + dare = causale().sezione_clifo() == 'D'; + if (row_type != 'T' && row_type != 'F') dare = !dare; + } + + TImporto importo(dare ? 'D' : 'A', r); + return importo; +} + +// Disabilita le celle della riga contabile n in base al suo tipo +void TPrimanota_application::disable_cgs_cells(int n, char tipo) +{ + int last; + switch(tipo) + { + case 'F': // Ritenute Fiscali + case 'S': // Ritenute Sociali + case 'D': // IVA Detraibile + case 'N': + last = 3; // IVA Non detraibile + break; + case 'T': // Totale documento + case 'I': + last = 7; // Imponibile + break; + default : + last = 0; // Solo contabile + break; + } + + TSheet_field& cg = cgs(); + for (int i = 0; i < last; i++) + cg.disable_cell(n, i); + + if (tipo == 'T') + { + cg.enable_cell(n, 3); + cg.enable_cell(n, 4); + } +} + + +int TPrimanota_application::set_cgs_row(int n, const TImporto& imp, + TConto& conto, const char* desc, + char tipo) +{ + TSheet_field& cg = cgs(); + if (n < 0) n = cg.first_empty(); + TToken_string& row = cg.row(n); + row = ""; + imp.add_to(row); + row.add(conto.string(0x3)); + row.add(""); + row.add(desc); + + int pos = 0; + if (tipo == 'I' && (pos = type2pos('T')) >= 0) + { + TConto contro(cg.row(pos), 2, 0x3); + row.add(contro.string(0x3)); + } + else + { + row.add(" | | | | "); // Contropartita + } + row << '|' << tipo; + + disable_cgs_cells(n, tipo); + cg.force_update(n); + + return n; +} + + +HIDDEN int compare_rows(const TObject** o1, const TObject** o2) +{ + // Totale, Rit.Fisc., Rit.Soc., da riga IVA, riga contabile, IVA detr., IVA non detr. + static char* sort_order = "TFSI DN"; + + const TToken_string* r1 = (const TToken_string*)*o1; + const TToken_string* r2 = (const TToken_string*)*o2; + const char c1 = r1->right(1)[0]; + const char c2 = r2->right(1)[0]; + return int(strchr(sort_order, c1) - strchr(sort_order, c2)); +} + + +void TPrimanota_application::cgs_pack() +{ + TArray& rows = cgs().rows_array(); + + const int max = rows.items(); + for (int i = 0; i < max; i++) + { + TToken_string& r = (TToken_string&)rows[i]; + bool del = FALSE; + if (r.empty_items()) // Remove all empty strings + del = TRUE; + else + { + const TImporto& imp = get_cgs_imp(i); + if (imp.valore() == ZERO) + del = TRUE; + } + if (del) + rows.destroy(i, FALSE); + } + + rows.sort(compare_rows); // Pack and sort array +} + + +real TPrimanota_application::calcola_saldo() const +{ + TArray& rows = cgs().rows_array(); + const int max = rows.items(); + + real tdare, tavere; + for (int i = 0; i < max; i++) + { + TToken_string& r = (TToken_string&)rows[i]; + tdare += real(r.get(0)); + tavere += real(r.get()); + } + + real sbilancio = abs(tdare)-abs(tavere); + switch (sbilancio.sign()) + { + case 1: + mask().set(F_DARE, (tdare-tavere).string()); + mask().reset(F_AVERE); + break; + case -1: + mask().reset(F_DARE); + mask().set(F_AVERE, (tavere-tdare).string()); + break; + default: + mask().reset(F_DARE); + mask().reset(F_AVERE); + break; + } + + return sbilancio; +} + + +// Handler dello sheet di contabilita' +// Certified 90% +bool TPrimanota_application::cg_handler(TMask_field& f, KEY k) +{ + if ((k == K_TAB && !f.mask().is_running()) || k == K_ENTER) + { + TSheet_field& cg = app().cgs(); + const real saldo = app().calcola_saldo(); + + if (k == K_ENTER) + { + if (saldo != ZERO) + { + const char* ss = saldo.string("."); + return f.error_box("Il movimento e' sbilanciato di %s lire.", ss); + } + else + if (app().get_cgs_imp(0).valore() == ZERO) + return f.error_box("Il movimento non ha una prima riga contabile valida!"); + } + } + return TRUE; +} + + +bool TPrimanota_application::cg_notify(int r, KEY k) +{ + TSheet_field& cg = app().cgs(); + TToken_string& row = cg.row(r); + const char tipo = row.empty() ? ' ' : row.right(1)[0]; + + switch(k) + { + case K_SPACE: + cg.sheet_mask().enable(DLG_DELREC, tipo == ' '); + break; + case K_ENTER: + if (r == 0 && app().iva() == nessuna_iva && cg.row(1).empty_items()) + { + TImporto i; i = row; i.swap_section(); + TConto contro(row, 9, 0x3); + app().set_cgs_row(1, i, contro, "", ' '); + TConto conto(row, 2, 0x3); + conto.add_to(cg.row(1), 9, 0x3); + app().cgs().force_update(1); + } + app().calcola_saldo(); + break; + case K_DEL: + if (tipo != ' ') + return error_box("La riga %d non puo' essere cancellata", r+1); + break; + default: + break; + } + return TRUE; +} + +bool TPrimanota_application::descr_handler(TMask_field& f, KEY k) +{ + if (k == K_ENTER && f.get().empty()) + { + if (f.mask().get(F_CODCAUS).empty()) + return error_box("Descrizione documento necessaria in mancanza della causale"); + } + return TRUE; +} + + +// Handler per le colonne 'Dare' e 'Avere' dello sheet contabile. +// Scrivendo qualcosa in dare (101) cancella l'importo in avere (102) e viceversa +bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k) +{ + if (k == K_TAB && f.focusdirty() && !f.get().empty()) + { + const int id = 203-f.dlg(); // Calcola id del campo da resettare + f.mask().reset(id); + } + return TRUE; +} + +/////////////////////////////////////////////////////////// +// Gestione sheet IVA +/////////////////////////////////////////////////////////// + +TSheet_field& TPrimanota_application::ivas() const +{ + TSheet_field& s = (TSheet_field&)_msk[2]->field(F_SHEETIVA); + return s; +} + + +void TPrimanota_application::set_ivas_row(int nriga, const char* codiva, TConto& tc, + const char* desc) +{ + TToken_string& riga = ivas().row(nriga); + riga = " "; // Importo + riga.add (codiva); // codiva + riga.add (" | "); // Det - Imposta + riga.add(tc.string(0x7)); // Conto + riga.add(desc); // Descrizione +} + + +bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.dirty()) + { + TString16 iva(f.mask().get(102)); + if (iva.empty()) + { + iva = app().mask().get(F_CODIVA); + f.mask().set(102, iva); + } + if (iva.not_empty()) // Se c'e' il codice IVA + { + const real& percent = cod2IVA(f.mask()); + const real imponibile(f.get()); + real imposta = abs(imponibile) * percent / 100.0; imposta.ceil(); + if (imponibile.sign() < 0) imposta = -imposta; + f.mask().set(104, imposta.string()); + } + } + + return TRUE; +} + + +bool TPrimanota_application::codiva_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.dirty()) + { + TMask_field& i = f.mask().field(101); + i.set_dirty(); + return imponibile_handler(i, key); + } else + if (key == K_ENTER) + { + if (f.get().empty() && f.mask().get(101).not_empty()) + return f.error_box("Codice IVA obbligatorio"); + } + return TRUE; +} + + +bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) +{ + if (key == K_ENTER) + { + const real imponibile(f.mask().get(101)); + const real& percent = cod2IVA(f.mask()); + real imposta = abs(imponibile) * percent / 100.0; + imposta.ceil(); + if (imponibile < ZERO) imposta = -imposta; + + const real val(f.get()); + if (val != imposta) + { + if (val != 0.0 || !app().causale().corrispettivi()) + { + const TString16 wrong(val.string(".")); + const TString16 right(imposta.string(".")); + f.warning_box("Imposta di '%s' errata: dovrebbe essere '%s'", + (const char*)wrong, (const char*)right); + } + } + } else + if (key == K_F8 && f.get().empty()) + { + real imponibile(f.mask().get(101)); + const real& percent = cod2IVA(f.mask()); + const real imposta = scorpora(imponibile, percent); + f.mask().set(101, imponibile.string()); + f.set(imposta.string()); + } + + return TRUE; +} + + +real TPrimanota_application::calcola_imp() const +{ + TArray& rows = ivas().rows_array(); + const int max = rows.items(); + + real imponibili, imposte; + for (int r = 0; r < max; r++) + { + TToken_string& row = (TToken_string&)rows[r]; + imponibili += real(row.get(0)); + imposte += real(row.get(3)); + } + + mask().set(F_IMPONIBILI, imponibili.string()); + mask().set(F_IMPOSTE, imposte.string()); + + return imponibili+imposte; +} + +// Certified 50% +bool TPrimanota_application::iva_notify(int r, KEY k) +{ + static int oldpos,oldposiva; + static real oldimp, oldiva; + + TSheet_field& iva = app().ivas(); + TToken_string& row = iva.row(r); + + if (k == K_SPACE) + { + oldimp = real(row.get(0)); // Imponibile 0 + oldiva = real(row.get(3)); // Imposta 3 + + const char tipod = detraibile(row.get_int()) ? 'D' : 'N'; + oldposiva = type2pos(tipod); // Tipodet 4 + if (oldposiva < 0 && oldiva != ZERO) + { + TConto c; app().causale().bill(tipod == 'D' ? 3 : 4, c); + oldposiva = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, "", tipod); + } + + TConto oldconto(row, 5, 0x1); // t/g/c/s 5 6 7 8 + oldpos = bill2pos(oldconto, 'I'); + if (oldpos < 0 && oldconto.ok()) + oldpos = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), oldconto, "", 'I'); + } + if (k == K_DEL) + { + row.add("0", 0); // Azzera imponibile + row.add("0", 3); // Azzera imposta + k = K_ENTER; // Elegante o Sporco trucco (dipende dai gusti!) + } + if (k == K_ENTER) + { + if (oldpos >= 0) // Il conto esisteva anche prima + { + app().sub_cgs_imp(oldpos, oldimp); + } + if (oldposiva >= 0) // Il conto IVA esisteva anche prima + { + app().sub_cgs_imp(oldposiva, oldiva); + } + + // Aggiorna conto sulla riga contabile + real imp(row.get(0)); // Imponibile + TConto conto(row, 5, 0x3); + const int newpos = bill2pos(conto, 'I'); + + if (newpos < 0) + { + const TImporto val(app().real2imp(imp, 'I')); + if (val.valore() != ZERO) + app().set_cgs_row(-1, val, conto, "", 'I'); + } + else + { + const TImporto val(app().real2imp(imp, 'I')); + app().add_cgs_imp(newpos, val); + } + oldimp = imp; + oldpos = newpos; + + // Aggiorna conto IVA sulla riga contabile + + imp = real(row.get(3)); // Imposta + const bool detrarre = detraibile(row.get_int()); // Determina se IVA detraibile + app().causale().bill(detrarre ? 3 : 4, conto); + const char tipod = detrarre ? 'D' : 'N'; + const int newposiva = type2pos(tipod); + + if (newposiva < 0) + { + const TImporto val(app().real2imp(imp, 'I')); + if (val.valore() != ZERO) + app().set_cgs_row(-1, val, conto, "", tipod); + } + else + { + const TImporto val(app().real2imp(imp, 'I')); + app().add_cgs_imp(newposiva, val); + } + oldiva = imp; + oldposiva = newposiva; + + app().calcola_imp(); + app().calcola_saldo(); + } + return TRUE; +} + + +// Handler dello sheet di contabilita' +// Certified 90% +bool TPrimanota_application::iva_handler(TMask_field& f, KEY k) +{ + if ((k == K_TAB && !f.mask().is_running()) || k == K_ENTER) + { + const real imp = app().calcola_imp(); + const real tot = app().totale_documento(); + if (k == K_ENTER) + { + if (imp != tot) + { + TString16 t(tot.string(".")); + TString16 i(imp.string(".")); + return error_box("La somma del totale documento e delle ritenute (%s) e' diverso dalla " + "somma degli imponibili e delle imposte (%s)", (const char*)t, (const char*)i); + } + } + } + return TRUE; +} + + +/////////////////////////////////////////////////////////// +// Handlers dei campi della testata +/////////////////////////////////////////////////////////// + + +// Handler of the F_NUMREG field on the query mask +// Certified 90% +bool TPrimanota_application::num_handler(TMask_field& f, KEY key) +{ + if (!f.mask().is_running()) return TRUE; + + if (key == K_TAB && f.get().not_empty()) + { + if (app().find(1)) + dispatch_e_char(f.parent(), K_AUTO_ENTER); + } + return TRUE; +} + + +// Handler of the F_CODCAUS field on the query mask +// Certified 99% +bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key) +{ + if (!f.mask().is_running()) return TRUE; + + if (key == K_TAB && f.focusdirty()) + { + const int ann = f.mask().get_int(F_ANNOIVA); + const char* cau = f.get(); + + const TipoIVA i = cau2IVA(cau, ann); // Cerca causale e suo tipo + if (i != iva_errata) + { + const bool ok = suspended_handler(f, key); // Controlla sospensione + if (ok) + f.mask().stop_run(K_INS); // Entra in modo inserimento + } + else return FALSE; + } + + return TRUE; +} + +// Handler of the F_CODCAUS field on the modify mask +// Certified 99% +bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key) +{ + if (f.to_check(key)) + { + bool ok = suspended_handler(f, key); + if (!ok) return FALSE; + + const int ann = f.mask().get_int(F_ANNOIVA); + const char* cau = f.get(); + TCausale c(cau, ann); + if (!c.ok()) return FALSE; + + + ok = app().causale().similar(c); + if (!ok) + { + f.error_box("Causale incongruente con quella precedentemente inserita"); + return FALSE; + } + app().read_caus(cau, ann); + } + + return TRUE; +} + + +// Handler of the F_DATAREG field +// Certified 70% +bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key) +{ + bool ok = TRUE; + + if ((key == K_TAB && f.focusdirty()) || key == K_ENTER) + { + const TDate dr(f.get()); // Data dell'operazione + if (dr > TDate(TODAY)) + return f.error_box("La data dell'operazione e' superiore quella di sistema"); + + TMask& m = f.mask(); + + const int ae = date2esc(dr); // Anno esercizio + if (ae == 0) + return f.error_box("La data dell'operazione non appartiene a nessun esercizio"); + + if (m.query_mode() || app().giornale().year() != ae) + ok = app().giornale().read(ae); + else + ok = TRUE; + + if (!ok) + return f.error_box("Non esiste il libro giornale dell'esercizio %d", ae); + + if (f.dirty() || f.mask().query_mode()) + { + const TLibro_giornale& gio = app().giornale(); + if (dr <= gio.last_print()) + return f.error_box("La data dell'operazione e' antecedente al %s, ultima stampa\n" + "del libro giornale dell'esercizio %d", gio.last_reg().string(), ae); + if (dr < gio.last_reg()) + warning_box("La data dell'operazione e' antecedente al %s, ultima registrazione\n" + "sul libro giornale dell'esercizio %d", + gio.last_reg().string(), ae); + + if (m.query_mode()) + app().read_caus(m.get(F_CODCAUS), dr.year()); + + TRegistro& reg = app().causale().reg(); + const TString16 codreg(reg.name()); + if (codreg.not_empty()) + { + + if (reg.year() != dr.year()) + { + const bool ok = reg.read(codreg, dr.year()); + if (!ok) return FALSE; + } + + if (dr <= reg.last_print()) + return error_box("La data dell'operazione e' antecedente al %s, ultima\n" + "data di stampa del registro '%s' dell'anno %d", + reg.last_print().string(), (const char*)codreg, dr.year()); + if (dr < reg.last_reg()) + warning_box("La data dell'operazione e' antecedente al %s, ultima registrazione\n" + "sul registro '%s' dell'anno %d", + reg.last_reg().string(), (const char*)codreg, dr.year()); + } + } + } + return ok; +} + +// Handler of the F_DATACOMP field on the modify mask +// Certified 90% +bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key) +{ + if (!f.to_check(key, TRUE)) + return TRUE; + + const TDate dc(f.get()); // Data di competenza + const int ae = date2esc(dc); // Esercizio corrispondente + TMask& m = f.mask(); + + if (ae) + { + const char* data = ""; + if (f.dlg() == F_DATACOMP) + { + m.set(F_ANNOES, ae); + data = "di competenza"; + } + else + data = "del 74/ter"; + + const TDate dr(m.get(F_DATAREG)); // Data operazione + int pr; // Esercizio precedente + const int ar = date2esc(dr, &pr); // Esercizio in corso + if (ae != ar && ae != pr) + { + TString80 e; + e << "La data " << data << " deve appartenere all'esercizio " << ar; + if (pr > 0) e << " o al " << pr; + return f.error_box(e); + } + } + else + return f.error_box("La data non appartiene a nessun esercizio"); + + return TRUE; +} + +// Handler of the F_DATA74TER field on the modify mask +// Certified 90% +bool TPrimanota_application::data74ter_handler(TMask_field& f, KEY key) +{ + if (!f.to_check(key)) return TRUE; + bool ok = datacomp_handler(f, key); + if (ok) + { + const TDate d74(f.get()); + const TLibro_giornale& g = app().giornale(); + if (d74 < g.last_print()) + { + ok = f.error_box("La data per il 74/ter e' antecedente alla data di stampa " + "del libro giornale dell'esercizio %d", g.year()); + } + } + return ok; +} + +// Handler of the F_CODREG field on the modify mask +// Certified 99% +bool TPrimanota_application::reg_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB) + { + TRegistro& reg = app().causale().reg(); + const bool av = reg.agenzia_viaggi(); + f.mask().show(F_DATA74TER, av); + if (!av) f.mask().reset(F_DATA74TER); + } + return TRUE; +} + +bool TPrimanota_application::occas_code_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB) + { + const char* code = f.get(); + if (*code) + { + TRelation occas(LF_OCCAS); + occas.lfile()->put("CFPI", code); + if (occas.read() == NOERR) + { + f.mask().autoload(&occas); + f.mask().send_key(K_TAB, O_COMUNE); // Forza decodifica comuni + f.mask().send_key(K_TAB, O_COMUNENAS); + } + } + } else + if (key == K_ENTER) + { + const TFixed_string codice(f.get()); + if (codice.not_empty()) + app().mask().set(app().iva() == iva_vendite ? F_PIVACLIENTE : F_PIVAFORNITORE, codice); + else + return f.error_box("Il codice e' obbligatorio"); + } + return TRUE; +} + +bool TPrimanota_application::occas_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE && f.mask().is_running()) + { + TMask& om = app().occas_mask(); + om.run(); + f.set_focus(); + } + return TRUE; +} + +// Crea o aggiorna la riga contabile col totale documento +// Certified 99% +void TPrimanota_application::add_cgs_tot(TMask& m) +{ + // Lettura del conto dalla maschera + char tipo = m.get(F_CLIFO)[0]; + int gruppo = m.get_int(F_GRUPPOCLIFO); + int conto = m.get_int(F_CONTOCLIFO); + long codice = m.get_long(tipo == 'C' ? F_CLIENTE : F_FORNITORE); + + // Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale + if (conto == 0) + { + TConto bill; _causale.bill(1, bill); + gruppo = bill.gruppo(); m.set(F_GRUPPOCLIFO, gruppo); + conto = bill.conto(); m.set(F_CONTOCLIFO, conto); + } + + if (tipo == 'C' && causale().corrispettivi()) + tipo = ' '; + TConto c(gruppo, conto, codice, tipo); + real tot(m.get(F_TOTALE)); + + // Creazione/Aggiornamento riga totale + const int pos = type2pos('T'); + set_cgs_row(pos, real2imp(tot, 'T'), c, "Totale documento", 'T'); + calcola_saldo(); +} + + +// Handler of the F_CLIENTE & F_FORNITORE field on the modify mask +// Certified 99% +bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) +{ + if (!suspended_handler(f, key)) + return FALSE; + + if (key == K_TAB && f.focusdirty()) + { + app().add_cgs_tot(f.mask()); + TLocalisamfile clifo(LF_CLIFO); + const int alleg = clifo.get_int("ALLEG"); + TEdit_field& upi = (TEdit_field&)f.mask().field(F_RIEPILOGO); + upi.check_type(alleg == 3 ? CHECK_REQUIRED : CHECK_NORMAL); + } + return TRUE; +} + + +// Handler of the F_CODIVA +// Certified 99% +bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.focusdirty() && f.get().not_empty()) + { + TToken_string& row = app().ivas().row(0); + const real imp(row.get(0)); + if (imp == ZERO) + { + iva_notify(0, K_SPACE); + + const TCodiceIVA iva(f.get()); + real tot = app().totale_documento(); + + real imposta; + if (!app().causale().corrispettivi()) + imposta = app().scorpora(tot, iva.percentuale()); + + row.add(tot.string(), 0); // imponibile + row.add(iva.codice(), 1); // codice IVA + row.add(imposta.string(), 3); // imposta + + TConto bill; // Conto della prima riga IVA + const TString& tipo = iva.tipo(); + if (tipo.not_empty()) + { + if (tipo == "ES") app().causale().bill(5, bill); else + if (tipo == "NI") app().causale().bill(6, bill); else + if (tipo == "NS") app().causale().bill(7, bill); + } + if (!bill.ok() && !app().causale().corrispettivi()) + { + const TMask& m = f.mask(); + bill.set(m.get_int(F_GRUPPORIC), m.get_int(F_CONTORIC), m.get_long(F_SOTTOCONTORIC)); + } + if (!bill.ok()) + app().causale().bill(2, bill); + row.add(bill.tipo(), 5); + row.add(bill.gruppo(), 6); + row.add(bill.conto(), 7); + row.add(bill.sottoconto(), 8); + row.add(bill.descrizione(), 9); + + app().ivas().force_update(0); + iva_notify(0, K_ENTER); + } + } + return TRUE; +} + +// Handler of the F_TOTALE +// Certified 99% +bool TPrimanota_application::totale_handler(TMask_field& f, KEY key) +{ + bool ok = TRUE; + if (key == K_TAB && f.focusdirty()) + app().add_cgs_tot(f.mask()); + + if (key == K_ENTER && f.get().empty()) + ok = f.yesno_box("Totale documento nullo: continuare ugualmente?"); + return ok; +} + + +void TPrimanota_application::add_cgs_rit(bool fiscali) +{ + const real imp(_msk[2]->get(fiscali ? F_RITFIS : F_RITSOC)); + + const char tipo = fiscali ? 'F' : 'S'; + int pos = type2pos(tipo); + if (pos < 0) + { + const int riga = fiscali ? 8 : 9; + TConto conto; _causale.bill(riga, conto); + + TString80 desc("Ritenute "); + desc << (fiscali ? "fiscali" : "sociali"); + + set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo); + } + else + set_cgs_imp(pos, real2imp(imp, tipo)); +} + + +// Handler of the F_RITFIS +// Certified 99% +bool TPrimanota_application::ritfis_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.focusdirty()) + app().add_cgs_rit(TRUE); + return TRUE; +} + + +// Handler of F_RITSOC +// Certified 99% +bool TPrimanota_application::ritsoc_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.focusdirty()) + app().add_cgs_rit(FALSE); + return TRUE; +} + + +// Handler of F_VISVAL +// Certified 90% +bool TPrimanota_application::visval_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + TMask& m = f.mask(); + const real e(f.get() == "X" ? m.get(F_CAMBIO) : "1"); + m.set_exchange(e); + } + return TRUE; +} + + +bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + TMask& m = f.mask(); + const bool anchecg = !m.get_bool(F_SOLAIVA); + + app().cgs().show(anchecg); + + if (m.is_running() && anchecg) + { + TSheet_field& iva = app().ivas(); + const int righe = iva.items(); + TProgind pi(righe, "Generazione righe contabilita'", FALSE, TRUE, 16); + + app().cgs().reset(); + app().add_cgs_tot(m); + if (m.get(F_RITFIS).not_empty()) app().add_cgs_rit(TRUE); + if (m.get(F_RITSOC).not_empty()) app().add_cgs_rit(FALSE); + + TToken_string oldrow(128); + for (int i = 0; i < righe; i++) + { + TToken_string& r = iva.row(i); + if (!r.empty_items()) + { + oldrow = r; + r = ""; + iva_notify(i, K_SPACE); + r = oldrow; + iva_notify(i, K_ENTER); + } + pi.setstatus(i+1); + } + app().fill_sheet(m); + app().cgs().force_update(); + } + } + return TRUE; +} + + diff --git a/cg/cg2102.h b/cg/cg2102.h index ef836b2a3..77777c63d 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -1,152 +1,152 @@ -#ifndef __CG2102_H -#define __CG2102_H - -#ifndef __MSKSHEET_H -#include -#endif - -#ifndef __RELAPP_H -#include -#endif - -#ifndef __CGLIB_H -#include "cglib.h" -#endif - -#ifndef __CG2101_H -#include "cg2101.h" -#endif - -#ifndef __CG2103_H -#include "cg2103.h" -#endif - -class TPrimanota_application : public TRelation_application -{ - TMovimentoPN* _rel; - TLocalisamfile* _tabcom; - TLocalisamfile* _tab; - TLocalisamfile* _caus; - TLocalisamfile* _rcaus; - TLocalisamfile* _clifo; - TLocalisamfile* _pcon; - TLocalisamfile* _attiv; - TLocalisamfile* _saldo; - TLocalisamfile* _comuni; - TLocalisamfile* _occas; - TLocalisamfile* _nditte; - - TCausale _causale; // Causale corrente - TLibro_giornale _giornale; // Libro giornale corrente - TipoIVA _iva; // Tipo di IVA corrente - - TSaldo_agg _saldi; // Saldi da aggiornare - - TMask* _msk[4]; // Maschere di query, cg, iva - long _lastreg; // Numero ultima registrazione - int _mode; // Modo maschera corrente - - static bool suspended_handler(TMask_field& f, KEY k); - static bool num_handler(TMask_field& f, KEY key); - static bool caus_query_handler(TMask_field& f, KEY key); - static bool caus_modify_handler(TMask_field& f, KEY key); - static bool datareg_handler(TMask_field& f, KEY key); - static bool datacomp_handler(TMask_field& f, KEY key); - static bool data74ter_handler(TMask_field& f, KEY key); - static bool reg_handler(TMask_field& f, KEY key); - static bool clifo_handler(TMask_field& f, KEY key); - static bool totale_handler(TMask_field& f, KEY key); - static bool ritfis_handler(TMask_field& f, KEY key); - static bool ritsoc_handler(TMask_field& f, KEY key); - static bool main_codiva_handler(TMask_field& f, KEY key); - static bool visval_handler(TMask_field& f, KEY key); - static bool occas_code_handler(TMask_field& f, KEY key); - static bool occas_handler(TMask_field& f, KEY key); - static bool solaiva_handler(TMask_field& f, KEY key); - static bool descr_handler(TMask_field& f, KEY k); - - static bool imponibile_handler(TMask_field& f, KEY key); - static bool codiva_handler(TMask_field& f, KEY key); - static bool imposta_handler(TMask_field& f, KEY key); - static bool dareavere_handler(TMask_field& f, KEY k); - - static bool iva_notify(int r, KEY key); - static bool iva_handler(TMask_field& f, KEY key); - static bool cg_notify(int r, KEY key); - static bool cg_handler(TMask_field& f, KEY key); - -protected: - virtual bool user_create(); - virtual bool user_destroy(); - virtual void print(); - virtual bool changing_mask(int mode); - virtual TMask* get_mask(int mode); - virtual TRelation* get_relation() const { return _rel; } - virtual void init_query_mode(TMask& m); - virtual void init_insert_mode(TMask& m); - virtual void init_modify_mode(TMask& m); - virtual const char* get_next_key(); - virtual int read(TMask& m); - virtual int write(const TMask& m); - virtual int rewrite(const TMask& m); - virtual bool remove(); - - void genera_incasso(const char* causimm); - - TMask* load_mask(int n); - TMask& occas_mask() { return *load_mask(3); } - - bool get_conto(const TRectype& r, TConto& c) const; - void put_conto(TRectype& r, const TConto& c) const; - - void mask2rel(const TMask& m); - - TipoIVA iva() const { return _iva; } - TMask& TPrimanota_application::mask() const; - - void fill_sheet(TMask& m) const; - void init_mask(TMask& m); - - TSheet_field& cgs() const; - TSheet_field& ivas() const; - - static int bill2pos(const TConto& conto, char tipo); - static TipoIVA reg2IVA(const char* registro, int anno); - static TipoIVA cau2IVA(const char* causale, int anno); - static int type2pos(char tipo); - static const real& cod2IVA(const TMask& m); - static real scorpora(real& imponibile, const real& percentuale); - static bool detraibile(int tipodet); - - int bill2contr(const TConto& c, char sezione) const; - int bill_used(const TConto& conto) const; - int det_used(char detraib) const; - - bool read_caus(const char* cod, int year); - TCausale& causale() { return _causale; } - TLibro_giornale& giornale() { return _giornale; } - - bool test_swap(bool ritsoc); - TImporto real2imp(const real& r, char tipo); - real totale_documento(); - - void set_cgs_imp(int n, const TImporto& importo); - TImporto get_cgs_imp(int n); - void add_cgs_imp(int n, const TImporto& importo); - void sub_cgs_imp(int n, const real& imp); - - void cgs_pack(); - real calcola_saldo() const; - real calcola_imp() const; - - void set_ivas_row(int n, const char* codiva, TConto& tc, const char* desc); - int set_cgs_row(int n, const TImporto& importo, TConto& conto, const char* desc, char tipo); - void disable_cgs_cells(int n, char tipo); - void add_cgs_tot(TMask& m); - void add_cgs_rit(bool fisc); - -public: - TPrimanota_application(); -}; - -#endif +#ifndef __CG2102_H +#define __CG2102_H + +#ifndef __MSKSHEET_H +#include +#endif + +#ifndef __RELAPP_H +#include +#endif + +#ifndef __CGLIB_H +#include "cglib.h" +#endif + +#ifndef __CG2101_H +#include "cg2101.h" +#endif + +#ifndef __CG2103_H +#include "cg2103.h" +#endif + +class TPrimanota_application : public TRelation_application +{ + TMovimentoPN* _rel; + TLocalisamfile* _tabcom; + TLocalisamfile* _tab; + TLocalisamfile* _caus; + TLocalisamfile* _rcaus; + TLocalisamfile* _clifo; + TLocalisamfile* _pcon; + TLocalisamfile* _attiv; + TLocalisamfile* _saldo; + TLocalisamfile* _comuni; + TLocalisamfile* _occas; + TLocalisamfile* _nditte; + + TCausale _causale; // Causale corrente + TLibro_giornale _giornale; // Libro giornale corrente + TipoIVA _iva; // Tipo di IVA corrente + + TSaldo_agg _saldi; // Saldi da aggiornare + + TMask* _msk[4]; // Maschere di query, cg, iva + long _lastreg; // Numero ultima registrazione + int _mode; // Modo maschera corrente + + static bool suspended_handler(TMask_field& f, KEY k); + static bool num_handler(TMask_field& f, KEY key); + static bool caus_query_handler(TMask_field& f, KEY key); + static bool caus_modify_handler(TMask_field& f, KEY key); + static bool datareg_handler(TMask_field& f, KEY key); + static bool datacomp_handler(TMask_field& f, KEY key); + static bool data74ter_handler(TMask_field& f, KEY key); + static bool reg_handler(TMask_field& f, KEY key); + static bool clifo_handler(TMask_field& f, KEY key); + static bool totale_handler(TMask_field& f, KEY key); + static bool ritfis_handler(TMask_field& f, KEY key); + static bool ritsoc_handler(TMask_field& f, KEY key); + static bool main_codiva_handler(TMask_field& f, KEY key); + static bool visval_handler(TMask_field& f, KEY key); + static bool occas_code_handler(TMask_field& f, KEY key); + static bool occas_handler(TMask_field& f, KEY key); + static bool solaiva_handler(TMask_field& f, KEY key); + static bool descr_handler(TMask_field& f, KEY k); + + static bool imponibile_handler(TMask_field& f, KEY key); + static bool codiva_handler(TMask_field& f, KEY key); + static bool imposta_handler(TMask_field& f, KEY key); + static bool dareavere_handler(TMask_field& f, KEY k); + + static bool iva_notify(int r, KEY key); + static bool iva_handler(TMask_field& f, KEY key); + static bool cg_notify(int r, KEY key); + static bool cg_handler(TMask_field& f, KEY key); + +protected: + virtual bool user_create(); + virtual bool user_destroy(); + virtual void print(); + virtual bool changing_mask(int mode); + virtual TMask* get_mask(int mode); + virtual TRelation* get_relation() const { return _rel; } + virtual void init_query_mode(TMask& m); + virtual void init_insert_mode(TMask& m); + virtual void init_modify_mode(TMask& m); + virtual const char* get_next_key(); + virtual int read(TMask& m); + virtual int write(const TMask& m); + virtual int rewrite(const TMask& m); + virtual bool remove(); + + void genera_incasso(const char* causimm); + + TMask* load_mask(int n); + TMask& occas_mask() { return *load_mask(3); } + + bool get_conto(const TRectype& r, TConto& c) const; + void put_conto(TRectype& r, const TConto& c) const; + + void mask2rel(const TMask& m); + + TipoIVA iva() const { return _iva; } + TMask& TPrimanota_application::mask() const; + + void fill_sheet(TMask& m) const; + void init_mask(TMask& m); + + TSheet_field& cgs() const; + TSheet_field& ivas() const; + + static int bill2pos(const TConto& conto, char tipo); + static TipoIVA reg2IVA(const char* registro, int anno); + static TipoIVA cau2IVA(const char* causale, int anno); + static int type2pos(char tipo); + static const real& cod2IVA(const TMask& m); + static real scorpora(real& imponibile, const real& percentuale); + static bool detraibile(int tipodet); + + int bill2contr(const TConto& c, char sezione) const; + int bill_used(const TConto& conto) const; + int det_used(char detraib) const; + + bool read_caus(const char* cod, int year); + TCausale& causale() { return _causale; } + TLibro_giornale& giornale() { return _giornale; } + + bool test_swap(bool ritsoc); + TImporto real2imp(const real& r, char tipo); + real totale_documento(); + + void set_cgs_imp(int n, const TImporto& importo); + TImporto get_cgs_imp(int n); + void add_cgs_imp(int n, const TImporto& importo); + void sub_cgs_imp(int n, const real& imp); + + void cgs_pack(); + real calcola_saldo() const; + real calcola_imp() const; + + void set_ivas_row(int n, const char* codiva, TConto& tc, const char* desc); + int set_cgs_row(int n, const TImporto& importo, TConto& conto, const char* desc, char tipo); + void disable_cgs_cells(int n, char tipo); + void add_cgs_tot(TMask& m); + void add_cgs_rit(bool fisc); + +public: + TPrimanota_application(); +}; + +#endif diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index 3f8be45f3..760862e77 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -1,508 +1,508 @@ -#include -#include - -#include "cg2103.h" - -#include - -const char* iva2name(TipoIVA iva) -{ - const char* i; - switch(iva) - { - case nessuna_iva: - i = "Nessuna IVA"; break; - case iva_acquisti: - i = "IVA Acquisti"; break; - case iva_vendite: - i = "IVA Vendite"; break; - case iva_generica: - i = "IVA Generica"; break; - default: - i = "IVA ERRATA!"; break; - } - return i; -} - -/////////////////////////////////////////////////////////// -// Registro -/////////////////////////////////////////////////////////// - -TRegistro::TRegistro(const char* cod, int year) : _rec(LF_TAB), _att(LF_ATTIV) -{ - read(cod, year); -} - - -bool TRegistro::read(const char* cod, int year) -{ - if (year <= 0) - { - const TDate oggi(TODAY); - year = oggi.year(); - } - - int err = ~NOERR; - - TTable reg("REG"); - if (cod && *cod > ' ') - { - TString16 chiave; chiave.format("%04d%s", year, cod); - reg.put("CODTAB", chiave); - err = reg.read(); - } - _rec = reg.curr(); - - if (_att.ok()) - _att.zero(); - if (err != NOERR) - _rec.zero(); - return err == NOERR; -} - - -int TRegistro::year() const -{ - int anno = 0; - if (ok()) - { - TString16 sanno(_rec.get("CODTAB")); sanno.cut(4); - anno = atoi(sanno); - } - return anno; -} - - - -TRegistro& TRegistro::operator =(const TRegistro& r) -{ - _rec = r._rec; - _att = r._att; - return *this; -} - - -int TRegistro::tipo() const -{ - const int t = ok() ? _rec.get_int("I0") : 0; - return t; -} - - -bool TRegistro::corrispettivi() const -{ - const bool c = ok() ? _rec.get_bool("B0") : FALSE; - return c; -} - - -TipoIVA TRegistro::iva() const -{ - TipoIVA i = (TipoIVA)tipo(); - if (i != nessuna_iva && i != iva_vendite && i != iva_acquisti) - { - error_box("Il registro '%s' non e' un registro IVA o contabile: tipo %d", - (const char*)name(), i); - i = nessuna_iva; - } - return i; -} - -bool TRegistro::read_att() -{ - if (!_att.empty()) - return TRUE; - - TLocalisamfile attiv(LF_ATTIV); - attiv.put("CODDITTA", MainApp()->get_firm()); - attiv.put("CODATT", attivita()); - const int err = attiv.read(); - _att = attiv.curr(); - if (err != NOERR) - _att.zero(); - - return err == NOERR; -} - -bool TRegistro::agenzia_viaggi() -{ - bool av = FALSE; - if (iva() == iva_vendite && read_att()) - av = _att.get_bool("REG74TER"); - return av; -} - -const TString& TRegistro::tipo_attivita() -{ - read_att(); - return _att.get("TIPOATT"); -} - - -// Certified 99% -bool TRegistro::update(long protiva, const TDate& datareg) -{ - bool updated = TRUE; - - if (protiva > _rec.get_long("I5")) - { - _rec.put("I5", protiva); - updated = FALSE; - } - if (datareg > _rec.get_date("D2")) - { - _rec.put("D2", datareg); - updated = FALSE; - } - if (!updated) - { - TTable reg("REG"); - updated = reg.rewrite(_rec) == NOERR; - } - - return updated; -} - -/////////////////////////////////////////////////////////// -// Libro giornale -/////////////////////////////////////////////////////////// - -// Legge il libro giornale dell'anno specificato -bool TLibro_giornale::read(int y) -{ - if (y <= 0) - { - const TDate oggi(TODAY); - y = oggi.year(); - } - - TTable reg("REG"); - bool found = FALSE; - - TString16 anno; anno.format("%04d", y); - - reg.setkey(1); - reg.put("CODTAB", anno); // Cerca il primo registro dell'anno y - - for (int err = reg.read(_isgteq); err == NOERR; err = reg.next()) - { - if (strncmp(reg.get("CODTAB"), anno, 4) != 0) break; - if (reg.get_int("I0") == libro_giornale) - { - found = TRUE; - break; - } - } - - if (!found) reg.zero(); // Memorizza record (anche vuoto) - _rec = reg.curr(); - - return found; -} - -/* - TDate TLibro_giornale::global_last_print() const - { - TTable reg("REG"); - reg.setkey(1); - - TDate last(botime); - for (int err = reg.first(); err == NOERR; err = reg.next()) - { - if (reg.get_int("I0") == libro_giornale) - { - const TDate l(reg.get("D3")); - if (l > last) last = l; - } - } - return last; - } - */ - -TLibro_giornale::TLibro_giornale(int y) -{ - read(y); -} - -/////////////////////////////////////////////////////////// -// Causale -/////////////////////////////////////////////////////////// - -TCausale::TCausale(const char* cod, int year) -: TArray(12), _rec(LF_CAUSALI), _iva(iva_errata), - _sezione_clifo(' '), _sezione_ritsoc(' '), _corrisp(FALSE) -{ - if (*cod) read(cod, year); -} - - -// Legge le righe della causale attualmente selezionata sulla maschera -bool TCausale::read(const char* cod, int year) -{ - destroy(); // Delete all rows - - _iva = iva_errata; - _sezione_clifo = _sezione_ritsoc = ' '; - - if (*cod > ' ') - { - - TLocalisamfile caus(LF_CAUSALI); - caus.setkey(1); - caus.zero(); - caus.put(CAU_CODCAUS, cod); - - int err = caus.read(); - _rec = caus.curr(); - if (err != NOERR) return FALSE; - - TLocalisamfile rcaus(LF_RCAUSALI); - rcaus.setkey(1); - rcaus.zero(); - rcaus.put(CAU_CODCAUS, cod); - rcaus.put(CAU_NRIGA, 0); - - err = rcaus.read(_isgteq); // Find first line - if (err != NOERR) return FALSE; - - while (err == NOERR && rcaus.get(CAU_CODCAUS) == cod) - { - const int riga = rcaus.get_int(CAU_NRIGA); - add(rcaus.curr(), riga); - err = rcaus.next(); // Read next line - } - rcaus.zero(); - for (int riga = 1; riga < size(); riga++) // Fill gaps - if (objptr(riga) == NULL) add(rcaus.curr(), riga); - - TString16 codreg(caus.get("REG")); - const bool ok = _reg.read(codreg, year); // Read register - if (!ok && codreg.not_empty()) - return error_box("Non esiste il registro '%s' per l'anno %d", - (const char*)codreg, year); - } - else - { - _iva = nessuna_iva; // Clear IVA data - _corrisp = FALSE; - _reg.read("", year); - } - - return TRUE; -} - - -const TRectype& TCausale::row(int num) const -{ - const TRectype* rec = (const TRectype*)objptr(num); - CHECKD(rec, "Manca la riga di causale ", num); - return *rec; -} - - -TConto& TCausale::bill(int num, TConto& conto) const -{ - const TRectype& rec = row(num); - conto.set(rec.get_int("GRUPPO"), rec.get_int("CONTO"), - rec.get_long("SOTTOCONTO"), rec.get_char("TIPOCF")); - return conto; -} - -bool TCausale::data_doc() const -{ return _rec.ok() ? _rec.get_bool("DATADOC") : FALSE; } - -bool TCausale::num_doc() const -{ return _rec.ok() ? _rec.get_bool("NUMDOC") : FALSE; } - -bool TCausale::apertura() const -{ return _rec.ok() ? _rec.get_char("MOVAP") == 'A' : FALSE; } - -bool TCausale::sezionale() const -{ return _rec.ok() ? _rec.get_bool("MOVSEZ") : FALSE; } - -bool TCausale::valuta() const -{ return _rec.ok() ? _rec.get_bool("MOVVAL") : FALSE; } - -bool TCausale::intra() const -{ return _rec.ok() ? _rec.get_bool("INTRACOM") : FALSE; } - -bool TCausale::corrval() const -{ return _rec.ok() ? _rec.get_bool("VALINTRA") : FALSE; } - -const char* TCausale::causale_inc_imm() const -{ return _rec.ok() ? _rec.get("CODCAUSIM") : ""; } - -const char* TCausale::tipo_doc() const -{ return _rec.ok() ? _rec.get("TIPODOC") : ""; } - -bool TCausale::ok() const -{ - if (iva() == iva_errata) - return FALSE; - - if (corrispettivi() != reg().corrispettivi()) - return error_box("Tipo documento e registro incongruenti per i corrispettivi"); - - return TRUE; -} - -char TCausale::sezione(int riga) const -{ - const TRectype& r = row(riga); - char sez = toupper(r.get_char("SEZIONE")); - if (sez <= ' ') // Guess section on tipocf - { - const char tipocf = toupper(row(1).get_char("TIPOCF")); - sez = (tipocf == 'C') ? 'D' : 'A'; - } - return sez; -} - -char TCausale::sezione_clifo() -{ - if (_sezione_clifo == ' ') - _sezione_clifo = sezione(1); - return _sezione_clifo; -} - -char TCausale::sezione_ritsoc() -{ - if (_sezione_ritsoc == ' ') - _sezione_ritsoc = sezione(9); - return _sezione_ritsoc; -} - -TipoIVA TCausale::iva() const -{ - if (_iva == iva_errata) - { - TipoIVA i = nessuna_iva; // Tipo IVA di default - bool c = FALSE; // Corrispettivi di default - - TString16 tipodoc(_rec.get("TIPODOC")); - if (tipodoc.not_empty()) - { - TTable tpd("%TPD"); - tpd.put("CODTAB", tipodoc); - if (tpd.read() == NOERR) - { - i = (TipoIVA)tpd.get_int("I0"); // IVA acquisti, vendite, generica - const TipoIVA ri = _reg.iva(); - if (i == iva_generica) - i = ri; - if (i != ri) - { - error_box("Tipo documento incompatibile con tipo registro"); - i = iva_errata; - } - c = tpd.get_bool("B0"); - } - } - ((TCausale*)this)->_iva = i; // Ricorda IVA per la prossima volta - ((TCausale*)this)->_corrisp = c; // Ricorda flag per la prossima volta - } - return _iva; -} - -bool TCausale::corrispettivi() const -{ - if (_iva == iva_errata) iva(); - return _corrisp; -} - -bool TCausale::similar(const TCausale& c) const -{ - return iva() == c.iva() && - sezionale() == c.sezionale() && - valuta() == c.valuta() && - intra() == c.intra() && - corrispettivi() == c.corrispettivi(); -} - -/////////////////////////////////////////////////////////// -// Codice IVA -/////////////////////////////////////////////////////////// - -TCodiceIVA::TCodiceIVA(const char* cod) : TRectype(LF_TABCOM) -{ - read(cod); -} - -bool TCodiceIVA::read(const char* cod) -{ - int err = ~NOERR; - TTable iva("%IVA"); - if (cod && *cod) - { - iva.setkey(1); - iva.put("CODTAB", cod); - err = iva.read(); - } - TRectype::operator=(iva.curr()); - if (err != NOERR) zero(); - return err == NOERR; -} - - -/////////////////////////////////////////////////////////// -// Importo -/////////////////////////////////////////////////////////// - -const TImporto& TImporto::add_to(TToken_string& s) const -{ - const bool dare = sezione() == 'D'; - const char* v = valore().string(); - s.add(dare ? v : "", 0); - s.add(dare ? "" : v, 1); - return *this; -} - -// Cerified 99% -// Ambigous section for ZERO -const TImporto& TImporto::operator =(TToken_string& sv) -{ - _valore = real(sv.get(0)); - if (_valore == ZERO) - { - _valore = real(sv.get()); - _sezione = 'A'; - } - else - _sezione = 'D'; - return *this; -} - - -const TImporto& TImporto::set(char s, const real& v) -{ - CHECKD(s == 'D' || s == 'A', "Sezione errata per importo: codice ", (int)s); - _sezione = s; _valore = v; - return *this; -} - - -const TImporto& TImporto::operator += (const TImporto& i) -{ - if (_sezione == i._sezione) - _valore += i._valore; - else - _valore -= i._valore; - return *this; -} - - -const TImporto& TImporto::operator -= (const TImporto& i) -{ - if (_sezione == i._sezione) - _valore -= i._valore; - else - _valore += i._valore; - return *this; -} - -const TImporto& TImporto::swap_section() -{ - _sezione = (_sezione == 'D') ? 'A' : 'D'; - return *this; -} - +#include +#include + +#include "cg2103.h" + +#include + +const char* iva2name(TipoIVA iva) +{ + const char* i; + switch(iva) + { + case nessuna_iva: + i = "Nessuna IVA"; break; + case iva_acquisti: + i = "IVA Acquisti"; break; + case iva_vendite: + i = "IVA Vendite"; break; + case iva_generica: + i = "IVA Generica"; break; + default: + i = "IVA ERRATA!"; break; + } + return i; +} + +/////////////////////////////////////////////////////////// +// Registro +/////////////////////////////////////////////////////////// + +TRegistro::TRegistro(const char* cod, int year) : _rec(LF_TAB), _att(LF_ATTIV) +{ + read(cod, year); +} + + +bool TRegistro::read(const char* cod, int year) +{ + if (year <= 0) + { + const TDate oggi(TODAY); + year = oggi.year(); + } + + int err = ~NOERR; + + TTable reg("REG"); + if (cod && *cod > ' ') + { + TString16 chiave; chiave.format("%04d%s", year, cod); + reg.put("CODTAB", chiave); + err = reg.read(); + } + _rec = reg.curr(); + + if (_att.ok()) + _att.zero(); + if (err != NOERR) + _rec.zero(); + return err == NOERR; +} + + +int TRegistro::year() const +{ + int anno = 0; + if (ok()) + { + TString16 sanno(_rec.get("CODTAB")); sanno.cut(4); + anno = atoi(sanno); + } + return anno; +} + + + +TRegistro& TRegistro::operator =(const TRegistro& r) +{ + _rec = r._rec; + _att = r._att; + return *this; +} + + +int TRegistro::tipo() const +{ + const int t = ok() ? _rec.get_int("I0") : 0; + return t; +} + + +bool TRegistro::corrispettivi() const +{ + const bool c = ok() ? _rec.get_bool("B0") : FALSE; + return c; +} + + +TipoIVA TRegistro::iva() const +{ + TipoIVA i = (TipoIVA)tipo(); + if (i != nessuna_iva && i != iva_vendite && i != iva_acquisti) + { + error_box("Il registro '%s' non e' un registro IVA o contabile: tipo %d", + (const char*)name(), i); + i = nessuna_iva; + } + return i; +} + +bool TRegistro::read_att() +{ + if (!_att.empty()) + return TRUE; + + TLocalisamfile attiv(LF_ATTIV); + attiv.put("CODDITTA", MainApp()->get_firm()); + attiv.put("CODATT", attivita()); + const int err = attiv.read(); + _att = attiv.curr(); + if (err != NOERR) + _att.zero(); + + return err == NOERR; +} + +bool TRegistro::agenzia_viaggi() +{ + bool av = FALSE; + if (iva() == iva_vendite && read_att()) + av = _att.get_bool("REG74TER"); + return av; +} + +const TString& TRegistro::tipo_attivita() +{ + read_att(); + return _att.get("TIPOATT"); +} + + +// Certified 99% +bool TRegistro::update(long protiva, const TDate& datareg) +{ + bool updated = TRUE; + + if (protiva > _rec.get_long("I5")) + { + _rec.put("I5", protiva); + updated = FALSE; + } + if (datareg > _rec.get_date("D2")) + { + _rec.put("D2", datareg); + updated = FALSE; + } + if (!updated) + { + TTable reg("REG"); + updated = reg.rewrite(_rec) == NOERR; + } + + return updated; +} + +/////////////////////////////////////////////////////////// +// Libro giornale +/////////////////////////////////////////////////////////// + +// Legge il libro giornale dell'anno specificato +bool TLibro_giornale::read(int y) +{ + if (y <= 0) + { + const TDate oggi(TODAY); + y = oggi.year(); + } + + TTable reg("REG"); + bool found = FALSE; + + TString16 anno; anno.format("%04d", y); + + reg.setkey(1); + reg.put("CODTAB", anno); // Cerca il primo registro dell'anno y + + for (int err = reg.read(_isgteq); err == NOERR; err = reg.next()) + { + if (strncmp(reg.get("CODTAB"), anno, 4) != 0) break; + if (reg.get_int("I0") == libro_giornale) + { + found = TRUE; + break; + } + } + + if (!found) reg.zero(); // Memorizza record (anche vuoto) + _rec = reg.curr(); + + return found; +} + +/* + TDate TLibro_giornale::global_last_print() const + { + TTable reg("REG"); + reg.setkey(1); + + TDate last(botime); + for (int err = reg.first(); err == NOERR; err = reg.next()) + { + if (reg.get_int("I0") == libro_giornale) + { + const TDate l(reg.get("D3")); + if (l > last) last = l; + } + } + return last; + } + */ + +TLibro_giornale::TLibro_giornale(int y) +{ + read(y); +} + +/////////////////////////////////////////////////////////// +// Causale +/////////////////////////////////////////////////////////// + +TCausale::TCausale(const char* cod, int year) +: TArray(12), _rec(LF_CAUSALI), _iva(iva_errata), + _sezione_clifo(' '), _sezione_ritsoc(' '), _corrisp(FALSE) +{ + if (*cod) read(cod, year); +} + + +// Legge le righe della causale attualmente selezionata sulla maschera +bool TCausale::read(const char* cod, int year) +{ + destroy(); // Delete all rows + + _iva = iva_errata; + _sezione_clifo = _sezione_ritsoc = ' '; + + if (*cod > ' ') + { + + TLocalisamfile caus(LF_CAUSALI); + caus.setkey(1); + caus.zero(); + caus.put(CAU_CODCAUS, cod); + + int err = caus.read(); + _rec = caus.curr(); + if (err != NOERR) return FALSE; + + TLocalisamfile rcaus(LF_RCAUSALI); + rcaus.setkey(1); + rcaus.zero(); + rcaus.put(CAU_CODCAUS, cod); + rcaus.put(CAU_NRIGA, 0); + + err = rcaus.read(_isgteq); // Find first line + if (err != NOERR) return FALSE; + + while (err == NOERR && rcaus.get(CAU_CODCAUS) == cod) + { + const int riga = rcaus.get_int(CAU_NRIGA); + add(rcaus.curr(), riga); + err = rcaus.next(); // Read next line + } + rcaus.zero(); + for (int riga = 1; riga < size(); riga++) // Fill gaps + if (objptr(riga) == NULL) add(rcaus.curr(), riga); + + TString16 codreg(caus.get("REG")); + const bool ok = _reg.read(codreg, year); // Read register + if (!ok && codreg.not_empty()) + return error_box("Non esiste il registro '%s' per l'anno %d", + (const char*)codreg, year); + } + else + { + _iva = nessuna_iva; // Clear IVA data + _corrisp = FALSE; + _reg.read("", year); + } + + return TRUE; +} + + +const TRectype& TCausale::row(int num) const +{ + const TRectype* rec = (const TRectype*)objptr(num); + CHECKD(rec, "Manca la riga di causale ", num); + return *rec; +} + + +TConto& TCausale::bill(int num, TConto& conto) const +{ + const TRectype& rec = row(num); + conto.set(rec.get_int("GRUPPO"), rec.get_int("CONTO"), + rec.get_long("SOTTOCONTO"), rec.get_char("TIPOCF")); + return conto; +} + +bool TCausale::data_doc() const +{ return _rec.ok() ? _rec.get_bool("DATADOC") : FALSE; } + +bool TCausale::num_doc() const +{ return _rec.ok() ? _rec.get_bool("NUMDOC") : FALSE; } + +bool TCausale::apertura() const +{ return _rec.ok() ? _rec.get_char("MOVAP") == 'A' : FALSE; } + +bool TCausale::sezionale() const +{ return _rec.ok() ? _rec.get_bool("MOVSEZ") : FALSE; } + +bool TCausale::valuta() const +{ return _rec.ok() ? _rec.get_bool("MOVVAL") : FALSE; } + +bool TCausale::intra() const +{ return _rec.ok() ? _rec.get_bool("INTRACOM") : FALSE; } + +bool TCausale::corrval() const +{ return _rec.ok() ? _rec.get_bool("VALINTRA") : FALSE; } + +const char* TCausale::causale_inc_imm() const +{ return _rec.ok() ? _rec.get("CODCAUSIM") : ""; } + +const char* TCausale::tipo_doc() const +{ return _rec.ok() ? _rec.get("TIPODOC") : ""; } + +bool TCausale::ok() const +{ + if (iva() == iva_errata) + return FALSE; + + if (corrispettivi() != reg().corrispettivi()) + return error_box("Tipo documento e registro incongruenti per i corrispettivi"); + + return TRUE; +} + +char TCausale::sezione(int riga) const +{ + const TRectype& r = row(riga); + char sez = toupper(r.get_char("SEZIONE")); + if (sez <= ' ') // Guess section on tipocf + { + const char tipocf = toupper(row(1).get_char("TIPOCF")); + sez = (tipocf == 'C') ? 'D' : 'A'; + } + return sez; +} + +char TCausale::sezione_clifo() +{ + if (_sezione_clifo == ' ') + _sezione_clifo = sezione(1); + return _sezione_clifo; +} + +char TCausale::sezione_ritsoc() +{ + if (_sezione_ritsoc == ' ') + _sezione_ritsoc = sezione(9); + return _sezione_ritsoc; +} + +TipoIVA TCausale::iva() const +{ + if (_iva == iva_errata) + { + TipoIVA i = nessuna_iva; // Tipo IVA di default + bool c = FALSE; // Corrispettivi di default + + TString16 tipodoc(_rec.get("TIPODOC")); + if (tipodoc.not_empty()) + { + TTable tpd("%TPD"); + tpd.put("CODTAB", tipodoc); + if (tpd.read() == NOERR) + { + i = (TipoIVA)tpd.get_int("I0"); // IVA acquisti, vendite, generica + const TipoIVA ri = _reg.iva(); + if (i == iva_generica) + i = ri; + if (i != ri) + { + error_box("Tipo documento incompatibile con tipo registro"); + i = iva_errata; + } + c = tpd.get_bool("B0"); + } + } + ((TCausale*)this)->_iva = i; // Ricorda IVA per la prossima volta + ((TCausale*)this)->_corrisp = c; // Ricorda flag per la prossima volta + } + return _iva; +} + +bool TCausale::corrispettivi() const +{ + if (_iva == iva_errata) iva(); + return _corrisp; +} + +bool TCausale::similar(const TCausale& c) const +{ + return iva() == c.iva() && + sezionale() == c.sezionale() && + valuta() == c.valuta() && + intra() == c.intra() && + corrispettivi() == c.corrispettivi(); +} + +/////////////////////////////////////////////////////////// +// Codice IVA +/////////////////////////////////////////////////////////// + +TCodiceIVA::TCodiceIVA(const char* cod) : TRectype(LF_TABCOM) +{ + read(cod); +} + +bool TCodiceIVA::read(const char* cod) +{ + int err = ~NOERR; + TTable iva("%IVA"); + if (cod && *cod) + { + iva.setkey(1); + iva.put("CODTAB", cod); + err = iva.read(); + } + TRectype::operator=(iva.curr()); + if (err != NOERR) zero(); + return err == NOERR; +} + + +/////////////////////////////////////////////////////////// +// Importo +/////////////////////////////////////////////////////////// + +const TImporto& TImporto::add_to(TToken_string& s) const +{ + const bool dare = sezione() == 'D'; + const char* v = valore().string(); + s.add(dare ? v : "", 0); + s.add(dare ? "" : v, 1); + return *this; +} + +// Cerified 99% +// Ambigous section for ZERO +const TImporto& TImporto::operator =(TToken_string& sv) +{ + _valore = real(sv.get(0)); + if (_valore == ZERO) + { + _valore = real(sv.get()); + _sezione = 'A'; + } + else + _sezione = 'D'; + return *this; +} + + +const TImporto& TImporto::set(char s, const real& v) +{ + CHECKD(s == 'D' || s == 'A', "Sezione errata per importo: codice ", (int)s); + _sezione = s; _valore = v; + return *this; +} + + +const TImporto& TImporto::operator += (const TImporto& i) +{ + if (_sezione == i._sezione) + _valore += i._valore; + else + _valore -= i._valore; + return *this; +} + + +const TImporto& TImporto::operator -= (const TImporto& i) +{ + if (_sezione == i._sezione) + _valore -= i._valore; + else + _valore += i._valore; + return *this; +} + +const TImporto& TImporto::swap_section() +{ + _sezione = (_sezione == 'D') ? 'A' : 'D'; + return *this; +} + diff --git a/cg/cg3100a.uml b/cg/cg3100a.uml index bac4f4df2..9ecb1e6e7 100755 --- a/cg/cg3100a.uml +++ b/cg/cg3100a.uml @@ -1,221 +1,221 @@ -#include "cg3100.h" - -PAGE "Stampa Lista Movimenti" -1 -1 76 20 - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 2 1 "Ditta " - FLAGS "FRD" - USE LF_NDITTE KEY 1 - CHECKTYPE REQUIRED - INPUT CODDITTA F_CODDITTA - DISPLAY "Codice" CODDITTA - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_CODDITTA CODDITTA - OUTPUT F_RAGSOC RAGSOC -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 2 2 "Ragione sociale " - FLAGS "D" -END - -DATE F_DATASTAMPA -BEGIN - PROMPT 48 1 "Data stampa " - FLAGS "A" -END - -NUMBER F_ANNO 4 -BEGIN - GROUP 3 - PROMPT 2 3 "Anno esercizio " - USE ESC - CHECKTYPE NORMAL - INPUT CODTAB F_ANNO - DISPLAY "Anno" CODTAB - DISPLAY "Data inizio esercizio" D0 - DISPLAY "Data fine esercizio" D1 - OUTPUT F_ANNO CODTAB - FLAGS "RZ" -END - -RADIOBUTTON F_MOVIMENTI 38 -BEGIN - PROMPT 30 3 "Scelta stampa " - HELP "Indicare il tipo di stampa" - ITEM "0|Lista movimenti" - MESSAGE SHOW,F_CONTROLLO|SHOW,1@|SHOW,F_REGISTROFIN|SHOW,F_REGISTROINI - ITEM "1|Lista movimenti di sola prima nota" - MESSAGE HIDE,F_CONTROLLO|HIDE,1@|HIDE,F_REGISTROFIN|HIDE,F_REGISTROINI|HIDE,F_STAMPA -END - - -LIST F_CONTROLLO 23 -BEGIN - PROMPT 2 7 "Controllo movimenti errati " - HELP "La scelta 1 stampa solo le registrazioni non errate; la scelta 2 permette di listare tutte le registrazioni inserite, segnalando quelle errate; la scelta 3 stampa solo le registrazioni errate" - ITEM "3|No" MESSAGE HIDE,1@ - ITEM "2|Si" MESSAGE SHOW,1@ - ITEM "1|Stampa movimenti errati" MESSAGE SHOW,1@ -END - -TEXT DLG_NULL -BEGIN - GROUP 1 - PROMPT 2 8 "Stampa messaggi : " -END - -BOOLEAN F_ANNOC -BEGIN - GROUP 1 - PROMPT 20 8 "anno di competenza " -END - -BOOLEAN F_ALLEGATO -BEGIN - GROUP 1 - PROMPT 20 9 "allegato iva " - MESSAGE TRUE DISABLE,F_STAMPA|COPY,F_STAMPA - MESSAGE FALSE ENABLE,F_STAMPA -END - -RADIOBUTTON F_DECIDI 10 -BEGIN - PROMPT 2 10 "Stampa " - ITEM "2|data" MESSAGE DISABLE,2@|RESET,2@|ENABLE,3@ - ITEM "1|numero" MESSAGE DISABLE,3@|RESET,3@|ENABLE,2@ -END - -DATE F_DATAINI -BEGIN - PROMPT 19 11 "Stampa mov. dalla data " - //HELP "Se non indicato nessun valore viene effettuata una stampa completa in ordine di data" - GROUP 3 -END - -DATE F_DATAFIN -BEGIN - PROMPT 55 11 "alla data " - GROUP 3 -END - -NUMBER F_NUMEROINI 7 -BEGIN - PROMPT 19 12 "Stampa mov. dal numero " - USE LF_MOV KEY 1 - INPUT NUMREG F_NUMEROINI - DISPLAY "Numero registrazione" NUMREG - DISPLAY "Descrizione@50" DESCR - OUTPUT F_NUMEROINI NUMREG - CHECKTYPE NORMAL - FLAGS "R" - GROUP 2 -END - -NUMBER F_NUMEROFIN 7 -BEGIN - PROMPT 55 12 "al numero " - COPY USE F_NUMEROINI - INPUT NUMREG F_NUMEROFIN - COPY DISPLAY F_NUMEROINI - OUTPUT F_NUMEROFIN NUMREG - CHECKTYPE NORMAL - FLAGS "R" - GROUP 2 -END - -STRING F_CAUSALEINI 3 -BEGIN - PROMPT 2 14 "Stampa dalla causale " - USE LF_CAUSALI KEY 1 - INPUT CODCAUS F_CAUSALEINI - DISPLAY "Codice causale" CODCAUS - DISPLAY "Descrizione@50" DESCR - OUTPUT F_CAUSALEINI CODCAUS - FLAGS "UR" - HELP "Introdurre codice causale di inizio stampa: vuoto = inizio archivio" -END - -STRING F_CAUSALEFIN 3 -BEGIN - PROMPT 40 14 "alla causale " - COPY USE F_CAUSALEINI - INPUT CODCAUS F_CAUSALEFIN - DISPLAY "Codice causale" CODCAUS - DISPLAY "Descrizione@50" DESCR - OUTPUT F_CAUSALEFIN CODCAUS - FLAGS "UR" - HELP "Introdurre codice causale di fine stampa: vuoto = fine archivio" -END - -STRING F_REGISTROINI 3 -BEGIN - PROMPT 2 15 "Stampa dal registro iva " - USE REG SELECT I0<"3" - //INPUT CODTAB[1,5] F_ANNO SELECT - //INPUT CODTAB[1,5] "" - INPUT CODTAB[5,7] F_REGISTROINI - DISPLAY "Anno" CODTAB[1,4] - DISPLAY "Cod. registro iva" CODTAB[5,7] - DISPLAY "Descrizione@40" S0 - OUTPUT F_REGISTROINI CODTAB[5,7] - FLAGS "UR" - //CHECKTYPE NORMAL - HELP "Introdurre cod. registro iva di inizio stampa: vuoto = inizio archivio" -END - -STRING F_REGISTROFIN 3 -BEGIN - PROMPT 40 15 "al reg. iva " - COPY USE F_REGISTROINI - //INPUT CODTAB[1,5] F_ANNO SELECT - //INPUT CODTAB[1,5] "" - INPUT CODTAB[5,7] F_REGISTROFIN - DISPLAY "Anno" CODTAB[1,4] - DISPLAY "Cod. registro iva" CODTAB[5,7] - DISPLAY "Descrizione@40" S0 - OUTPUT F_REGISTROFIN CODTAB[5,7] - FLAGS "UR" - //CHECKTYPE NORMAL - HELP "Introdurre cod. registro iva di fine stampa: vuoto = fine archivio" -END - -BOOLEAN F_STAMPA -BEGIN - PROMPT 2 16 "Stampa imponibili, imposte e codici iva " -END - -BOOLEAN F_STAMPAMOVP -BEGIN - PROMPT 2 17 "Stampa movimenti provvisori " -END - -/* -TEXT DLG_NULL -BEGIN - PROMPT 2 17 "N.B. se non indicato nessun valore stampa completa in ordine di data" -END -*/ - -BUTTON DLG_OK 9 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 9 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -ENDMASK - - - - - - - +#include "cg3100.h" + +PAGE "Stampa Lista Movimenti" -1 -1 76 20 + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 2 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + CHECKTYPE REQUIRED + INPUT CODDITTA F_CODDITTA + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_CODDITTA CODDITTA + OUTPUT F_RAGSOC RAGSOC +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 2 2 "Ragione sociale " + FLAGS "D" +END + +DATE F_DATASTAMPA +BEGIN + PROMPT 48 1 "Data stampa " + FLAGS "A" +END + +NUMBER F_ANNO 4 +BEGIN + GROUP 3 + PROMPT 2 3 "Anno esercizio " + USE ESC + CHECKTYPE NORMAL + INPUT CODTAB F_ANNO + DISPLAY "Anno" CODTAB + DISPLAY "Data inizio esercizio" D0 + DISPLAY "Data fine esercizio" D1 + OUTPUT F_ANNO CODTAB + FLAGS "RZ" +END + +RADIOBUTTON F_MOVIMENTI 38 +BEGIN + PROMPT 30 3 "Scelta stampa " + HELP "Indicare il tipo di stampa" + ITEM "0|Lista movimenti" + MESSAGE SHOW,F_CONTROLLO|SHOW,1@|SHOW,F_REGISTROFIN|SHOW,F_REGISTROINI + ITEM "1|Lista movimenti di sola prima nota" + MESSAGE HIDE,F_CONTROLLO|HIDE,1@|HIDE,F_REGISTROFIN|HIDE,F_REGISTROINI|HIDE,F_STAMPA +END + + +LIST F_CONTROLLO 23 +BEGIN + PROMPT 2 7 "Controllo movimenti errati " + HELP "La scelta 1 stampa solo le registrazioni non errate; la scelta 2 permette di listare tutte le registrazioni inserite, segnalando quelle errate; la scelta 3 stampa solo le registrazioni errate" + ITEM "3|No" MESSAGE HIDE,1@ + ITEM "2|Si" MESSAGE SHOW,1@ + ITEM "1|Stampa movimenti errati" MESSAGE SHOW,1@ +END + +TEXT DLG_NULL +BEGIN + GROUP 1 + PROMPT 2 8 "Stampa messaggi : " +END + +BOOLEAN F_ANNOC +BEGIN + GROUP 1 + PROMPT 20 8 "anno di competenza " +END + +BOOLEAN F_ALLEGATO +BEGIN + GROUP 1 + PROMPT 20 9 "allegato iva " + MESSAGE TRUE DISABLE,F_STAMPA|COPY,F_STAMPA + MESSAGE FALSE ENABLE,F_STAMPA +END + +RADIOBUTTON F_DECIDI 10 +BEGIN + PROMPT 2 10 "Stampa " + ITEM "2|data" MESSAGE DISABLE,2@|RESET,2@|ENABLE,3@ + ITEM "1|numero" MESSAGE DISABLE,3@|RESET,3@|ENABLE,2@ +END + +DATE F_DATAINI +BEGIN + PROMPT 19 11 "Stampa mov. dalla data " + //HELP "Se non indicato nessun valore viene effettuata una stampa completa in ordine di data" + GROUP 3 +END + +DATE F_DATAFIN +BEGIN + PROMPT 55 11 "alla data " + GROUP 3 +END + +NUMBER F_NUMEROINI 7 +BEGIN + PROMPT 19 12 "Stampa mov. dal numero " + USE LF_MOV KEY 1 + INPUT NUMREG F_NUMEROINI + DISPLAY "Numero registrazione" NUMREG + DISPLAY "Descrizione@50" DESCR + OUTPUT F_NUMEROINI NUMREG + CHECKTYPE NORMAL + FLAGS "R" + GROUP 2 +END + +NUMBER F_NUMEROFIN 7 +BEGIN + PROMPT 55 12 "al numero " + COPY USE F_NUMEROINI + INPUT NUMREG F_NUMEROFIN + COPY DISPLAY F_NUMEROINI + OUTPUT F_NUMEROFIN NUMREG + CHECKTYPE NORMAL + FLAGS "R" + GROUP 2 +END + +STRING F_CAUSALEINI 3 +BEGIN + PROMPT 2 14 "Stampa dalla causale " + USE LF_CAUSALI KEY 1 + INPUT CODCAUS F_CAUSALEINI + DISPLAY "Codice causale" CODCAUS + DISPLAY "Descrizione@50" DESCR + OUTPUT F_CAUSALEINI CODCAUS + FLAGS "UR" + HELP "Introdurre codice causale di inizio stampa: vuoto = inizio archivio" +END + +STRING F_CAUSALEFIN 3 +BEGIN + PROMPT 40 14 "alla causale " + COPY USE F_CAUSALEINI + INPUT CODCAUS F_CAUSALEFIN + DISPLAY "Codice causale" CODCAUS + DISPLAY "Descrizione@50" DESCR + OUTPUT F_CAUSALEFIN CODCAUS + FLAGS "UR" + HELP "Introdurre codice causale di fine stampa: vuoto = fine archivio" +END + +STRING F_REGISTROINI 3 +BEGIN + PROMPT 2 15 "Stampa dal registro iva " + USE REG SELECT I0<"3" + //INPUT CODTAB[1,5] F_ANNO SELECT + //INPUT CODTAB[1,5] "" + INPUT CODTAB[5,7] F_REGISTROINI + DISPLAY "Anno" CODTAB[1,4] + DISPLAY "Cod. registro iva" CODTAB[5,7] + DISPLAY "Descrizione@40" S0 + OUTPUT F_REGISTROINI CODTAB[5,7] + FLAGS "UR" + //CHECKTYPE NORMAL + HELP "Introdurre cod. registro iva di inizio stampa: vuoto = inizio archivio" +END + +STRING F_REGISTROFIN 3 +BEGIN + PROMPT 40 15 "al reg. iva " + COPY USE F_REGISTROINI + //INPUT CODTAB[1,5] F_ANNO SELECT + //INPUT CODTAB[1,5] "" + INPUT CODTAB[5,7] F_REGISTROFIN + DISPLAY "Anno" CODTAB[1,4] + DISPLAY "Cod. registro iva" CODTAB[5,7] + DISPLAY "Descrizione@40" S0 + OUTPUT F_REGISTROFIN CODTAB[5,7] + FLAGS "UR" + //CHECKTYPE NORMAL + HELP "Introdurre cod. registro iva di fine stampa: vuoto = fine archivio" +END + +BOOLEAN F_STAMPA +BEGIN + PROMPT 2 16 "Stampa imponibili, imposte e codici iva " +END + +BOOLEAN F_STAMPAMOVP +BEGIN + PROMPT 2 17 "Stampa movimenti provvisori " +END + +/* +TEXT DLG_NULL +BEGIN + PROMPT 2 17 "N.B. se non indicato nessun valore stampa completa in ordine di data" +END +*/ + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK + + + + + + + diff --git a/cg/cg3200a.uml b/cg/cg3200a.uml index 0daf2ae37..9a0a83c90 100755 --- a/cg/cg3200a.uml +++ b/cg/cg3200a.uml @@ -1,581 +1,581 @@ -#include "cg3200.h" - -PAGE "Stampa Clienti e Fornitori" -1 -1 78 20 - - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 4 1 "Ditta " - FLAGS "FRD" - USE LF_NDITTE KEY 1 - CHECKTYPE REQUIRED - INPUT CODDITTA F_CODDITTA - DISPLAY "Codice" CODDITTA - DISPLAY "Ragione sociale @50" RAGSOC - OUTPUT F_CODDITTA CODDITTA - OUTPUT F_RAGSOC RAGSOC -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 4 2 "Ragione sociale " - FLAGS "D" -END - -TEXT 96 -BEGIN - PROMPT 4 10 "Dalla data competenza " -END - -TEXT 97 -BEGIN - PROMPT 40 10 "Alla data competenza " -END - -TEXT 98 -BEGIN - PROMPT 4 10 "Dalla data operazione " -END - -TEXT 99 -BEGIN - PROMPT 40 10 "Alla data operazione " -END - -NUMBER F_ANNO 4 -BEGIN - PROMPT 47 1 "Anno esercizio " - HELP "Inserire un anno esercizio presente nella tabella oppure nulla: in questo caso non e' possibile fare il controllo competenza esercizio" - USE ESC - INPUT CODTAB F_ANNO - DISPLAY "Anno Esercizio" CODTAB - DISPLAY "Data inizio esercizio" D0 - DISPLAY "Data fine esercizio " D1 - OUTPUT F_ANNO CODTAB - CHECKTYPE NORMAL - MESSAGE HIDE,98|HIDE,99|SHOW,96|SHOW,97 - MESSAGE EMPTY HIDE,96|HIDE,97|SHOW,98|SHOW,99 - FLAGS "RZ" -END - -LIST F_RICERCA 25 -BEGIN - PROMPT 4 4 "Ricerca " - ITEM "C|Clienti" - MESSAGE HIDE,2@|HIDE,3@|RESET,2@|RESET,3@|SHOW,1@ - ITEM "F|Fornitori" - MESSAGE HIDE,1@|HIDE,3@|RESET,1@|RESET,3@|SHOW,2@ - ITEM "P|Gruppo/conto/sottoconto" - MESSAGE HIDE,1@|HIDE,2@|RESET,1@|RESET,2@|SHOW,3@ -END - -NUMBER F_GRUPPOINI 3 -BEGIN - PROMPT 4 5 "Da Gruppo - Conto - Sottoconto " - USE LF_CLIFO SELECT TIPOCF="C" -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOINI GRUPPO - OUTPUT F_CONTOINI CONTO - OUTPUT F_SOTTOCONTOINI CODCF - OUTPUT F_DESCRINI RAGSOC - FLAGS "R" - GROUP 1 -END - -NUMBER F_CONTOINI 3 -BEGIN - PROMPT 41 5 "" - COPY USE F_GRUPPOINI -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI - INPUT CONTO F_CONTOINI - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOINI GRUPPO - OUTPUT F_CONTOINI CONTO - OUTPUT F_SOTTOCONTOINI CODCF - OUTPUT F_DESCRINI RAGSOC - FLAGS "R" - GROUP 1 -END - -NUMBER F_SOTTOCONTOINI 6 -BEGIN - PROMPT 47 5 "" - COPY USE F_GRUPPOINI -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI - INPUT CONTO F_CONTOINI - INPUT CODCF F_SOTTOCONTOINI - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOINI GRUPPO - OUTPUT F_CONTOINI CONTO - OUTPUT F_SOTTOCONTOINI CODCF - OUTPUT F_DESCRINI RAGSOC - FLAGS "R" - GROUP 1 -END - -STRING F_DESCRINI 50 -BEGIN - PROMPT 4 6 "Ragione sociale " - FLAGS "D" - GROUP 1 -END - -NUMBER F_GRUPPOFINE 3 -BEGIN - PROMPT 4 7 "A Gruppo - Conto - Sottoconto " - COPY USE F_GRUPPOINI -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOFINE GRUPPO - OUTPUT F_CONTOFINE CONTO - OUTPUT F_SOTTOCONTOFINE CODCF - OUTPUT F_DESCRFINE RAGSOC - FLAGS "R" - GROUP 1 -END - -NUMBER F_CONTOFINE 3 -BEGIN - PROMPT 41 7 "" - COPY USE F_GRUPPOINI -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE - INPUT CONTO F_CONTOFINE - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOFINE GRUPPO - OUTPUT F_CONTOFINE CONTO - OUTPUT F_SOTTOCONTOFINE CODCF - OUTPUT F_DESCRFINE RAGSOC - FLAGS "R" - GROUP 1 -END - -NUMBER F_SOTTOCONTOFINE 6 -BEGIN - PROMPT 47 7 "" - COPY USE F_GRUPPOINI -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE - INPUT CONTO F_CONTOFINE - INPUT CODCF F_SOTTOCONTOFINE - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOFINE GRUPPO - OUTPUT F_CONTOFINE CONTO - OUTPUT F_SOTTOCONTOFINE CODCF - OUTPUT F_DESCRFINE RAGSOC - FLAGS "R" - GROUP 1 -END - -STRING F_DESCRFINE 50 -BEGIN - PROMPT 4 8 "Ragione sociale " - FLAGS "D" - GROUP 1 -END - -NUMBER F_GRUPPOINI2 3 -BEGIN - PROMPT 4 5 "Da Gruppo - Conto - Sottoconto " - USE LF_CLIFO SELECT TIPOCF="F" -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI2 - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOINI2 GRUPPO - OUTPUT F_CONTOINI2 CONTO - OUTPUT F_SOTTOCONTOINI2 CODCF - OUTPUT F_DESCRINI2 RAGSOC - FLAGS "R" - GROUP 2 - MESSAGE COPY,F_GRUPPOINI -END - -NUMBER F_CONTOINI2 3 -BEGIN - PROMPT 41 5 "" - COPY USE F_GRUPPOINI2 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI2 - INPUT CONTO F_CONTOINI2 - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOINI2 GRUPPO - OUTPUT F_CONTOINI2 CONTO - OUTPUT F_SOTTOCONTOINI2 CODCF - OUTPUT F_DESCRINI2 RAGSOC - FLAGS "R" - GROUP 2 - MESSAGE COPY,F_CONTOINI -END - -NUMBER F_SOTTOCONTOINI2 6 -BEGIN - PROMPT 47 5 "" - COPY USE F_GRUPPOINI2 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI2 - INPUT CONTO F_CONTOINI2 - INPUT CODCF F_SOTTOCONTOINI2 - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOINI2 GRUPPO - OUTPUT F_CONTOINI2 CONTO - OUTPUT F_SOTTOCONTOINI2 CODCF - OUTPUT F_DESCRINI2 RAGSOC - FLAGS "R" - GROUP 2 - MESSAGE COPY,F_SOTTOCONTOINI -END - -STRING F_DESCRINI2 50 -BEGIN - PROMPT 4 6 "Ragione sociale " - FLAGS "D" - GROUP 2 -END - -NUMBER F_GRUPPOFINE2 3 -BEGIN - PROMPT 4 7 "A Gruppo - Conto - Sottoconto " - COPY USE F_GRUPPOINI2 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE2 - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOFINE2 GRUPPO - OUTPUT F_CONTOFINE2 CONTO - OUTPUT F_SOTTOCONTOFINE2 CODCF - OUTPUT F_DESCRFINE2 RAGSOC - FLAGS "R" - GROUP 2 - MESSAGE COPY,F_GRUPPOFINE -END - -NUMBER F_CONTOFINE2 3 -BEGIN - PROMPT 41 7 "" - COPY USE F_GRUPPOINI2 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE2 - INPUT CONTO F_CONTOFINE2 - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOFINE2 GRUPPO - OUTPUT F_CONTOFINE2 CONTO - OUTPUT F_SOTTOCONTOFINE2 CODCF - OUTPUT F_DESCRFINE2 RAGSOC - FLAGS "R" - GROUP 2 - MESSAGE COPY,F_CONTOFINE -END - -NUMBER F_SOTTOCONTOFINE2 6 -BEGIN - PROMPT 47 7 "" - COPY USE F_GRUPPOINI2 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE2 - INPUT CONTO F_CONTOFINE2 - INPUT CODCF F_SOTTOCONTOFINE2 - DISPLAY "Tipo" TIPOCF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT F_GRUPPOFINE2 GRUPPO - OUTPUT F_CONTOFINE2 CONTO - OUTPUT F_SOTTOCONTOFINE2 CODCF - OUTPUT F_DESCRFINE2 RAGSOC - FLAGS "R" - GROUP 2 - MESSAGE COPY,F_SOTTOCONTOFINE -END - -STRING F_DESCRFINE2 50 -BEGIN - PROMPT 4 8 "Ragione sociale " - FLAGS "D" - GROUP 2 -END - -NUMBER F_GRUPPOINI3 3 -BEGIN - PROMPT 4 5 "Da Gruppo - Conto - Sottoconto " - USE LF_PCON -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI3 - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPOINI3 GRUPPO - OUTPUT F_CONTOINI3 CONTO - OUTPUT F_SOTTOCONTOINI3 SOTTOCONTO - OUTPUT F_DESCRINI3 DESCR - FLAGS "R" - GROUP 3 - MESSAGE COPY,F_GRUPPOINI -END - -NUMBER F_CONTOINI3 3 -BEGIN - PROMPT 41 5 "" - COPY USE F_GRUPPOINI3 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI3 - INPUT CONTO F_CONTOINI3 - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPOINI3 GRUPPO - OUTPUT F_CONTOINI3 CONTO - OUTPUT F_SOTTOCONTOINI3 SOTTOCONTO - OUTPUT F_DESCRINI3 DESCR - FLAGS "R" - GROUP 3 - MESSAGE COPY,F_CONTOINI -END - -NUMBER F_SOTTOCONTOINI3 6 -BEGIN - PROMPT 47 5 "" - COPY USE F_GRUPPOINI3 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOINI3 - INPUT CONTO F_CONTOINI3 - INPUT SOTTOCONTO F_SOTTOCONTOINI3 - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPOINI3 GRUPPO - OUTPUT F_CONTOINI3 CONTO - OUTPUT F_SOTTOCONTOINI3 SOTTOCONTO - OUTPUT F_DESCRINI3 DESCR - FLAGS "R" - GROUP 3 - MESSAGE COPY,F_SOTTOCONTOINI -END - -STRING F_DESCRINI3 50 -BEGIN - PROMPT 4 6 "Descrizione " - FLAGS "D" - GROUP 3 -END - -NUMBER F_GRUPPOFINE3 3 -BEGIN - PROMPT 4 7 "A Gruppo - Conto - Sottoconto " - COPY USE F_GRUPPOINI3 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE3 - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPOFINE3 GRUPPO - OUTPUT F_CONTOFINE3 CONTO - OUTPUT F_SOTTOCONTOFINE3 SOTTOCONTO - OUTPUT F_DESCRFINE3 DESCR - FLAGS "R" - GROUP 3 - MESSAGE COPY,F_GRUPPOFINE -END - -NUMBER F_CONTOFINE3 3 -BEGIN - PROMPT 41 7 "" - COPY USE F_GRUPPOFINE3 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE3 - INPUT CONTO F_CONTOFINE3 - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPOFINE3 GRUPPO - OUTPUT F_CONTOFINE3 CONTO - OUTPUT F_SOTTOCONTOFINE3 SOTTOCONTO - OUTPUT F_DESCRFINE3 DESCR - FLAGS "R" - GROUP 3 - MESSAGE COPY,F_CONTOFINE -END - -NUMBER F_SOTTOCONTOFINE3 6 -BEGIN - PROMPT 47 7 "" - COPY USE F_GRUPPOFINE3 -// CHECKTYPE NORMAL - INPUT GRUPPO F_GRUPPOFINE3 - INPUT CONTO F_CONTOFINE3 - INPUT SOTTOCONTO F_SOTTOCONTOFINE3 - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPOFINE3 GRUPPO - OUTPUT F_CONTOFINE3 CONTO - OUTPUT F_SOTTOCONTOFINE3 SOTTOCONTO - OUTPUT F_DESCRFINE3 DESCR - FLAGS "R" - GROUP 3 - MESSAGE COPY,F_SOTTOCONTOFINE -END - -STRING F_DESCRFINE3 50 -BEGIN - PROMPT 4 8 "Descrizione " - FLAGS "D" - GROUP 3 -END - -DATE F_DATAINI -BEGIN - PROMPT 26 10 "" -END - -DATE F_DATAFINE -BEGIN - PROMPT 62 10 "" -END - -BOOLEAN F_STAMPATOTIVA -BEGIN - PROMPT 4 12 "Stampa totali documenti IVA" -END - -BOOLEAN F_STAMPAPROGRE -BEGIN - PROMPT 44 12 "Stampa progressivi attuali" -END - -BOOLEAN F_STAMPAMOVPROV -BEGIN - PROMPT 4 13 "Stampa movimenti provvisori" -END - -LIST F_STAMPANUM 15 -BEGIN - PROMPT 4 15 "Stampa numerazione " - ITEM "1|Registrazione" - ITEM "2|Riga giornale" -END - -LIST F_TIPOSTAMPA 34 -BEGIN - PROMPT 4 16 "Tipo stampa " - ITEM "1|Mastrini movimentati nel periodo" - ITEM "2|Mastrini con saldi diversi da 0" - ITEM "3|Completa" -END - - -BOOLEAN F_MEMORIZZA -BEGIN - PROMPT 4 17 "Memorizza scelte" -END - -BUTTON DLG_OK 9 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 9 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -PAGE "" -1 -1 60 10 - -LIST F_NUMCARAT 10 -BEGIN - PROMPT 4 2 "Numero caratteri " - ITEM "1|132 crt." - ITEM "2|198 crt." -END - -LIST F_FORMATO 23 -BEGIN - PROMPT 4 4 "Formato modulo di stampa " - ITEM "66|11 pollici (27,94 cm)" - ITEM "72|12 pollici (30,48 cm)" -END - -LIST F_NUMMAST 5 -BEGIN - PROMPT 4 6 "Numero mastrini per pagina " - ITEM "1|Uno" - ITEM "2|Due" -END - -BUTTON DLG_OK 9 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 9 2 -BEGIN - PROMPT -22 -1 "" -END - - -ENDPAGE - -ENDMASK - - - - - - - +#include "cg3200.h" + +PAGE "Stampa Clienti e Fornitori" -1 -1 78 20 + + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 4 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + CHECKTYPE REQUIRED + INPUT CODDITTA F_CODDITTA + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale @50" RAGSOC + OUTPUT F_CODDITTA CODDITTA + OUTPUT F_RAGSOC RAGSOC +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 4 2 "Ragione sociale " + FLAGS "D" +END + +TEXT 96 +BEGIN + PROMPT 4 10 "Dalla data competenza " +END + +TEXT 97 +BEGIN + PROMPT 40 10 "Alla data competenza " +END + +TEXT 98 +BEGIN + PROMPT 4 10 "Dalla data operazione " +END + +TEXT 99 +BEGIN + PROMPT 40 10 "Alla data operazione " +END + +NUMBER F_ANNO 4 +BEGIN + PROMPT 47 1 "Anno esercizio " + HELP "Inserire un anno esercizio presente nella tabella oppure nulla: in questo caso non e' possibile fare il controllo competenza esercizio" + USE ESC + INPUT CODTAB F_ANNO + DISPLAY "Anno Esercizio" CODTAB + DISPLAY "Data inizio esercizio" D0 + DISPLAY "Data fine esercizio " D1 + OUTPUT F_ANNO CODTAB + CHECKTYPE NORMAL + MESSAGE HIDE,98|HIDE,99|SHOW,96|SHOW,97 + MESSAGE EMPTY HIDE,96|HIDE,97|SHOW,98|SHOW,99 + FLAGS "RZ" +END + +LIST F_RICERCA 25 +BEGIN + PROMPT 4 4 "Ricerca " + ITEM "C|Clienti" + MESSAGE HIDE,2@|HIDE,3@|RESET,2@|RESET,3@|SHOW,1@ + ITEM "F|Fornitori" + MESSAGE HIDE,1@|HIDE,3@|RESET,1@|RESET,3@|SHOW,2@ + ITEM "P|Gruppo/conto/sottoconto" + MESSAGE HIDE,1@|HIDE,2@|RESET,1@|RESET,2@|SHOW,3@ +END + +NUMBER F_GRUPPOINI 3 +BEGIN + PROMPT 4 5 "Da Gruppo - Conto - Sottoconto " + USE LF_CLIFO SELECT TIPOCF="C" +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOINI GRUPPO + OUTPUT F_CONTOINI CONTO + OUTPUT F_SOTTOCONTOINI CODCF + OUTPUT F_DESCRINI RAGSOC + FLAGS "R" + GROUP 1 +END + +NUMBER F_CONTOINI 3 +BEGIN + PROMPT 41 5 "" + COPY USE F_GRUPPOINI +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI + INPUT CONTO F_CONTOINI + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOINI GRUPPO + OUTPUT F_CONTOINI CONTO + OUTPUT F_SOTTOCONTOINI CODCF + OUTPUT F_DESCRINI RAGSOC + FLAGS "R" + GROUP 1 +END + +NUMBER F_SOTTOCONTOINI 6 +BEGIN + PROMPT 47 5 "" + COPY USE F_GRUPPOINI +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI + INPUT CONTO F_CONTOINI + INPUT CODCF F_SOTTOCONTOINI + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOINI GRUPPO + OUTPUT F_CONTOINI CONTO + OUTPUT F_SOTTOCONTOINI CODCF + OUTPUT F_DESCRINI RAGSOC + FLAGS "R" + GROUP 1 +END + +STRING F_DESCRINI 50 +BEGIN + PROMPT 4 6 "Ragione sociale " + FLAGS "D" + GROUP 1 +END + +NUMBER F_GRUPPOFINE 3 +BEGIN + PROMPT 4 7 "A Gruppo - Conto - Sottoconto " + COPY USE F_GRUPPOINI +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOFINE GRUPPO + OUTPUT F_CONTOFINE CONTO + OUTPUT F_SOTTOCONTOFINE CODCF + OUTPUT F_DESCRFINE RAGSOC + FLAGS "R" + GROUP 1 +END + +NUMBER F_CONTOFINE 3 +BEGIN + PROMPT 41 7 "" + COPY USE F_GRUPPOINI +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE + INPUT CONTO F_CONTOFINE + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOFINE GRUPPO + OUTPUT F_CONTOFINE CONTO + OUTPUT F_SOTTOCONTOFINE CODCF + OUTPUT F_DESCRFINE RAGSOC + FLAGS "R" + GROUP 1 +END + +NUMBER F_SOTTOCONTOFINE 6 +BEGIN + PROMPT 47 7 "" + COPY USE F_GRUPPOINI +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE + INPUT CONTO F_CONTOFINE + INPUT CODCF F_SOTTOCONTOFINE + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOFINE GRUPPO + OUTPUT F_CONTOFINE CONTO + OUTPUT F_SOTTOCONTOFINE CODCF + OUTPUT F_DESCRFINE RAGSOC + FLAGS "R" + GROUP 1 +END + +STRING F_DESCRFINE 50 +BEGIN + PROMPT 4 8 "Ragione sociale " + FLAGS "D" + GROUP 1 +END + +NUMBER F_GRUPPOINI2 3 +BEGIN + PROMPT 4 5 "Da Gruppo - Conto - Sottoconto " + USE LF_CLIFO SELECT TIPOCF="F" +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI2 + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOINI2 GRUPPO + OUTPUT F_CONTOINI2 CONTO + OUTPUT F_SOTTOCONTOINI2 CODCF + OUTPUT F_DESCRINI2 RAGSOC + FLAGS "R" + GROUP 2 + MESSAGE COPY,F_GRUPPOINI +END + +NUMBER F_CONTOINI2 3 +BEGIN + PROMPT 41 5 "" + COPY USE F_GRUPPOINI2 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI2 + INPUT CONTO F_CONTOINI2 + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOINI2 GRUPPO + OUTPUT F_CONTOINI2 CONTO + OUTPUT F_SOTTOCONTOINI2 CODCF + OUTPUT F_DESCRINI2 RAGSOC + FLAGS "R" + GROUP 2 + MESSAGE COPY,F_CONTOINI +END + +NUMBER F_SOTTOCONTOINI2 6 +BEGIN + PROMPT 47 5 "" + COPY USE F_GRUPPOINI2 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI2 + INPUT CONTO F_CONTOINI2 + INPUT CODCF F_SOTTOCONTOINI2 + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOINI2 GRUPPO + OUTPUT F_CONTOINI2 CONTO + OUTPUT F_SOTTOCONTOINI2 CODCF + OUTPUT F_DESCRINI2 RAGSOC + FLAGS "R" + GROUP 2 + MESSAGE COPY,F_SOTTOCONTOINI +END + +STRING F_DESCRINI2 50 +BEGIN + PROMPT 4 6 "Ragione sociale " + FLAGS "D" + GROUP 2 +END + +NUMBER F_GRUPPOFINE2 3 +BEGIN + PROMPT 4 7 "A Gruppo - Conto - Sottoconto " + COPY USE F_GRUPPOINI2 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE2 + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOFINE2 GRUPPO + OUTPUT F_CONTOFINE2 CONTO + OUTPUT F_SOTTOCONTOFINE2 CODCF + OUTPUT F_DESCRFINE2 RAGSOC + FLAGS "R" + GROUP 2 + MESSAGE COPY,F_GRUPPOFINE +END + +NUMBER F_CONTOFINE2 3 +BEGIN + PROMPT 41 7 "" + COPY USE F_GRUPPOINI2 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE2 + INPUT CONTO F_CONTOFINE2 + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOFINE2 GRUPPO + OUTPUT F_CONTOFINE2 CONTO + OUTPUT F_SOTTOCONTOFINE2 CODCF + OUTPUT F_DESCRFINE2 RAGSOC + FLAGS "R" + GROUP 2 + MESSAGE COPY,F_CONTOFINE +END + +NUMBER F_SOTTOCONTOFINE2 6 +BEGIN + PROMPT 47 7 "" + COPY USE F_GRUPPOINI2 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE2 + INPUT CONTO F_CONTOFINE2 + INPUT CODCF F_SOTTOCONTOFINE2 + DISPLAY "Tipo" TIPOCF + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Codice" CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_GRUPPOFINE2 GRUPPO + OUTPUT F_CONTOFINE2 CONTO + OUTPUT F_SOTTOCONTOFINE2 CODCF + OUTPUT F_DESCRFINE2 RAGSOC + FLAGS "R" + GROUP 2 + MESSAGE COPY,F_SOTTOCONTOFINE +END + +STRING F_DESCRFINE2 50 +BEGIN + PROMPT 4 8 "Ragione sociale " + FLAGS "D" + GROUP 2 +END + +NUMBER F_GRUPPOINI3 3 +BEGIN + PROMPT 4 5 "Da Gruppo - Conto - Sottoconto " + USE LF_PCON +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI3 + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPOINI3 GRUPPO + OUTPUT F_CONTOINI3 CONTO + OUTPUT F_SOTTOCONTOINI3 SOTTOCONTO + OUTPUT F_DESCRINI3 DESCR + FLAGS "R" + GROUP 3 + MESSAGE COPY,F_GRUPPOINI +END + +NUMBER F_CONTOINI3 3 +BEGIN + PROMPT 41 5 "" + COPY USE F_GRUPPOINI3 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI3 + INPUT CONTO F_CONTOINI3 + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPOINI3 GRUPPO + OUTPUT F_CONTOINI3 CONTO + OUTPUT F_SOTTOCONTOINI3 SOTTOCONTO + OUTPUT F_DESCRINI3 DESCR + FLAGS "R" + GROUP 3 + MESSAGE COPY,F_CONTOINI +END + +NUMBER F_SOTTOCONTOINI3 6 +BEGIN + PROMPT 47 5 "" + COPY USE F_GRUPPOINI3 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOINI3 + INPUT CONTO F_CONTOINI3 + INPUT SOTTOCONTO F_SOTTOCONTOINI3 + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPOINI3 GRUPPO + OUTPUT F_CONTOINI3 CONTO + OUTPUT F_SOTTOCONTOINI3 SOTTOCONTO + OUTPUT F_DESCRINI3 DESCR + FLAGS "R" + GROUP 3 + MESSAGE COPY,F_SOTTOCONTOINI +END + +STRING F_DESCRINI3 50 +BEGIN + PROMPT 4 6 "Descrizione " + FLAGS "D" + GROUP 3 +END + +NUMBER F_GRUPPOFINE3 3 +BEGIN + PROMPT 4 7 "A Gruppo - Conto - Sottoconto " + COPY USE F_GRUPPOINI3 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE3 + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPOFINE3 GRUPPO + OUTPUT F_CONTOFINE3 CONTO + OUTPUT F_SOTTOCONTOFINE3 SOTTOCONTO + OUTPUT F_DESCRFINE3 DESCR + FLAGS "R" + GROUP 3 + MESSAGE COPY,F_GRUPPOFINE +END + +NUMBER F_CONTOFINE3 3 +BEGIN + PROMPT 41 7 "" + COPY USE F_GRUPPOFINE3 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE3 + INPUT CONTO F_CONTOFINE3 + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPOFINE3 GRUPPO + OUTPUT F_CONTOFINE3 CONTO + OUTPUT F_SOTTOCONTOFINE3 SOTTOCONTO + OUTPUT F_DESCRFINE3 DESCR + FLAGS "R" + GROUP 3 + MESSAGE COPY,F_CONTOFINE +END + +NUMBER F_SOTTOCONTOFINE3 6 +BEGIN + PROMPT 47 7 "" + COPY USE F_GRUPPOFINE3 +// CHECKTYPE NORMAL + INPUT GRUPPO F_GRUPPOFINE3 + INPUT CONTO F_CONTOFINE3 + INPUT SOTTOCONTO F_SOTTOCONTOFINE3 + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPOFINE3 GRUPPO + OUTPUT F_CONTOFINE3 CONTO + OUTPUT F_SOTTOCONTOFINE3 SOTTOCONTO + OUTPUT F_DESCRFINE3 DESCR + FLAGS "R" + GROUP 3 + MESSAGE COPY,F_SOTTOCONTOFINE +END + +STRING F_DESCRFINE3 50 +BEGIN + PROMPT 4 8 "Descrizione " + FLAGS "D" + GROUP 3 +END + +DATE F_DATAINI +BEGIN + PROMPT 26 10 "" +END + +DATE F_DATAFINE +BEGIN + PROMPT 62 10 "" +END + +BOOLEAN F_STAMPATOTIVA +BEGIN + PROMPT 4 12 "Stampa totali documenti IVA" +END + +BOOLEAN F_STAMPAPROGRE +BEGIN + PROMPT 44 12 "Stampa progressivi attuali" +END + +BOOLEAN F_STAMPAMOVPROV +BEGIN + PROMPT 4 13 "Stampa movimenti provvisori" +END + +LIST F_STAMPANUM 15 +BEGIN + PROMPT 4 15 "Stampa numerazione " + ITEM "1|Registrazione" + ITEM "2|Riga giornale" +END + +LIST F_TIPOSTAMPA 34 +BEGIN + PROMPT 4 16 "Tipo stampa " + ITEM "1|Mastrini movimentati nel periodo" + ITEM "2|Mastrini con saldi diversi da 0" + ITEM "3|Completa" +END + + +BOOLEAN F_MEMORIZZA +BEGIN + PROMPT 4 17 "Memorizza scelte" +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +PAGE "" -1 -1 60 10 + +LIST F_NUMCARAT 10 +BEGIN + PROMPT 4 2 "Numero caratteri " + ITEM "1|132 crt." + ITEM "2|198 crt." +END + +LIST F_FORMATO 23 +BEGIN + PROMPT 4 4 "Formato modulo di stampa " + ITEM "66|11 pollici (27,94 cm)" + ITEM "72|12 pollici (30,48 cm)" +END + +LIST F_NUMMAST 5 +BEGIN + PROMPT 4 6 "Numero mastrini per pagina " + ITEM "1|Uno" + ITEM "2|Due" +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + + +ENDPAGE + +ENDMASK + + + + + + + diff --git a/cg/cglib.h b/cg/cglib.h index d89df5e14..670724884 100755 --- a/cg/cglib.h +++ b/cg/cglib.h @@ -1,115 +1,115 @@ -#ifndef __CGLIB_H -#define __CGLIB_H - -#ifndef __ISAM_H -#include -#endif -#ifndef __REAL_H -#include -#endif -#ifndef __DATE_H -#include -#endif - -#include -//#include -//#include -//#include - -#include "conto.h" - -TLocalisamfile * get_descr_cf(TLocalisamfile * pconti, - TLocalisamfile * clifo , int g, int c, long s); - - class TClifo_list : public TArray -{ -public: - TClifo_list(int g, int c, char tipocf); - TRectype& clifo(int i)const { return(TRectype&)this->operator[](i); } -}; - -class Saldo -{ - real _saldo, _saldo_iniziale, _prg_dare, _prg_avere; - int _indbil; - TLocalisamfile * _saldi, *_rmov, *_clifo, *_mov; - TRectype* _rec; - -public: - bool causale_mov(long, const TDate&, const TDate&, TString&); - const char* causale_chiusura_es(); - const char* causale_apertura_es(); - bool calcola_data_limite(int,int,int,long,const TDate&,const TDate&,int,bool, - const TDate&,const TDate&,const TDate&,bool); - bool calcola_ultima_immissione(int, int, int, int, long, int); - real calcola_saldo_iniziale(int, int, int, long, int); - bool calcola_clifo(int, int, int, int, int); - TRectype& ricerca_progr_prec(int, int, int, long); - real saldofin_esprec(int,int,int,long); - real saldo() {return _saldo;} - real saldoini() {return _saldo_iniziale;} - real prgdare() {return _prg_dare;} - real prgavere() {return _prg_avere;} - bool calcola(int,int,int,int,long,const TDate&,const TDate&,int,bool, - const TDate&,const TDate&,const TDate&,bool); - bool prg_attuali(int,TConto&,int,real&,real&); - bool prg_mov_eliminati(int,TConto&,int,real&,real&); - Saldo(); - ~Saldo(); -}; - -class TTab_conti : public TAssoc_array -{ - void do_agg(TConto* tc, int anno_es, const real& importo, char sezione, - bool movap, bool provv, bool somma, const char* key); -public: - void aggiorna_conto(const TConto& tc, int anno_es, const real& importo, - char sezione, bool movap, bool provv, bool somma); - void aggiorna_conto (int gruppo, int conto, long sottoconto, int anno_es, - const real& importo, char sezione, bool movap, - bool provv, bool somma); -}; - -class TSaldo_agg : public TObject -{ - TTab_conti _tab_conti; - bool _movap; // se e' mov. d'apertura (aggiorno SALDO e FLAGSALINI in - // saldi) - bool _provv; - int _anno_es; // anno esercizio - TDate _data_ulmov; // data ultimo movimento - long _num_ulmov; // numero ultimo movimento - - TConto& tconti() { return *(TConto*)_tab_conti.get(); } - -public: - void clear_saldi(int year); - void registra(); - void aggiorna (const TConto& tc, const real& importo, char sezione, - bool somma=TRUE); - void aggiorna (int gruppo, int conto, long sottoconto, const real& importo, - char sezione, bool somma=TRUE); - - void set_anno_es(int anno) { _anno_es = anno; } - int anno_es() const { return _anno_es; } - - void set_movap (bool movap) { _movap = movap; } - bool movap() const { return _movap; } - - void set_movprovv (bool p) { _provv = p; } - bool movprovv() { return _provv; } - - void set_data_ulmov (const TDate& data) { _data_ulmov = data; } - const TDate& data_ulmov() const { return _data_ulmov; } - - void set_num_ulmov (long num) { _num_ulmov = num; } - long num_ulmov() const { return _num_ulmov; } - - void reset(); // pulisce l'array dei conti - TSaldo_agg(); - int items() const { return _tab_conti.items();} -}; - - -#endif - +#ifndef __CGLIB_H +#define __CGLIB_H + +#ifndef __ISAM_H +#include +#endif +#ifndef __REAL_H +#include +#endif +#ifndef __DATE_H +#include +#endif + +#include +//#include +//#include +//#include + +#include "conto.h" + +TLocalisamfile * get_descr_cf(TLocalisamfile * pconti, + TLocalisamfile * clifo , int g, int c, long s); + + class TClifo_list : public TArray +{ +public: + TClifo_list(int g, int c, char tipocf); + TRectype& clifo(int i)const { return(TRectype&)this->operator[](i); } +}; + +class Saldo +{ + real _saldo, _saldo_iniziale, _prg_dare, _prg_avere; + int _indbil; + TLocalisamfile * _saldi, *_rmov, *_clifo, *_mov; + TRectype* _rec; + +public: + bool causale_mov(long, const TDate&, const TDate&, TString&); + const char* causale_chiusura_es(); + const char* causale_apertura_es(); + bool calcola_data_limite(int,int,int,long,const TDate&,const TDate&,int,bool, + const TDate&,const TDate&,const TDate&,bool); + bool calcola_ultima_immissione(int, int, int, int, long, int); + real calcola_saldo_iniziale(int, int, int, long, int); + bool calcola_clifo(int, int, int, int, int); + TRectype& ricerca_progr_prec(int, int, int, long); + real saldofin_esprec(int,int,int,long); + real saldo() {return _saldo;} + real saldoini() {return _saldo_iniziale;} + real prgdare() {return _prg_dare;} + real prgavere() {return _prg_avere;} + bool calcola(int,int,int,int,long,const TDate&,const TDate&,int,bool, + const TDate&,const TDate&,const TDate&,bool); + bool prg_attuali(int,TConto&,int,real&,real&); + bool prg_mov_eliminati(int,TConto&,int,real&,real&); + Saldo(); + ~Saldo(); +}; + +class TTab_conti : public TAssoc_array +{ + void do_agg(TConto* tc, int anno_es, const real& importo, char sezione, + bool movap, bool provv, bool somma, const char* key); +public: + void aggiorna_conto(const TConto& tc, int anno_es, const real& importo, + char sezione, bool movap, bool provv, bool somma); + void aggiorna_conto (int gruppo, int conto, long sottoconto, int anno_es, + const real& importo, char sezione, bool movap, + bool provv, bool somma); +}; + +class TSaldo_agg : public TObject +{ + TTab_conti _tab_conti; + bool _movap; // se e' mov. d'apertura (aggiorno SALDO e FLAGSALINI in + // saldi) + bool _provv; + int _anno_es; // anno esercizio + TDate _data_ulmov; // data ultimo movimento + long _num_ulmov; // numero ultimo movimento + + TConto& tconti() { return *(TConto*)_tab_conti.get(); } + +public: + void clear_saldi(int year); + void registra(); + void aggiorna (const TConto& tc, const real& importo, char sezione, + bool somma=TRUE); + void aggiorna (int gruppo, int conto, long sottoconto, const real& importo, + char sezione, bool somma=TRUE); + + void set_anno_es(int anno) { _anno_es = anno; } + int anno_es() const { return _anno_es; } + + void set_movap (bool movap) { _movap = movap; } + bool movap() const { return _movap; } + + void set_movprovv (bool p) { _provv = p; } + bool movprovv() { return _provv; } + + void set_data_ulmov (const TDate& data) { _data_ulmov = data; } + const TDate& data_ulmov() const { return _data_ulmov; } + + void set_num_ulmov (long num) { _num_ulmov = num; } + long num_ulmov() const { return _num_ulmov; } + + void reset(); // pulisce l'array dei conti + TSaldo_agg(); + int items() const { return _tab_conti.items();} +}; + + +#endif +