43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#include "statistic.h"
|
|
#include "util.h"
|
|
|
|
Statistic::Statistic(std::unique_ptr<RepaySqlOpr>& repaySqlOpr) : repaySqlOpr_(repaySqlOpr)
|
|
{
|
|
}
|
|
|
|
Statistic::~Statistic()
|
|
{
|
|
}
|
|
|
|
void Statistic::Calculate(const AccountRecordList& list)
|
|
{
|
|
auto* d = SharedData::instance();
|
|
d->ClearTt();
|
|
|
|
for (const auto& item : list) {
|
|
if (item.payType == "现金支出") {
|
|
d->ttCashOut_ += item.money;
|
|
} else if (item.payType == "现金收入") {
|
|
d->ttCashIn_ += item.money;
|
|
} else if (item.payType == "信用支出") {
|
|
d->ttCreditOut_ += item.money;
|
|
RepayRecordList repayList;
|
|
if (repaySqlOpr_->GetRepayResult(repayList, item.id)) {
|
|
for (const auto& repay : repayList) {
|
|
d->ttCashPay_ += repay.money;
|
|
}
|
|
}
|
|
} else if (item.payType == "信用收入") {
|
|
d->ttCreditIn_ += item.money;
|
|
} else if (item.payType == "信用借款") {
|
|
d->ttCreditCash_ += item.money;
|
|
RepayRecordList repayList;
|
|
if (repaySqlOpr_->GetRepayResult(repayList, item.id)) {
|
|
for (const auto& repay : repayList) {
|
|
d->ttCashPay_ += repay.money;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|