mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Reorder the create price procedure.
This commit is contained in:
parent
62bbe4f951
commit
644a0aa06f
@ -362,32 +362,10 @@ Result GncImportPrice::create_price (QofBook* book, GNCPriceDB *pdb, bool over)
|
||||
|
||||
bool rev = false;
|
||||
auto amount = *m_amount;
|
||||
Result ret_val = ADDED;
|
||||
|
||||
GNCPrice *old_price = gnc_pricedb_lookup_day (pdb, *m_from_commodity, *m_to_currency, date);
|
||||
|
||||
if (gnc_commodity_is_currency (*m_from_commodity)) // Currency Import
|
||||
{
|
||||
// Check for currency in reverse direction.
|
||||
if (old_price != nullptr)
|
||||
{
|
||||
// Check for price in reverse direction.
|
||||
if (gnc_commodity_equiv (gnc_price_get_currency (old_price), *m_from_commodity))
|
||||
rev = true;
|
||||
|
||||
DEBUG("Commodity from is a Currency");
|
||||
}
|
||||
|
||||
// Check for price less than 1, reverse if so.
|
||||
if (*m_amount < GncNumeric(1,1))
|
||||
rev = true;
|
||||
|
||||
}
|
||||
DEBUG("Date is %s, Rev is %d, Commodity from is '%s', Currency is '%s', Amount is %s", gnc_print_date (date),
|
||||
rev, gnc_commodity_get_fullname (*m_from_commodity), gnc_commodity_get_fullname (*m_to_currency),
|
||||
amount.to_string().c_str());
|
||||
|
||||
Result ret_val = ADDED;
|
||||
|
||||
// Should old price be over writen
|
||||
if ((old_price != nullptr) && (over == true))
|
||||
{
|
||||
@ -398,6 +376,26 @@ Result GncImportPrice::create_price (QofBook* book, GNCPriceDB *pdb, bool over)
|
||||
ret_val = REPLACED;
|
||||
}
|
||||
|
||||
if (gnc_commodity_is_currency (*m_from_commodity)) // Currency Import
|
||||
{
|
||||
// Check for currency in reverse direction.
|
||||
if (old_price != nullptr)
|
||||
{
|
||||
// Check for price in reverse direction.
|
||||
if (gnc_commodity_equiv (gnc_price_get_currency (old_price), *m_from_commodity))
|
||||
rev = true;
|
||||
}
|
||||
DEBUG("Commodity from is a Currency");
|
||||
|
||||
// Check for price less than 1, reverse if so.
|
||||
if (*m_amount < GncNumeric(1,1))
|
||||
rev = true;
|
||||
|
||||
}
|
||||
DEBUG("Date is %s, Rev is %d, Commodity from is '%s', Currency is '%s', Amount is %s", gnc_print_date (date),
|
||||
rev, gnc_commodity_get_fullname (*m_from_commodity), gnc_commodity_get_fullname (*m_to_currency),
|
||||
amount.to_string().c_str());
|
||||
|
||||
// Create the new price
|
||||
if (old_price == nullptr)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user