Patch level :2.0 nopatch

Files correlati     :cm1 & friends
Ricompilazione Demo : [ ]
Commento            :prima stesura personalizzazione commesse CRPA


git-svn-id: svn://10.65.10.50/trunk@11658 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2003-12-10 12:10:52 +00:00
parent 65404d48f1
commit c8cd2bf9bd
7 changed files with 584 additions and 0 deletions

37
cm/cm1.cpp Executable file
View File

@ -0,0 +1,37 @@
#include <xvt.h>
#include "cm1.h"
int main(int argc, char** argv)
{
const int op = argc < 2 ? 0 : argv[1][1]-'0';
switch (op)
{
// case 1: cm1200(argc,argv); break; //
default: cm1100(argc,argv); break; //stampa pagato per commessa
}
exit(0);
return 0;
}

20
cm/cm1.h Executable file
View File

@ -0,0 +1,20 @@
#ifndef __CM1_H
#define __CM1_H
int cm1100(int argc, char* argv[]);
#endif // __CM1_H

315
cm/cm1100.cpp Executable file
View File

@ -0,0 +1,315 @@
#include <applicat.h>
#include <automask.h>
#include <form.h>
#include <printer.h>
#include <partite.h>
#include <mov.h>
#include <rmoviva.h>
#include "..\cg\cgsaldac.h"
#include "..\ve\velib.h"
#include "cm1100a.h"
#include "cm1100.h"
//===============================================================================================
//maschera
class TPag_per_cms_mask: public TAutomask
{
public:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
TPag_per_cms_mask():TAutomask("cm1100a") {}
};
bool TPag_per_cms_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
/* switch (o.dlg())
{
default: break;
}*/
return true;
}
//===============================================================================================
//struct dei dati da passare in stampa
struct TPag_per_cms_struct : public TObject
{
long _codforn;
TDate _datapag;
TCurrency _importopagato;
TString _descrpagamento;
long _nreg;
TString _commessa;
TCurrency _importocommessa;
};
//===============================================================================================
//form
class TPag_per_cms_form : public TForm
{
TArray& _pagamenti; //puntatore all'arrayone dei pagamenti
int _curr_pag; //pagamento corrente
protected:
virtual long records() const {return _pagamenti.items();}
bool validate(TForm_item &cf, TToken_string &s);
const TPag_per_cms_struct& curr() const { return(TPag_per_cms_struct&)_pagamenti[_curr_pag]; }
public:
void print(const TMask& m);
TPag_per_cms_form(TArray& pag);
virtual ~TPag_per_cms_form();
};
bool TPag_per_cms_form::validate(TForm_item &cf, TToken_string &s)
{
if (s == "_NEXTPAG")
{
_curr_pag ++; //aggiorna il contatore pagamenti quando ne trova uno sull'arrayone
return true;
}
if (s == "_CODCMS")
{
cf.set(curr()._commessa);
return true;
}
if (s == "_TOTDOC")
{
cf.set(curr()._importocommessa.get_num().string());
return true;
}
if (s == "_TOTPAG")
{
cf.set(curr()._importopagato.get_num().string());
return true;
}
return TForm::validate(cf,s);
}
void TPag_per_cms_form::print(const TMask& m)
{
TPrint_section& header = section('H', odd_page);
header.find_field(FR_DATAINI).set(m.get(F_DATAINI));
header.find_field(FR_DATAFIN).set(m.get(F_DATAFIN));
header.find_field(FR_DACDC).set(m.get(F_DACDC));
header.find_field(FR_ACDC).set(m.get(F_ACDC));
_curr_pag = 0;
TForm::print(); //chiama la vera print dopo aver azzerato il contatore
}
TPag_per_cms_form::TPag_per_cms_form(TArray& pag) :TForm ("cm1100a"), _pagamenti(pag)
{
}
TPag_per_cms_form::~TPag_per_cms_form()
{
}
//===============================================================================================
//Applicazione
class TPag_per_cms : public TSkeleton_application
{
TPag_per_cms_mask* _mask;
TPag_per_cms_form* _form;
TArray _pagamenti;
protected:
virtual void main_loop();
virtual bool create();
virtual bool destroy();
public:
long find_movimento(const TRectype& riga_pag);
void find_commesse(const long nreg, const TRectype& riga_pag, const char * tipodata);
};
long TPag_per_cms::find_movimento(const TRectype& riga_pag)
{
int n_fatture = 0; //numero di fatture trovate
int first_fatt = 0; //numero riga della prima fattura
//scan della partita dall'ultima alla prima riga
TPartita partita(riga_pag);
for (int p = partita.last(); p > 0; p = partita.pred(p))
{
const TRiga_partite& fatt = partita.riga(p);
if (fatt.is_fattura())
{
n_fatture ++;
first_fatt = p;
}
}
if (n_fatture > 1)
{
const int linea_pag = riga_pag.get_int(PART_NRIGA);
int linea_fattura = 0;
for (int f = first_fatt; (f > 0) && (f <= partita.last()) && (linea_fattura == 0); f = partita.succ(f))
{
const TRiga_partite& fatt = partita.riga(f);
if (fatt.is_fattura())
{
for (int r = 1; r <= fatt.rate(); r++)
{
const TRiga_scadenze& rata = fatt.rata(r);
if (rata.exist(linea_pag))
{
linea_fattura = f;
break;
}
}
}
}
first_fatt = linea_fattura;
}
long nreg = 0;
if (first_fatt > 0)
{
const TRiga_partite& fatt = partita.riga(first_fatt);
nreg = fatt.get_long(PART_NREG);
}
return nreg;
}
void TPag_per_cms::find_commesse(const long nreg, const TRectype& riga_pag, const char * tipodata)
{
TMovimentoPN pn;
pn.curr().put(MOV_NUMREG, nreg);
if (pn.read() == NOERR)
{
const real totdoc = pn.curr().get_real(MOV_TOTDOC);
const real totpagato = riga_pag.get_real(PART_IMPORTO);
const real percentuale = totpagato / totdoc;
TAssoc_array commesse;
for (int i = 0; i < pn.iva_items(); i++)
{
const TRectype& rmoviva = pn.iva(i);
const TString80 codcms = rmoviva.get(RMI_CODCMS);
if (codcms.not_empty())
{
real* imp = (real*)commesse.objptr(codcms);
if (imp == NULL)
{
imp = new real;
commesse.add(codcms, imp);
}
real importo = rmoviva.get_real(RMI_IMPONIBILE) + rmoviva.get_real(RMI_IMPOSTA);
*imp += importo;
}
}
FOR_EACH_ASSOC_OBJECT(commesse, h, k, imp)
{
const real& impcms = *(real*)imp;
TPag_per_cms_struct* ppcs = new TPag_per_cms_struct;
ppcs->_codforn = riga_pag.get_long(PART_SOTTOCONTO);
ppcs->_datapag = riga_pag.get_date(tipodata);
ppcs->_importopagato.set_num(impcms * percentuale); //pagamento nella partita
ppcs->_descrpagamento = riga_pag.get(PART_DESCR);
ppcs->_nreg = nreg;
ppcs->_commessa = k;
ppcs->_importocommessa.set_num(impcms); //importo da pagare scritto sulla fattura
_pagamenti.add(ppcs); //aggiunge il pagamento all'array dei pagamenti
}
}
}
bool TPag_per_cms::create()
{
_mask = new TPag_per_cms_mask;
_form = new TPag_per_cms_form(_pagamenti);
return TSkeleton_application::create();
}
bool TPag_per_cms::destroy()
{
delete _mask;
delete _form;
return TRUE;
}
void TPag_per_cms::main_loop()
{
while (_mask->run() == K_ENTER)
{
//costruzione filtro sulle date
const char * tipodata = PART_DATAREG;
switch(_mask->get_int(F_TIPODATA))
{
case 1:tipodata = PART_DATADOC;break;
case 2:tipodata = PART_DATAPAG;break;
default:break;
}
TString filtro = "(TIPOC==\"F\")&&(TIPOPAG>=\"3\")"; //deve essere un pagamento a fornitore!!!
const TDate dataini = _mask->get_date(F_DATAINI);
const TDate datafin = _mask->get_date(F_DATAFIN);
if (dataini.ok())
{
if (filtro.not_empty())
filtro << "&&";
TString filtrofinale;
filtrofinale.format("(ANSI(%s)>=\"%s\")", tipodata,dataini.string(ANSI));
filtro << filtrofinale;
}
if (datafin.ok())
{
if (filtro.not_empty())
filtro << "&&";
TString filtrofinale;
filtrofinale.format("(ANSI(%s)<=\"%s\")", tipodata,datafin.string(ANSI));
filtro << filtrofinale;
}
//applica il filtro ai due file della relazione
TRelation rel(LF_PARTITE);
TCursor cur(&rel, filtro);
const TRectype& riga_part_pag = cur.curr(); //riga partita pagamento
const long items = cur.items();
cur.freeze();
_pagamenti.destroy(); //azzera l'arrayone dei pagamenti
//ciclo sui pagamenti selezionati per trovare i movimenti
for (cur=0; cur.pos()<items; ++cur)
{
const long nreg = find_movimento(riga_part_pag);
if (nreg > 0)
find_commesse(nreg, riga_part_pag, tipodata);
}
_form->print(*_mask);
}
}
int cm1100(int argc, char* argv[])
{
TPag_per_cms a;
a.run(argc,argv,TR("Stampa pagato per commessa"));
return 0;
}

7
cm/cm1100.h Executable file
View File

@ -0,0 +1,7 @@
// campi del form cm1100a.frm
#define FR_DATAINI 11
#define FR_DATAFIN 12
#define FR_DACDC 13
#define FR_ACDC 14

122
cm/cm1100a.frm Executable file
View File

@ -0,0 +1,122 @@
#include "cm1100.h"
SECTION GRAPHICS ODD
LINEA -1 132 1
BEGIN
PROMPT 1 5 "@b"
END
LINEA -1 132 1
BEGIN
PROMPT 1 7 "@b"
END
END
// intestazione generale stampa pagato per commessa
SECTION HEADER ODD 7
NUMERO -1
BEGIN
KEY "Nr. pagina"
PROMPT 1 1 "Pag. "
MESSAGE _PAGENO
END
STRINGA -1
BEGIN
KEY "Data"
PROMPT 115 1 "Data "
MESSAGE _TODAY
END
STRINGA -1
BEGIN
KEY "Intestazione stampa"
PROMPT 56 2 "@bPAGATO PER COMMESSA"
END
DATA FR_DATAINI
BEGIN
KEY "Parametri stampa: data iniziale"
PROMPT 1 3 "@bMovimenti dal "
END
DATA FR_DATAFIN
BEGIN
KEY "Parametri stampa: data finale"
PROMPT 40 3 "al "
END
STRINGA FR_DACDC
BEGIN
KEY "da codice commessa"
PROMPT 1 4 "@bDalla commessa "
END
STRINGA FR_ACDC
BEGIN
KEY "a codice commessa"
PROMPT 40 4 "Alla commessa "
END
STRINGA -1
BEGIN
KEY "codice commessa"
PROMPT 1 6 "@bCodice commessa"
END
STRINGA -1
BEGIN
KEY "totale fattura"
PROMPT 24 6 "Totale fattura"
END
STRINGA -1
BEGIN
KEY "totale pagamento"
PROMPT 39 6 "Totale pagamento"
END
END // section header odd
// riga di stampa (utilizzata per ogni gruppo/conto/sottoconto e per tutti i totali)
SECTION BODY ODD 1
STRINGA -1
BEGIN
KEY "codice commessa"
PROMPT 1 1 ""
MESSAGE _CODCMS
END
VALUTA -1 15
BEGIN
KEY "totale fattura"
PROMPT 23 1 ""
MESSAGE _TOTDOC
END
VALUTA -1 15
BEGIN
KEY "totale pagamento"
PROMPT 40 1 ""
MESSAGE _TOTPAG
END
STRINGA -1
BEGIN
KEY "avanza 1 pagamento"
PROMPT 1 1 ""
MESSAGE _NEXTPAG
FLAGS "H"
END
END // section body
SECTION FOOTER ODD 3
END
END // form

7
cm/cm1100a.h Executable file
View File

@ -0,0 +1,7 @@
// campi per la maschera cm1100a
#define F_TIPODATA 100
#define F_DATAINI 101
#define F_DATAFIN 102
#define F_DACDC 103
#define F_ACDC 105

76
cm/cm1100a.uml Executable file
View File

@ -0,0 +1,76 @@
#include "cm1100a.h"
TOOLBAR "" 0 -2 0 2
BUTTON DLG_PRINT 10 2
BEGIN
PROMPT -12 -1 "~Stampa"
MESSAGE EXIT,K_ENTER
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
PAGE "Stampa pagato per commessa" -1 -1 50 10
GROUPBOX DLG_NULL 78 6
BEGIN
PROMPT 1 1 "@bSelezione periodo"
END
RADIOBUTTON F_TIPODATA 76
BEGIN
PROMPT 2 2 "Tipologia di data"
ITEM "0|Registrazione"
ITEM "1|Documento"
ITEM "2|Pagamento"
FLAGS "Z"
END
DATE F_DATAINI
BEGIN
PROMPT 2 5 "Dalla data "
END
DATE F_DATAFIN
BEGIN
PROMPT 25 5 "Alla data "
VALIDATE DATE_CMP_FUNC >= F_DATAINI
WARNING "La data finale deve essere successiva a quella iniziale"
END
GROUPBOX DLG_NULL 76 4
BEGIN
PROMPT 1 8 "@bSelezione commesse"
END
STRING F_DACDC 20
BEGIN
PROMPT 2 9 "Da CDC/Commessa "
FLAGS "UZ"
USE CMS
INPUT CODTAB F_DACDC
DISPLAY "Codice@20" CODTAB
DISPLAY "Descrizione@70" S0
OUTPUT F_DACDC CODTAB
CHECKTYPE SEARCH
END
STRING F_ACDC 20
BEGIN
PROMPT 2 10 "A CDC/Commessa "
FLAGS "UZ"
COPY USE F_DACDC
INPUT CODTAB F_ACDC
COPY DISPLAY F_DACDC
OUTPUT F_ACDC CODTAB
CHECKTYPE SEARCH
END
ENDPAGE
ENDMASK