Updated batch to use a date instead of string as name.
to update this step, also execute the following sql in the database. update entities_batches set "Name" = '01-Jan-2012' where "Name" = 'Old Products'; alter table entities_batches alter column "Name" type timestamp without time zone using "Name"::date;
This commit is contained in:
parent
eae7220651
commit
5972dd6b75
@ -218,7 +218,7 @@ class Batch(Base):
|
||||
__tablename__ = 'entities_batches'
|
||||
|
||||
id = Column('BatchID', GUID(), primary_key=True, default=uuid.uuid4)
|
||||
name = Column('Name', Unicode(255))
|
||||
name = Column('Date', DateTime)
|
||||
product_id = Column('ProductID', GUID(), ForeignKey('entities_products.ProductID'))
|
||||
quantity_remaining = Column('QuantityRemaining', Numeric)
|
||||
rate = Column('Rate', Numeric)
|
||||
@ -246,7 +246,7 @@ class Batch(Base):
|
||||
query = query.filter(cls.quantity_remaining > 0)
|
||||
for item in name.split():
|
||||
query = query.filter(Product.name.ilike('%' + item + '%'))
|
||||
return query.order_by(Product.name).all()
|
||||
return query.order_by(Product.name).order_by(cls.name).all()
|
||||
|
||||
|
||||
@classmethod
|
||||
|
@ -11,8 +11,7 @@ def batch_term(request):
|
||||
list = []
|
||||
for index, item in enumerate(Batch.list(filter, include_nil=False)):
|
||||
text = "{0} ({1}) {2:.2f}@{3:.2f} from {4}".format(item.product.name, item.product.units,
|
||||
item.quantity_remaining,
|
||||
item.rate, item.name)
|
||||
item.quantity_remaining, item.rate, item.name.strftime('%d-%b-%Y'))
|
||||
list.append({'BatchID': item.id, 'Name': text, 'QuantityRemaining': item.quantity_remaining,
|
||||
'Rate': item.rate, 'Tax': item.tax, 'Discount': item.discount,
|
||||
'Product': {'ProductID': item.product.id, 'Name': item.product.name, 'Units': item.product.units}})
|
||||
|
@ -169,7 +169,7 @@ def voucher_info(voucher):
|
||||
'Tax': item.tax, 'Discount': item.discount, 'Amount': item.amount,
|
||||
'Product': {'ProductID': item.product.id, 'Name': item.product.full_name, 'Units': item.product.units,
|
||||
'Price': item.rate},
|
||||
'Batch': {'BatchID': item.batch.id, 'Name': item.batch.name, 'QuantityRemaining': item.batch.quantity_remaining}})
|
||||
'Batch': {'BatchID': item.batch.id, 'Name': item.batch.name.strftime('%d-%b-%Y'), 'QuantityRemaining': item.batch.quantity_remaining}})
|
||||
return json_voucher
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ def purchase_create_voucher(json, user):
|
||||
DBSession.add(voucher)
|
||||
|
||||
for item in json['Inventories']:
|
||||
purchase_create_inventory(voucher, item, json['Date'])
|
||||
purchase_create_inventory(voucher, item, dt)
|
||||
for item in purchase_create_journals(voucher.inventories, json['Journals'][0]['Ledger']['LedgerID']):
|
||||
DBSession.add(item)
|
||||
voucher.journals.append(item)
|
||||
@ -72,14 +72,14 @@ def purchase_update_voucher(voucher, json, user):
|
||||
voucher.posted = False
|
||||
voucher.last_edit_date = datetime.datetime.utcnow()
|
||||
|
||||
purchase_update_inventory(voucher, json['Inventories'], json['Date'])
|
||||
purchase_update_inventory(voucher, json['Inventories'])
|
||||
purchase_update_journals(voucher, json['Journals'])
|
||||
journals_valid(voucher)
|
||||
inventory_valid(voucher)
|
||||
return voucher
|
||||
|
||||
|
||||
def purchase_update_inventory(voucher, newInventories, date):
|
||||
def purchase_update_inventory(voucher, newInventories):
|
||||
for it in range(len(voucher.inventories), 0, -1):
|
||||
item = voucher.inventories[it - 1]
|
||||
found = False
|
||||
@ -129,7 +129,7 @@ def purchase_update_inventory(voucher, newInventories, date):
|
||||
rate = round(Decimal(i['Rate']), 2)
|
||||
tax = round(Decimal(i['Tax']), 5)
|
||||
discount = round(Decimal(i['Discount']), 5)
|
||||
batch = Batch(name=date, product_id=product.id, quantity_remaining=new_quantity, rate=rate, tax=tax,
|
||||
batch = Batch(name=voucher.date, product_id=product.id, quantity_remaining=new_quantity, rate=rate, tax=tax,
|
||||
discount=discount)
|
||||
inventory = Inventory(id=None, product_id=product.id, batch=batch, quantity=new_quantity, rate=rate, tax=tax,
|
||||
discount=discount)
|
||||
|
Loading…
Reference in New Issue
Block a user