20 #include "FdItemCoa.hpp"
25 AccountSignature signature,
32 mSignature(signature),
33 mInitialBalance(initial),
35 mPreviousBalance(previous)
37 if(!parent.isNull() && parent->type() != RootType)
38 mOnBalanceSheet = parent->onBalanceSheet();
40 mOnBalanceSheet =
false;
50 myself = FdItemCoa_p(
new FdItemCoa(parent,
52 item.attribute(
"Label"),
53 AccountSignature(item.attribute(
"Signature",
"0").toDouble()),
54 item.attribute(
"Initial",
"0").toDouble(),
56 item.attribute(
"Previous",
"0").toDouble()));
60 if(!parent.isNull() && parent->type() == RootType)
61 myself->setOnBalanceSheet(item.attribute(
"OnBalanceSheet").toDouble());
63 if(item.tagName() !=
"Account")
65 QDomElement
child = item.firstChildElement();
66 while(!child.isNull())
69 child = child.nextSiblingElement();
84 FdItemCoa_p myself = FdItemCoa_p(
new FdItemCoa(parent,
92 if(!parent.isNull() && parent->type() == RootType)
93 myself->setOnBalanceSheet(model->onBalanceSheet());
95 if(myself->onBalanceSheet())
96 myself->setInitialBalance(myself->previousBalance());
98 for(
int i = 0; i < model->childrenCount(); ++i)
238 QList<FdItemCoa_p> results;
239 for(
int i = 0; i <
mChildren.size(); ++i)
241 if(
mChildren[i]->
id().contains(text, Qt::CaseInsensitive) ||
mChildren[i]->label().contains(text, Qt::CaseInsensitive))
254 for(
int i = 0; i <
mChildren.size(); ++i)
274 return mParent->childRow(
this);
317 for(
int i = 0; i <
mChildren.size(); ++i)
333 for(
int i = 0; i <
mChildren.size(); ++i)
345 QList<FdItemCoa_p> accounts;
346 for(
int i = 0; i <
mChildren.size(); ++i)
365 for(
int i = 0; i <
mChildren.size(); ++i)
371 FdItemCoa_p item =
mChildren[i]->childById(
id);
377 return FdItemCoa_p();
387 if(label != QString())
389 for(
int i = 0; i <
mChildren.size(); ++i)
395 FdItemCoa_p item =
mChildren[i]->childByLabel(label);
401 return FdItemCoa_p();
409 if(
type() == AccountType)
412 for (
int i = 0; i <
mChildren.size(); ++i)
422 for(
int i = 0; i <
mChildren.size(); ++i)
429 if(abs(balance) < 1e-2)
434 if(
type() == CategoryType)
437 for(
int i = 0; i <
mChildren.size(); ++i)
439 initial +=
mChildren[i]->initialBalance();
441 if(abs(initial) < 1e-2)
466 QDomElement item = document.createElement(
"Coa");
468 if(
type() != RootType)
470 item.setAttribute(
"Id",
mId);
471 item.setAttribute(
"Label",
mLabel);
472 if(
type() == CategoryType)
473 item.setTagName(
"Category");
476 item.setTagName(
"Account");
478 item.setAttribute(
"Initial", QString::number(
mInitialBalance,
'f', 2));
481 if(
mParent->type() == RootType)
485 if(
type() != AccountType)
487 for(
int i = 0; i <
mChildren.size(); ++i)
488 item.appendChild(
mChildren[i]->toXml(document));