def __init__(self,owner=None):
     PropertiesObject.__init__(self,[ 'id', 'name', 'accountholder', 'accountnumber', 'allowincasso', 'owner' ])
     if owner:
         self.owner = owner
         self.id = owner.GetID()
         self.name = owner.GetName()
         sc = StructuredComment(owner.GetNotes())
         self.accountholder = sc.get_string('AccountHolder')
         self.accountnumber = sc.get_int('AccountNumber')
         self.allowincasso = sc.get_bool('AllowIncasso')
 def _fill_from_lots(self,items,lots):
     for lot in lots:
         invoice = lot.GetInvoiceFromLot()
         if invoice:
             sc = StructuredComment(invoice.GetNotes())
             owner = invoice.GetOwner()
             items.append(Transaction({
                 'description': self._get_txn_desc(invoice.GetPostedTxn()),
                 'amount': self.conv(lot.get_balance()),
                 'invoiceid': invoice.GetID(),
                 'owner': owner and Contact(owner),
                 'accountholder': sc.get_string('AccountHolder'),
                 'accountnumber': sc.get_int('AccountNumber'),
                 'allowincasso': sc.get_bool('AllowIncasso'),
             }))
         else:
             items.append(Transaction({
                 'amount': self.conv(lot.get_balance()),
                 'invoiceid': lot.get_title(),
             }))
     return items
    def _update_contact(self,c,row):
        sc = StructuredComment(c.GetNotes())

        fld = self.mapping['name']
        if fld:
            c.SetName(row[fld])
            a = c.GetAddr()
            a.SetName(row[fld])
            a.SetAddr1('-')

        fld = self.mapping['accountholder']
        if fld:
            key = 'AccountHolder'
            if row[fld]:
                sc.set_entry(key,row[fld])
            else:
                sc.remove_entry(key)

        fld = self.mapping['accountnumber']
        if fld:
            key = 'AccountNumber'
            try:
                sc.set_entry(key,int(row[fld]))
            except:
                sc.remove_entry(key)

        fld = self.mapping['allowincasso']
        if fld:
            key = 'AllowIncasso'
            val = row[fld].lower()
            if val:
                if val == 'true' or val == 'yes' or val == '1' or val == 'y':
                    sc.set_entry(key,True)
                else:
                    sc.set_entry(key,False)
            else:
                sc.remove_entry(key)

        c.SetNotes(sc.get_comment())