def test_cost(self): dev = Device.create(sn='device', model_type=DeviceType.rack_server, model_name='device') dmg = DeviceModelGroup(name='DeviceModelGroup') dmg.price = 100 dmg.save() dev.model.group = dmg dev.model.save() mk = MarginKind(name='50%', margin=50) mk.save() dev.margin_kind = mk dk = DeprecationKind(name='10 months', months=10) dk.save() dev.deprecation_kind = dk dev.save() self.assertEqual(pricing.get_device_cost(dev), 15) pricing.device_update_cached(dev) dev = Device.objects.get(id=dev.id) self.assertEqual(pricing.get_device_cost(dev), 15) self.assertEqual(dev.cached_cost, 15)
('Position', position), ('Parent', subfield('parent', 'name')), ('Name', field('name')), ('Serial Number', field('sn')), ('Barcode', field('barcode')), ('Model', field('model')), ('Remarks', field('remarks')), ], 'serials': [ ('Name', field('name')), ('Data Center', field('dc')), ('Barcode', field('barcode')), ('Serial Number', field('sn')), ('Venture', subfield('venture', 'name')), ('Quoted Price', field('cached_price')), ('Cost', lambda d: '%.2f' % pricing.get_device_cost(d)), ('Model', field('model')), ('Remarks', field('remarks')), ] } class Command(BaseCommand): """Prepare a report""" help = textwrap.dedent(__doc__).strip() requires_model_validation = False option_list = BaseCommand.option_list + ( make_option('--output', dest='output', default=None, help='Where to write the report'), make_option('--format', dest='format', default='csv',
('Position', position), ('Parent', subfield('parent', 'name')), ('Name', field('name')), ('Serial Number', field('sn')), ('Barcode', field('barcode')), ('Model', field('model')), ('Remarks', field('remarks')), ], 'serials': [ ('Name', field('name')), ('Data Center', field('dc')), ('Barcode', field('barcode')), ('Serial Number', field('sn')), ('Venture', subfield('venture', 'name')), ('Quoted Price', field('cached_price')), ('Cost', lambda d: '%.2f' % pricing.get_device_cost(d)), ('Model', field('model')), ('Remarks', field('remarks')), ] } class Command(BaseCommand): """Prepare a report""" help = textwrap.dedent(__doc__).strip() requires_model_validation = False option_list = BaseCommand.option_list + ( make_option('--output', dest='output', default=None,
("Position", position), ("Parent", subfield("parent", "name")), ("Name", field("name")), ("Serial Number", field("sn")), ("Barcode", field("barcode")), ("Model", field("model")), ("Remarks", field("remarks")), ], "serials": [ ("Name", field("name")), ("Data Center", field("dc")), ("Barcode", field("barcode")), ("Serial Number", field("sn")), ("Venture", subfield("venture", "name")), ("Quoted Price", field("cached_price")), ("Cost", lambda d: "%.2f" % pricing.get_device_cost(d)), ("Model", field("model")), ("Remarks", field("remarks")), ], } class Command(BaseCommand): """Prepare a report""" help = textwrap.dedent(__doc__).strip() requires_model_validation = False option_list = BaseCommand.option_list + ( make_option("--output", dest="output", default=None, help="Where to write the report"), make_option(