# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
from java.math import BigDecimal

from dk.vajhoej.isam.local import LocalIsamSource

import Customer
import CustomerActual
import Order
import OrderLine

cisam = LocalIsamSource('customer.isq', 'dk.vajhoej.vms.rms.IndexSequential', False)
oisam = LocalIsamSource('order.isq', 'dk.vajhoej.vms.rms.IndexSequential', False)
c = CustomerActual()
c.id = 8
c.name = 'H company'
c.phone = '8888-8888'
c.status = Customer.ACTUAL
c.address1 = 'H road 8'
c.address2 = 'H town'
c.contact = 'Mr. H'
cisam.create(c)
o = Order()
o.id = 8
o.customer = 8
o.status = 'In progress'
o.nlines = 1
ol = OrderLine()
ol.item = 'X stuff'
ol.quantity = 1
ol.price = BigDecimal('72.00')
o.line[0] = ol
for i in range(9):
    o.line[1 + i] = OrderLine()
oisam.create(o)
cisam.close()
oisam.close()
