From c1f34b5518bc1a29e1e9a22a5d01c9b5eb4e674c Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 7 May 2015 10:28:30 +0000 Subject: [PATCH] git-svn-id: svn://10.65.10.50/branches/R_10_00@23078 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg1311.cpp | 151 +++++++++++++++++++++++++++++++++++++++++++++++++ cg/cg2100.cpp | 7 --- cg/cg2100.h | 1 - cg/cg2102.cpp | 2 +- cg/cg4301.cpp | 11 ++-- cg/cg6900.cpp | 6 +- cg/cglib03.cpp | 44 ++++++++++---- 7 files changed, 195 insertions(+), 27 deletions(-) create mode 100644 cg/cg1311.cpp diff --git a/cg/cg1311.cpp b/cg/cg1311.cpp new file mode 100644 index 000000000..980538274 --- /dev/null +++ b/cg/cg1311.cpp @@ -0,0 +1,151 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class TXRef_mask : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event fe, long jolly); + void test_rmov(); + +public: + TXRef_mask(const char* title); +}; + +void TXRef_mask::test_rmov() +{ + TLog_report log; + + TFast_isamfile mov(LF_MOV); + TFast_isamfile part(LF_PARTITE); part.setkey(2); + + TString msg; + TISAM_recordset rmov_set("USE RMOV"); + const TRectype& rmov = rmov_set.cursor()->curr(); + TProgress_monitor pm(rmov_set.items(), TR("Scansione righe contabili")); + for (bool ok = rmov_set.move_first(); ok; ok = rmov_set.move_next()) + { + if (!pm.add_status(1)) + break; + const long numreg = rmov.get_long(RMV_NUMREG); + const int numrig = rmov.get_int(RMV_NUMRIG); + + msg.format(FR("Riga %3d del movimento %7ld del %s: "), numrig, numreg, (const char*)rmov.get(RMV_DATAREG)); + + if (numreg != mov.get_long(MOV_NUMREG)) + { + mov.put(MOV_NUMREG, numreg); + if (mov.read() != NOERR) + mov.zero(); + } + if (numreg != mov.get_long(MOV_NUMREG)) + { + msg << TR("manca il record di testata"); + log.log(2, msg); + } + if (rmov.get_char(RMV_ROWTYPE) == 'K') + { + part.put(PART_NREG, numreg); + part.put(PART_NUMRIG, numrig); + if (part.read() != NOERR) + { + msg << TR("manca il record di saldaconto"); + log.log(2, msg); + } + } + } + + log.preview(); +} + +bool TXRef_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case DLG_USER: + if (e == fe_button) + { + TArray_sheet sheet(-1, -1, 70, 20, TR("Scelta ditta"), HR("Codice|Ragione Sociale@50")); + TToken_string row; + TLocalisamfile ditte(LF_NDITTE); + + FOR_EACH_FILE_RECORD(ditte) + { + const long cod = ditte.get_long(NDT_CODDITTA); + if (prefix().exist(cod)) + { + row.cut(0); + row.add(cod); + row.add(ditte.get(NDT_RAGSOC)); + + const long pos = sheet.add(row); + if (cod == prefix().get_codditta()) + sheet.select(pos); + } + } + if (sheet.run() == K_ENTER) + set(DLG_USER, sheet.row().get(0), 0x3); + return false; + } + if (e == fe_modify || e == fe_close) + { + const long cod = atol(o.get()); + if (prefix().exist(cod)) + prefix().set_codditta(cod); + else + return error_box(FR("La ditta %05ld non č attivata per la contabilitā"), cod); + } + break; + case DLG_SELECT: + if (e == fe_button) + { + test_rmov(); + return false; + } + break; + default: + break; + } + return true; +} + +TXRef_mask::TXRef_mask(const char* title) : TAutomask(title, 1, 30, 5) +{ + add_number(DLG_USER, 0, TR("Codice ditta "), 1, 1, 5, "BUF"); + add_button(DLG_SELECT, 0, "", -12, -1, 10, 2); + add_button(DLG_QUIT, 0, "", -22, -1, 10, 2); + set_handlers(); +} + + +class TXRef_check: public TSkeleton_application +{ +public: + const char* app_name() const { return TR("Controllo integritā archivi"); } + virtual void main_loop(); +}; + +void TXRef_check::main_loop() +{ + open_files(LF_CLIFO, LF_NDITTE, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA, + LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0); + + TXRef_mask m(app_name()); + while (m.run() != K_QUIT); +} + +void xref_check(int argc, char* argv[]) +{ + TXRef_check ez; + ez.run(argc, argv, ez.app_name()); +} diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index db52db3ed..9f6b95649 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -805,13 +805,6 @@ void TPrimanota_application::init_insert_mode(TMask& m) init_mask(m); m.first_focus(_firstfocus); - if (m.get_long(F_NUMREG) <= 0) - { - const long nreg = _msk[0]->get_long(F_CC_NUMREG); - if (nreg > 0) - m.set(F_NUMREG, nreg); - } - if (causale().reg().agenzia_viaggi()) m.set(F_DATA74TER, m.get(F_DATAREG)); diff --git a/cg/cg2100.h b/cg/cg2100.h index c12c409e2..c2c4388e2 100755 --- a/cg/cg2100.h +++ b/cg/cg2100.h @@ -19,7 +19,6 @@ #define F_DATACOMP 116 #define F_ANNOIVA 117 #define F_NUMDOCEXT 130 -#define F_CC_NUMREG 163 #define F_CLIFO 128 #define F_CLIENTE 151 diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 90bca229a..f3fc0cbad 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -2198,7 +2198,7 @@ bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key) TEdit_field& numreg = m.efield(F_NUMREG); TString16 filter; if (cau.full()) filter << MOV_CODCAUS << "==\"" << cau << '"'; numreg.browse()->set_filter(filter); - + const TipoIVA i = app().cau2IVA(cau, ann); // Cerca causale e suo tipo if (i != iva_errata) return suspended_handler(f, key); // Controlla sospensione diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index d12e1a562..6b6408783 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -1075,11 +1075,14 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const int tipatt = trueatt[5] - '0'; trueatt.cut(5); - TString pimsg; pimsg << TR("Ricalcolo attivitā ") << trueatt << " (mese " << month << ')'; - TProgind pi(items, pimsg, false, true); + TString pimsg; + pimsg << TR("Ricalcolo attivitā ") << trueatt << " (" << TR("mese ") + << (month > 12 ? "13" : itom(month)) << ')'; + + TProgress_monitor pi(items, pimsg, false); for (; _cur->pos() < items; ++(*_cur)) { - if (!pi.setstatus(_cur->pos())) + if (!pi.set_status(_cur->pos())) break; TDate date = _mov->get(MOV_DATAREG); @@ -1100,7 +1103,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } #ifndef NDEBUG - if (_mov->get_long(MOV_NUMREG) == 21438) + if (_mov->get_long(MOV_NUMREG) >= 132) int cazzone = 1; #endif diff --git a/cg/cg6900.cpp b/cg/cg6900.cpp index 5a9106885..fec13fd14 100755 --- a/cg/cg6900.cpp +++ b/cg/cg6900.cpp @@ -27,7 +27,7 @@ TInv_cont::TInv_cont(char mov) : _scelta(toupper(mov)) bool TInv_cont::messaggio_hnd(TMask_field& f, KEY k) { if (k == K_TAB) - return message_box("Rilevato STATO DI RIPARTENZA: il trasferimento ripartira' automaticamente"); + return message_box("Rilevato STATO DI RIPARTENZA: il trasferimento ripartirā automaticamente"); return TRUE; } @@ -623,12 +623,12 @@ bool TInv_cont::controlli() { if (_esiste_ditta && !_esiste_record) return error_box(FR("Rilevato stato di ripartenza con dati contradditori:\n" - "Ditta %ld in tabella studio per invio senza record."), _ditta); + "Ditta %ld in tabella %%INS per invio senza record HEADER."), _ditta); if (!_esiste_ditta && _esiste_record) { return error_box("Rilevato stato di ripartenza con dati contradditori:\n" - "esiste un record senza nessuna ditta in %%INS."); + "esiste un record HEADER senza nessuna ditta in %%INS."); } if (_esiste_ditta && _esiste_record) diff --git a/cg/cglib03.cpp b/cg/cglib03.cpp index a19b0b325..502684630 100755 --- a/cg/cglib03.cpp +++ b/cg/cglib03.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -134,13 +135,13 @@ bool gestione_IVAxCassa(const TDate& data_mov, long firm) return yes; } -static bool mov_has_imposte(const TRectype& mov) +static tipo_movimento get_tipo_movimento(const TRectype& mov) { - const char tipocf = mov.get_char(MOV_TIPO); - if (tipocf == 'C' || tipocf == 'F') + tipo_movimento tm = (tipo_movimento)mov.get_int(MOV_TIPOMOV); + if (tm == tm_nessuno) { - tipo_movimento tm = (tipo_movimento)mov.get_int(MOV_TIPOMOV); - if (tm == tm_nessuno) + const char tipocf = mov.get_char(MOV_TIPO); + if (tipocf == 'C' || tipocf == 'F') { const TString& tipodoc = mov.get(MOV_TIPODOC); if (tipodoc == "FV" || tipodoc == "FA") @@ -148,15 +149,23 @@ static bool mov_has_imposte(const TRectype& mov) if (tipodoc == "NC") tm = tm_nota_credito; } - return tm == tm_fattura || tm == tm_nota_credito; } - - return false; + return tm; +} + +static bool mov_has_imposte(const TRectype& mov) +{ + const tipo_movimento tm = get_tipo_movimento(mov); + return tm == tm_fattura || tm == tm_nota_credito; } bool is_split_payment(const TRectype& mov) { - if (mov_has_imposte(mov) && mov.get_int(MOV_ANNOIVA) >= 2015 && mov.get_real(MOV_RITFIS).is_zero()) + bool yes = false; + if (mov.get_char(MOV_TIPO) != 'C') + return yes; + + if (mov.get_int(MOV_ANNOIVA) >= 2015 && mov.get_real(MOV_RITFIS).is_zero() && mov_has_imposte(mov)) { const TRectype& clifo = cache().get_rec(LF_CLIFO, "C", mov.get(MOV_CODCF)); if (clifo.get_bool(CLI_SPLITPAY)) // Ente pubblico con split payment @@ -164,10 +173,23 @@ bool is_split_payment(const TRectype& mov) const TRectype& rcs = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS)); const int rsi = rcs.get_int(CAU_REGSPIVA); // Regime speciale IVA if (rsi != 13 && rsi != 50 && rsi != 51) // No reverse charge! - return true; + yes = true; + + if (yes && get_tipo_movimento(mov) == tm_nota_credito) // Controlla le N.C. + { + if (mov.get_bool(MOV_LIQDIFF)) + yes = false; + else + { + TISAM_recordset par("USE PART KEY 2 SELECT ANNO<2015\nFROM NREG=#NR\nTO NREG=#NR"); + par.set_var("#NR", mov.get_long(MOV_NUMREG)); + if (!par.empty()) // Se la nota si rifersice a partite vecchie non ha lo split payment + yes = false; + } + } } } - return false; + return yes; } bool is_IVA_diff(const TRectype& mov)