Import Price Bug Fix
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
from unittest.mock import Mock, patch
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval
|
||||
@@ -2058,6 +2059,37 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertTrue(Trigger.default_average())
|
||||
self.assertEqual(Trigger.last.string, 'Latest')
|
||||
|
||||
@with_transaction()
|
||||
def test_import_forward_prices_copies_value_to_ohl_fields(self):
|
||||
'forward import uses price values for open, low and high prices'
|
||||
ImportPrices = Pool().get('purchase_trade.import_prices')
|
||||
ns = {'s': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'}
|
||||
sheet = ElementTree.fromstring('''
|
||||
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
||||
<sheetData>
|
||||
<row r="1">
|
||||
<c r="A1" t="inlineStr"><is><t>Price Index</t></is></c>
|
||||
<c r="B1" t="inlineStr"><is><t>Price Date</t></is></c>
|
||||
<c r="C1" t="inlineStr"><is><t>2026-03</t></is></c>
|
||||
</row>
|
||||
<row r="2">
|
||||
<c r="A2" t="inlineStr"><is><t>ICE Cotton</t></is></c>
|
||||
<c r="B2" t="inlineStr"><is><t>2026-03-01</t></is></c>
|
||||
<c r="C2"><v>75.25</v></c>
|
||||
</row>
|
||||
</sheetData>
|
||||
</worksheet>
|
||||
''')
|
||||
rows = sheet.findall('.//s:sheetData/s:row', ns)
|
||||
|
||||
result = ImportPrices._read_forward_price_rows(rows, [], ns)
|
||||
|
||||
self.assertEqual(len(result), 1)
|
||||
self.assertEqual(result[0]['price_value'], '75.25')
|
||||
self.assertEqual(result[0]['open_price'], '75.25')
|
||||
self.assertEqual(result[0]['low_price'], '75.25')
|
||||
self.assertEqual(result[0]['high_price'], '75.25')
|
||||
|
||||
def test_pricing_component_matrix_returns_generic_line_price(self):
|
||||
'matrix pricing can use an unconditional matrix line as a component price'
|
||||
Component = Pool().get('pricing.component')
|
||||
|
||||
Reference in New Issue
Block a user