账单记录器迁移。
This commit is contained in:
42
statistic.cpp
Normal file
42
statistic.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user