KissCount

KissCount Commit Details

Date:2018-10-03 09:05:21 (1 year 16 days ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:951793567a77d87239d991a071a067e49dc229c2
Parents: 10c534857d09b3cca6241711aba93ddc5c704509
Message:Auto fill operation amount if it was the same for the last 3 operations

Changes:
MChangeLog (1 diff)
Msrc/controller/KissCount.cpp (3 diffs)
Msrc/view/grid/GridAccount.cpp (1 diff)

File differences

ChangeLog
1
1
22
33
4
45
56
67
8
9
710
811
912
v0.8 (26/08/2018)
v0.8 (03/10/2018)
** User **
Add multi month operation support : Normal operation with description "... (XX/YY)" will be forwarded to next month
Auto fill operation amount if it was the same for the last 3 operations
** Dev **
** Bugs **
Current account value is badly computed if operations are not in date order
NULLop was set with random values which can cause misunderstanding when entering a new operation
v0.7.1 (07/05/2018)
src/controller/KissCount.cpp
3030
3131
3232
33
34
35
3336
3437
3538
......
562565
563566
564567
568
569
565570
566
567
568
569
570
571
572
573
571
572
574573
575574
576575
......
584583
585584
586585
587
586
587
588
589
590
591
592
593
594
595
596
597
588598
599
589600
590
591
601
602
603
592604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
593620
594621
595622
596
623
597624
598625
599626
std::vector<ImportEngine*> * KissCount::_importEngines;
std::vector<ExportEngine*> * KissCount::_exportEngines;
/* Fill amount if it was the same for the last X operations */
#define SAME_AMOUNT_THRESHOLD 3
KissCount::KissCount(int& argc, char** argv) : QApplication(argc, argv), _user(0)
{
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
//wxDateSpan threeMonths(0, 3); Not working :(
std::vector<int> v;
int i;
bool ret = false;
int same_amount = SAME_AMOUNT_THRESHOLD-1, same_amount_value = 0;
month -= 3;
if (month < 0)
{
year -= 1;
month += 12;
}
QDate date = QDate(year, month, 0);
QDate date = QDate(year, month+1, 1);
date = date.addMonths(-3);
if (limitToType)
operations = _db->Search(_user, &op.description, &date, 0, 0, 0, v, op.fix_cost ? +Database::FIX_OP : +Database::NON_FIX_OP, v, false, v);
}
for(i=operations->size()-1; i>=0; i--)
if (!(*operations)[i].meta && index--)
{
if ((*operations)[i].meta)
continue ;
/* If it's a transfert, take index in account */
if ((*operations)[i].transfert && index > 0)
{
index--;
continue;
}
if (!ret)
{
// First time found
*res = (*operations)[i];
delete operations;
return true;
res->amount = 0;
ret = true;
same_amount_value = (*operations)[i].amount;
}
else
{
if ((*operations)[i].amount == same_amount_value)
{
/* X time same amount */
if (!same_amount--)
{
res->amount = same_amount_value;
break;
}
}
else
break;
}
}
delete operations;
return false;
return ret;
}
void KissCount::GetHistory(int month, int year, QStringList& list)
src/view/grid/GridAccount.cpp
10501050
10511051
10521052
1053
1054
1055
1056
1057
1058
10531059
10541060
10551061
new_op.fix_cost = (new_op.category == user->GetCategoryId("Fix"));
if (op_tmp.transfert != 0)
transfertCompleted = true;
/* Non null value --> set amount */
if (op_tmp.amount > 0)
setItem(row, CREDIT, new QTableWidgetItem(value.sprintf("%.2lf", (double)op_tmp.amount/100)));
else if (op_tmp.amount < 0)
setItem(row, DEBIT, new QTableWidgetItem(value.sprintf("%.2lf", (double)-op_tmp.amount/100)));
}
}

Archive Download the corresponding diff file