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;
|
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;
|
string comm;
|
||||||
do {
|
do {
|
||||||
|
|
@ -171,8 +172,8 @@ void generate_posts_iterator::generate_commodity(std::ostream& out)
|
||||||
generate_string(buf, six_gen(), true);
|
generate_string(buf, six_gen(), true);
|
||||||
comm = buf.str();
|
comm = buf.str();
|
||||||
}
|
}
|
||||||
while (comm == "h" || comm == "m" || comm == "s" || comm == "and" ||
|
while (comm == exclude || comm == "h" || comm == "m" || comm == "s" ||
|
||||||
comm == "any" || comm == "all" || comm == "div" ||
|
comm == "and" || comm == "any" || comm == "all" || comm == "div" ||
|
||||||
comm == "false" || comm == "or" || comm == "not" ||
|
comm == "false" || comm == "or" || comm == "not" ||
|
||||||
comm == "true" || comm == "if" || comm == "else");
|
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,
|
string generate_posts_iterator::generate_amount(std::ostream& out,
|
||||||
value_t not_this_amount,
|
value_t not_this_amount,
|
||||||
bool no_negative)
|
bool no_negative,
|
||||||
|
const string& exclude)
|
||||||
{
|
{
|
||||||
std::ostringstream buf;
|
std::ostringstream buf;
|
||||||
|
|
||||||
if (truth_gen()) { // commodity goes in front
|
if (truth_gen()) { // commodity goes in front
|
||||||
generate_commodity(buf);
|
generate_commodity(buf, exclude);
|
||||||
if (truth_gen())
|
if (truth_gen())
|
||||||
buf << ' ';
|
buf << ' ';
|
||||||
if (no_negative || truth_gen())
|
if (no_negative || truth_gen())
|
||||||
|
|
@ -200,7 +202,7 @@ string generate_posts_iterator::generate_amount(std::ostream& out,
|
||||||
buf << neg_number_gen();
|
buf << neg_number_gen();
|
||||||
if (truth_gen())
|
if (truth_gen())
|
||||||
buf << ' ';
|
buf << ' ';
|
||||||
generate_commodity(buf);
|
generate_commodity(buf, exclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Possibly generate an annotized commodity, but make it rarer
|
// 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
|
else
|
||||||
buf << " @@ ";
|
buf << " @@ ";
|
||||||
|
|
||||||
if (! generate_amount(buf, amount, true).empty())
|
if (! generate_amount(buf, amount, true,
|
||||||
|
amount.as_amount().commodity().symbol()).empty())
|
||||||
out << buf.str();
|
out << buf.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,11 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void generate_string(std::ostream& out, int len, bool only_alpha = false);
|
void generate_string(std::ostream& out, int len, bool only_alpha = false);
|
||||||
bool generate_account(std::ostream& out, bool no_virtual = 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,
|
string generate_amount(std::ostream& out,
|
||||||
value_t not_this_amount = NULL_VALUE,
|
value_t not_this_amount = NULL_VALUE,
|
||||||
bool no_negative = false);
|
bool no_negative = false,
|
||||||
|
const string& exclude = "");
|
||||||
bool generate_post(std::ostream& out, bool no_amount = false);
|
bool generate_post(std::ostream& out, bool no_amount = false);
|
||||||
void generate_cost(std::ostream& out, value_t amount);
|
void generate_cost(std::ostream& out, value_t amount);
|
||||||
void generate_date(std::ostream& out);
|
void generate_date(std::ostream& out);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue