Don't gen posting with same cost, amount commodity
This commit is contained in:
parent
f68b4d0f0f
commit
90d5ef83b6
2 changed files with 14 additions and 10 deletions
|
|
@ -163,7 +163,8 @@ bool generate_posts_iterator::generate_account(std::ostream& out,
|
|||
return must_balance;
|
||||
}
|
||||
|
||||
void generate_posts_iterator::generate_commodity(std::ostream& out)
|
||||
void generate_posts_iterator::generate_commodity(std::ostream& out,
|
||||
const string& exclude)
|
||||
{
|
||||
string comm;
|
||||
do {
|
||||
|
|
@ -171,8 +172,8 @@ void generate_posts_iterator::generate_commodity(std::ostream& out)
|
|||
generate_string(buf, six_gen(), true);
|
||||
comm = buf.str();
|
||||
}
|
||||
while (comm == "h" || comm == "m" || comm == "s" || comm == "and" ||
|
||||
comm == "any" || comm == "all" || comm == "div" ||
|
||||
while (comm == exclude || comm == "h" || comm == "m" || comm == "s" ||
|
||||
comm == "and" || comm == "any" || comm == "all" || comm == "div" ||
|
||||
comm == "false" || comm == "or" || comm == "not" ||
|
||||
comm == "true" || comm == "if" || comm == "else");
|
||||
|
||||
|
|
@ -181,12 +182,13 @@ void generate_posts_iterator::generate_commodity(std::ostream& out)
|
|||
|
||||
string generate_posts_iterator::generate_amount(std::ostream& out,
|
||||
value_t not_this_amount,
|
||||
bool no_negative)
|
||||
bool no_negative,
|
||||
const string& exclude)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
|
||||
if (truth_gen()) { // commodity goes in front
|
||||
generate_commodity(buf);
|
||||
generate_commodity(buf, exclude);
|
||||
if (truth_gen())
|
||||
buf << ' ';
|
||||
if (no_negative || truth_gen())
|
||||
|
|
@ -200,7 +202,7 @@ string generate_posts_iterator::generate_amount(std::ostream& out,
|
|||
buf << neg_number_gen();
|
||||
if (truth_gen())
|
||||
buf << ' ';
|
||||
generate_commodity(buf);
|
||||
generate_commodity(buf, exclude);
|
||||
}
|
||||
|
||||
// Possibly generate an annotized commodity, but make it rarer
|
||||
|
|
@ -259,7 +261,8 @@ void generate_posts_iterator::generate_cost(std::ostream& out, value_t amount)
|
|||
else
|
||||
buf << " @@ ";
|
||||
|
||||
if (! generate_amount(buf, amount, true).empty())
|
||||
if (! generate_amount(buf, amount, true,
|
||||
amount.as_amount().commodity().symbol()).empty())
|
||||
out << buf.str();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,10 +110,11 @@ public:
|
|||
protected:
|
||||
void generate_string(std::ostream& out, int len, bool only_alpha = false);
|
||||
bool generate_account(std::ostream& out, bool no_virtual = false);
|
||||
void generate_commodity(std::ostream& out);
|
||||
void generate_commodity(std::ostream& out, const string& exclude = "");
|
||||
string generate_amount(std::ostream& out,
|
||||
value_t not_this_amount = NULL_VALUE,
|
||||
bool no_negative = false);
|
||||
value_t not_this_amount = NULL_VALUE,
|
||||
bool no_negative = false,
|
||||
const string& exclude = "");
|
||||
bool generate_post(std::ostream& out, bool no_amount = false);
|
||||
void generate_cost(std::ostream& out, value_t amount);
|
||||
void generate_date(std::ostream& out);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue