示例#1
0
PROD_REFS = getProductRefList()

columns = [
    "id", "type", "quantity", "note", "createdAt", "updatedAt", "id_product"
]

rows = []

obj_id = 1

with open(STOCK_UPD_CSV, encoding='utf8', newline='') as csvfile:
    reader = csv.reader(csvfile, delimiter=';')
    next(reader)  # skip header
    for row in reader:
        try:
            SU = [
                obj_id, 'inventory',
                float(row[5].replace('.', '').replace(',', '.')), '',
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                PROD_REFS.index(row[2]) + 1
            ]
            rows.append(SU)

            obj_id += 1
        except:
            pass

generateSeeds('stock_update', columns, rows)
示例#2
0
  for row in reader:
    address = [
      obj_id,
      'Belgium',
      row[6] if row[6] != '' else '-',
      row[5] if row[5] != '' else '-',
      row[4] if row[4] != '' else '-',
      datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
      datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    ]
    rows.append(address)
    obj_id += 1

with open(SUPPLIERS_CSV, encoding='utf8', newline='') as csvfile:
  reader = csv.reader(csvfile, delimiter=';')
  next(reader) # skip header
  for row in reader:
    address = [
      obj_id,
      'Belgium',
      row[6] if row[6] != '' else '-',
      row[5] if row[5] != '' else '-',
      row[4] if row[4] != '' else '-',
      datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
      datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    ]
    rows.append(address)
    obj_id += 1

generateSeeds('address', columns, rows)
  
示例#3
0
    else:
        pass

    order_prod = [
        order_prods_id, op['product_id'], order_id, '', op['quant'],
        op['quant'], op['price'], op['price'], 'Received', order_id,
        op['created_at'].strftime('%Y-%m-%d %H:%M:%S'),
        op['created_at'].strftime('%Y-%m-%d %H:%M:%S')
    ]
    order_prods_id += 1
    order_prods.append(order_prod)

    prev_supplier = op['supplier']
    prev_date = op['created_at']

bill_amount = 0
for o in order_prods:
    if o[2] == order_id:
        bill_amount += o[6]

bill_supp = [
    order_id, '', 0, bill_amount, '',
    op['created_at'].strftime('%Y-%m-%d %H:%M:%S'),
    op['created_at'].strftime('%Y-%m-%d %H:%M:%S')
]
bills.append(bill_supp)

generateSeeds('order', order_columns, orders)
generateSeeds('bill_supplier', bill_supp_columns, bills)
generateSeeds('product_order', order_prod_columns, order_prods)
示例#4
0
                obj_id, 'C', row[0], email, row[11], row[7], '', row[8], '',
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), '',
                row_id
            ]
            rows.append(company)
            obj_id += 1
        row_id += 1

with open(SUPPLIERS_CSV, encoding='utf8', newline='') as csvfile:
    reader = csv.reader(csvfile, delimiter=';')
    next(reader)  # skip header
    for row in reader:
        if row[0] != '':
            email = f'change.this@fakemail{obj_id}.com'
            if row[10] != '' and row[10] not in unique_refs:
                email = row[10]
                unique_refs.append(email)
            company = [
                obj_id, 'S', row[0], email, row[14], row[7], '', row[8],
                row[17],
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), '',
                row_id
            ]
            rows.append(company)
            obj_id += 1
        row_id += 1

generateSeeds('company', columns, rows)
示例#5
0
obj_id = 1

with open(CLIENTS_CSV, encoding='utf8', newline='') as csvfile:
    reader = csv.reader(csvfile, delimiter=';')
    next(reader)  # skip header
    for row in reader:
        if row[0] == '':
            email = f'change.this@fakemail{obj_id}.com'
            if row[10] != '' and row[10] not in unique_refs:
                email = row[10]
                unique_refs.append(email)

            person = [
                obj_id,
                'Mr.',
                row[3] if row[3] != '' else 'UNKNOWN',
                row[2] if row[2] != '' else 'UNKNOWN',
                email,
                row[7],
                row[8],
                row[11],
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                obj_id,
            ]
            rows.append(person)

        obj_id += 1

generateSeeds('person', columns, rows)