38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
"""四个业务菜单中的成本价/单价统一显示四位小数。"""
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
APP_JS = Path(__file__).resolve().parents[1] / 'static' / 'js' / 'app.js'
|
|
|
|
|
|
class PricePrecisionDisplayTestCase(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.source = APP_JS.read_text(encoding='utf-8')
|
|
|
|
def test_shared_price_formatter_uses_four_decimals(self):
|
|
self.assertIn("number.toFixed(4)", self.source)
|
|
self.assertIn("function formatPrice4(value, currency)", self.source)
|
|
|
|
def test_product_and_planning_cost_prices_use_shared_formatter(self):
|
|
self.assertIn("formatPrice4(p, true)", self.source)
|
|
self.assertIn("formatPrice4(val, true)", self.source)
|
|
self.assertIn("val:formatPrice4(row.cost_price, true)", self.source)
|
|
self.assertIn("val:formatPriceInput4(row.cost_price)", self.source)
|
|
|
|
def test_bom_cost_prices_use_four_decimals(self):
|
|
self.assertIn("formatPrice4(totalMatCost, true)", self.source)
|
|
self.assertIn("formatPrice4(r.material_cost_price, true)", self.source)
|
|
self.assertIn('step="0.0001"', self.source)
|
|
|
|
def test_backup_unit_prices_use_four_decimals(self):
|
|
self.assertIn("formatPrice4(item['单价'], false)", self.source)
|
|
self.assertIn("unitPrice.toFixed(4)", self.source)
|
|
self.assertNotIn("Number(item['单价']).toFixed(2)", self.source)
|
|
self.assertNotIn("unitPrice.toFixed(2)", self.source)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|