Esporatzione CBA per Cigno Generazione rimanenze finali per Cigno git-svn-id: svn://10.65.10.50/branches/R_10_00@22796 c028cbd2-c16b-5b4b-a496-9718f37d4682
119 lines
2.7 KiB
C++
119 lines
2.7 KiB
C++
#include <automask.h>
|
|
#include <applicat.h>
|
|
#include <progind.h>
|
|
#include <recset.h>
|
|
|
|
#include "../cg/cg2101.h"
|
|
#include "../cg/cglib01.h"
|
|
#include "../mg/mglib.h"
|
|
#include "ps0430500a.h"
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TRimfin_mask
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TRimfin_mask : public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
public:
|
|
TRimfin_mask() : TAutomask("ps0430500a") {}
|
|
};
|
|
|
|
bool TRimfin_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TRimfin_app
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TRimfin_app : public TSkeleton_application
|
|
{
|
|
protected:
|
|
virtual const char* extra_modules() const { return "ca"; }
|
|
virtual void main_loop();
|
|
|
|
public:
|
|
};
|
|
|
|
static bool scan_mag(const TRelation& rel, void* jolly)
|
|
{
|
|
const TRectype& rec = rel.curr();
|
|
|
|
const real qta = rec.get("R0");
|
|
if (qta.sign() <= 0)
|
|
return true;
|
|
|
|
const TDate data = rec.get("D0");
|
|
const TString& codart = rec.get("CODTAB").mid(5, 20);
|
|
const TArticolo_giacenza& art = cached_article_balances(codart);
|
|
const real valore = art.ultimo_costo(data.year());
|
|
if (valore.is_zero())
|
|
return true;
|
|
|
|
TBill bill;
|
|
bill.set(rec.get_int("I3"), rec.get_int("I4"), rec.get_long("I5"));
|
|
#ifdef DBG
|
|
if (!bill.ok())
|
|
bill.set(rec.get_int("I0"), rec.get_int("I1"), rec.get_long("I2"));
|
|
#endif
|
|
|
|
TString16 key;
|
|
key << rec.get("CODTAB").left(3) << '|' << bill.string(0x10);
|
|
|
|
TAssoc_array& saldi = *(TAssoc_array*)jolly;
|
|
real* imp = (real*)saldi.objptr(key);
|
|
if (imp == NULL)
|
|
{
|
|
imp = new real;
|
|
saldi.add(key, imp);
|
|
}
|
|
*imp += qta * valore;
|
|
|
|
return true;
|
|
}
|
|
|
|
void TRimfin_app::main_loop()
|
|
{
|
|
TRimfin_mask m;
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
TString query;
|
|
query << "USE &MGMAG"; // SELECT I5>0"
|
|
TISAM_recordset recset(query);
|
|
|
|
TAssoc_array saldi;
|
|
recset.cursor()->scan(scan_mag, &saldi, title());
|
|
|
|
TString_array a;
|
|
FOR_EACH_ASSOC_OBJECT(saldi, h, k, o)
|
|
{
|
|
const TFixed_string key(k);
|
|
TToken_string* r = new TToken_string;
|
|
*r = key.left(3);
|
|
r->add(key.mid(3));
|
|
r->add(((real*)o)->string(0, 2));
|
|
}
|
|
a.sort();
|
|
|
|
TMovimentoPN mov;
|
|
mov.curr().put(MOV_DATAREG, m.get(F_DATAREG));
|
|
mov.curr().put(MOV_CODCAUS, m.get(F_CODCAUS));
|
|
TString4 curmag;
|
|
real imp;
|
|
FOR_EACH_ARRAY_ROW(a, i, r)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|
|
int ps0430500(int argc, char* argv[])
|
|
{
|
|
TRimfin_app a;
|
|
a.run(argc, argv, TR("Generazione rimanenze finali"));
|
|
return 0;
|
|
}
|