diff --git a/cg/cg7200.cpp b/cg/cg7200.cpp index 0f5b1875c..c265807b1 100755 --- a/cg/cg7200.cpp +++ b/cg/cg7200.cpp @@ -1,12 +1,52 @@ #include #include +#include +#include #include -#include +#include +#include #include "../ba/ba8500.h" #include "../cg/cg7200a.h" +/////////////////////////////////////////////////////////// +// Recordset +/////////////////////////////////////////////////////////// +class TPrint_x_imponibile_recordset : public TISAM_recordset +{ + static real _limite; + +protected: + static bool filtro(const TRelation* rel); + virtual void set_custom_filter(TCursor& cursor) const; + +public: + TPrint_x_imponibile_recordset(const TString& sql) : TISAM_recordset(sql) {} +}; + +real TPrint_x_imponibile_recordset::_limite; + +bool TPrint_x_imponibile_recordset::filtro(const TRelation* rel) +{ + const TRectype& rec = rel->curr(); + + const TString& keytok = rec.get(MOV_NUMREG); + TRecord_array righe_iva(keytok, LF_RMOVIVA); + + real tot_imponibile; + for (int r = righe_iva.last_row(); r > 0; r = righe_iva.pred_row(r)) + tot_imponibile += righe_iva.row(r).get_real(RMI_IMPONIBILE); + + return tot_imponibile > _limite; +} + +void TPrint_x_imponibile_recordset::set_custom_filter(TCursor& cursor) const +{ + _limite = get("#LIMITE").as_real(); + cursor.set_filterfunction(filtro); +} + /////////////////////////////////////////////////////////// // Report /////////////////////////////////////////////////////////// @@ -17,9 +57,16 @@ protected: virtual bool use_mask() { return false; } public: + virtual bool set_recordset(const TString& sql); TPrint_x_imponibile_report(); }; +bool TPrint_x_imponibile_report::set_recordset(const TString& sql) +{ + TPrint_x_imponibile_recordset* recset = new TPrint_x_imponibile_recordset(sql); + return TReport::set_recordset(recset); +} + TPrint_x_imponibile_report::TPrint_x_imponibile_report() { load("cg7200a"); @@ -49,25 +96,43 @@ void TPrint_x_imponibile_mask::elabora() const int anno = get_int(F_ANNO); const TDate dataini = get_date(F_DATAINI); const TDate datafin = get_date(F_DATAFIN); + const real limite = get_real(F_LIMITE); + const real limite_farlocco = limite * 0.60; TString query; + query << "USE MOV KEY 3"; + query << "\nSELECT (TOTDOC>=" << limite_farlocco.integer() << ")"; if (tipodate == 'R') //per data di 'R'egistrazione { - query << "USE MOV KEY 3"; - - query << "\nSELECT (ANNOIVA=" << anno << ")"; + if (codcf <= 0L) + query << "&&(BETWEEN(DATAREG," << dataini.date2ansi() << "," << datafin.date2ansi() << "))"; query << "\nFROM TIPO=" << tipoelenco; - query << " CODCF=" << codcf; - query << " DATAREG=" << dataini.date2ansi(); + if (codcf > 0L) + { + query << " CODCF=" << codcf; + query << " DATAREG=" << dataini.date2ansi(); + } query << "\nTO TIPO=" << tipoelenco; - query << " CODCF=" << (codcf > 0L ? codcf : 999999); - query << " DATAREG=" << datafin.date2ansi(); + if (codcf > 0L) + { + query << " CODCF=" << codcf; + query << " DATAREG=" << datafin.date2ansi(); + } } else //per data 'D'ocumento { + query << "&&(BETWEEN(DATADOC," << dataini.date2ansi() << "," << datafin.date2ansi() << "))"; + query << "\nBY CODCF DATADOC"; + query << "\nFROM TIPO=" << tipoelenco; + if (codcf > 0L) + query << " CODCF=" << codcf; + + query << "\nTO TIPO=" << tipoelenco; + if (codcf > 0L) + query << " CODCF=" << codcf; } TPrint_x_imponibile_report rep; diff --git a/cg/cg7200a.rep b/cg/cg7200a.rep index 94537fc3d..891829690 100755 --- a/cg/cg7200a.rep +++ b/cg/cg7200a.rep @@ -95,7 +95,7 @@ THEN MESSAGE RESET,F2 - MESSAGE ISAMREAD,20,TIPOCF=#H1.101!CODCF=#151,RAGSOC + MESSAGE ISAMREAD,20,TIPOCF=#H1.101!CODCF=#151,RAGSOC CODCF @@ -110,22 +110,29 @@ THEN USE RMOVIVA FROM NUMREG=#PARENT.NUMREG TO NUMREG=#PARENT.NUMREG - + NUMRIG - + IMPONIBILE - + IMPOSTA - + + PARENT.TIPODOC + +
  • 251 ENABLE
  • +
  • 251 DISABLE "IMPONIBILE" @ "F11.235" +! "IMPOSTA" @ "F11.236" +!
  • +
    +
    + CODIVA - - MESSAGE TABLEREAD,%IVA,CODIVA,S1 + + MESSAGE TABLEREAD,%IVA,CODIVA,S1 -
  • "IMPONIBILE" @ "F11.201" +! "IMPOSTA" @ "F11.202" +!
  • +
  • "IMPONIBILE" @ "F11.201" +! "IMPOSTA" @ "F11.202" +!
  • "IMPONIBILE" @ "F11.211" +! "IMPOSTA" @ "F11.212" +!
  • "IMPONIBILE" @ "F11.221" +! "IMPOSTA" @ "F11.222" +!
  • "IMPONIBILE" @ "F11.231" +! "IMPOSTA" @ "F11.232" +!
  • @@ -215,6 +222,20 @@ THEN "H1.102" @ E;= IF #THIS @ "F1.232" +! +THEN +
    + + @@ -249,7 +270,7 @@ THEN - REPORT.PAGE + #REPORT.PAGE
    @@ -265,6 +286,7 @@ THEN + @@ -273,6 +295,8 @@ THEN + +