                 log.warn "unexpected category id: #{cid}"
             else
                 o.categoryId = categoryMap[cid]
+
+        if o.operationTypeID?
+            oid = o.operationTypeID
+            if not opTypeMap[oid]?
+                log.warn "unexpected operation type id: #{oid}"
+            else
+                o.operationTypeID = opTypeMap[oid]
+
         # Strip away id
         o.id = undefined
 

            categoryMap[catId] = created.id
            cb null, created

    importOperation = (op, cb) ->
        if op.categoryId? and not categoryMap[op.categoryId]?
            return h.sendErr res, "unknown category #{op.categoryId}", 400, "unknown category"
        op.categoryId = categoryMap[op.categoryId]
        Operation.create op, cb

    importSetting = Config.create.bind Config

    log.info """Importing:
    accesses: #{all.accesses.length}
    accounts: #{all.accounts.length}
    categories: #{all.categories.length}
    operations: #{all.operations.length}
    settings: #{all.settings.length}
    """

    async.each all.accesses, importAccess, (err) ->

        categoryMap[c.id] = nextCatId
        c.id = nextCatId++

    opTypeMap = {}
    nextOpTypeId = 0
    all.operationtypes ?= []
    for o in all.operationtypes
        opTypeMap[o.id] = nextOpTypeId
        o.id = nextOpTypeId++

    all.operations ?= []
    for o in all.operations

        if o.categoryId?
            cid = o.categoryId
            if +cid is -1
