コード例 #1
0
  def writeContent(self, trans=None):
    #
    # this servlet creates and stores a new Transfer
    #

    globalSetVars = self._globalSetVars
    store = globalSetVars['store']

    account = self.transaction.request().field('account','')
    index = self.transaction.request().field('index',0)
    page = self.transaction.request().field('page','Main')

    #
    # test for errors and consistency
    #
    if not self.transaction.request().field('name',''):
      self.transaction.response().sendRedirect(string.split(self.transaction.request().environ()['HTTP_REFERER'],'?')[0] + '?id=%s&index=%s&error=Bitte einen Zahlungsempfänger angeben' % (account,index))
    elif (DateTime.DateTimeFrom(self.transaction.request().field('date',DateTime.now())).year > (DateTime.now().year + 2)) or \
      (DateTime.DateTimeFrom(self.transaction.request().field('date',DateTime.now())).year < (DateTime.now().year - 5)):
        self.transaction.response().sendRedirect(string.split(self.transaction.request().environ()['HTTP_REFERER'],'?')[0] + '?id=%s&index=%s&error=das Buchungsdatum scheint nicht korrekt zu sein' % (account,index))
    elif float(string.replace(self.transaction.request().field('Haben','0,0'),',','.')) < 0.0:
      self.transaction.response().sendRedirect(string.split(self.transaction.request().environ()['HTTP_REFERER'],'?')[0] + '?id=%s&index=%s&error=das Haben darf nicht negativ sein' % (account,index))
    elif float(string.replace(self.transaction.request().field('Soll','0,0'),',','.')) < 0.0:
      self.transaction.response().sendRedirect(string.split(self.transaction.request().environ()['HTTP_REFERER'],'?')[0] + '?id=%s&index=%s&error=das Soll darf nicht negativ sein' % (account,index))
    elif (float(string.replace(self.transaction.request().field('Soll','0,0'),',','.')) == 0.0) and (float(string.replace(self.transaction.request().field('Haben','0,0'),',','.')) == 0.0):
      self.transaction.response().sendRedirect(string.split(self.transaction.request().environ()['HTTP_REFERER'],'?')[0] + '?id=%s&index=%s&error=Haben oder Soll müssen einen Wert haben' % (account,index))
    elif (float(string.replace(self.transaction.request().field('Soll','0,0'),',','.')) != 0.0) and (float(string.replace(self.transaction.request().field('Haben','0,0'),',','.')) != 0.0):
      self.transaction.response().sendRedirect(string.split(self.transaction.request().environ()['HTTP_REFERER'],'?')[0] + '?id=%s&index=%s&error=entweder Haben oder Soll darf einen Wert haben' % (account,index))

    else:
      #
      konto = self.transaction.request().field('konto','')
      if not konto:
        bookingObjects = store.fetchObjectsOfClass('Prices','WHERE BKZ="%s"' % self.transaction.request().field('bkz',''))
        attrs = bookingObjects[0].allAttrs(0)
        konto = attrs['Konto']
      #
      # create transfer object
      #
      transfer = Transfers()
      transfer.setTAID(self.getSite() + DateTime.now().strftime("%Y%m%d%H%M%S") + "%04d" % UniqueID.next())
      transfer.setTransferID(account + "_" + self.transaction.request().field('bkz',''))
      transfer.setImportWho(self.transaction.request().field('name',''))
      transfer.setImportBeschreibung(string.strip(self.transaction.request().field('description','') + ' ' + self.transaction.request().field('notice','')))
      transfer.setBeschreibung(string.strip(self.transaction.request().field('description','') + ' ' + self.transaction.request().field('notice','')))
      transfer.setWho(self.transaction.request().field('name',''))
      if account < konto:
        transfer.setHaben(float(string.replace(self.transaction.request().field('Haben','0,0'),',','.')))
        transfer.setSoll(float(string.replace(self.transaction.request().field('Soll','0,0'),',','.')))
        transfer.setKonto1(account)
        transfer.setKonto2(konto)
      else:
        transfer.setHaben(float(string.replace(self.transaction.request().field('Soll','0,0'),',','.')))
        transfer.setSoll(float(string.replace(self.transaction.request().field('Haben','0,0'),',','.')))
        transfer.setKonto1(konto)
        transfer.setKonto2(account)
      transfer.setChangedBy(self.transaction.session().value('authenticated_user',''))
      transfer.setChangedAt(DateTime.now())
      transfer.setJahr(DateTime.DateTimeFrom(self.transaction.request().field('date',DateTime.now())).year)
      transfer.setDatum(DateTime.DateTimeFrom(self.transaction.request().field('date',DateTime.now())))
      transfer.setBKZ(self.transaction.request().field('bkz',''))
      transfer.setChangedOn(self.getSite())
      #
      # calculate the rest
      #

      #
      # store transfer in database
      #
      store.addObject(transfer)
      try:
        store.saveChanges()
      except OperationalError,x:
        store.discardEverything()
        errorCode,errorText = x
        #
        # back to error page
        #
        self.transaction.response().sendRedirect('Error?problem=Daten+konnten+nicht+gespeichert+werden!&reason=' + urlEncode(str(errorText)))
      except Warning,x:
        pass
コード例 #2
0
 def writeContent(self, trans=None):
   #
   # get the year for which the new saldos have to be calculated
   #
   try:
     year = int(self.transaction.request().field('year',''))
   except ValueError:
     self.transaction.response().sendRedirect('Administration')
   else:
     globalSetVars = self._globalSetVars
     store = globalSetVars['store']
     #
     # remove old saldos from next year
     #
     storeObjects = store.fetchObjectsOfClass(self.storeName,'WHERE Jahr="%s" AND (BKZ="SVH" OR BKZ = "SVS")' % str(year+1))
     for x in storeObjects:
       store.deleteObject(x)
     store.saveChanges()
     #
     # calculate new saldos from given year
     #
     transfers = store.fetchObjectsOfClass(self.storeName,'WHERE Jahr="%s" ORDER BY Datum' % str(year))
     saldos = {}
     for transfer in transfers:
       x = transfer.allAttrs(0)
       if saldos.has_key(x['Konto1']):
         saldo = saldos[x['Konto1']]
       else:
         saldo = 0.0
       if x['Haben'] != 0.0:
         saldo = saldo + x['Haben']
       if x['Soll'] != 0.0:
         saldo = saldo - x['Soll']
       if saldo != 0.0:
         saldos[x['Konto1']] = saldo
       elif saldos.has_key(x['Konto1']):
         del saldos[x['Konto1']]
       if (x['Konto1'] != x['Konto2']):
         if saldos.has_key(x['Konto2']):
           saldo = saldos[x['Konto2']]
         else:
           saldo = 0.0
         if x['Haben'] != 0.0:
           saldo = saldo - x['Haben']
         if x['Soll'] != 0.0:
           saldo = saldo + x['Soll']
         if saldo != 0.0:
           saldos[x['Konto2']] = saldo
         elif saldos.has_key(x['Konto2']):
           del saldos[x['Konto2']]
     #
     # store new saldos
     #
     for x in saldos.keys():
       if x[:2] in self.accountStores.keys():
         #
         # create transfer object
         #
         member = store.fetchObjectsOfClass(self.accountStores[x[:2]],'WHERE ID="%s"' % x)
         if member:
           attrs = member[0].allAttrs(0)
           transfer = Transfers()
           transfer.setTAID(self.getSite() + DateTime.now().strftime("%Y%m%d%H%M%S") + "%04d" % UniqueID.next())
           if attrs.has_key('Firma') and attrs['Firma']:
             transfer.setImportWho(attrs['Firma'])
             transfer.setWho(attrs['Firma'])
           elif attrs.has_key('Bank'):
             transfer.setImportWho(attrs['Bank'])
             transfer.setWho(attrs['Bank'])
           elif attrs.has_key('Name'):
             transfer.setImportWho(attrs['Name'])
             transfer.setWho(attrs['Name'])
           else:
             transfer.setImportWho(attrs['Nachname'] + ', ' + attrs['Vorname'])
             transfer.setWho(attrs['Nachname'] + ', ' + attrs['Vorname'])
           transfer.setImportBeschreibung('Saldovortrag aus %i' % year)
           transfer.setBeschreibung('Saldovortrag aus %i' % year)
           if saldos[x] > 0.0:
             transfer.setBKZ('SVH')
             transfer.setTransferID(x + "_SVH")
             if year+1 == 2002:
               transfer.setHaben(round(saldos[x] / 1.95583,2))
             else:
               transfer.setHaben(saldos[x])
             transfer.setSoll(0.0)
           else:
             transfer.setBKZ('SVS')
             transfer.setTransferID(x + "_SVS")
             transfer.setHaben(0.0)
             if year+1 == 2002:
               transfer.setSoll(0.0 - round(saldos[x] / 1.95583,2))
             else:
               transfer.setSoll(0.0 - saldos[x])
           transfer.setKonto1(x)
           transfer.setKonto2(x)
           transfer.setChangedBy(self.transaction.session().value('authenticated_user',''))
           transfer.setChangedAt(DateTime.now())
           transfer.setJahr(year+1)
           transfer.setDatum(DateTime.DateTimeFrom('31.12.' + str(year)))
           transfer.setChangedOn(self.getSite())
           store.addObject(transfer)
     store.saveChanges()
     self.transaction.response().sendRedirect('Administration')
コード例 #3
0
 def writeContent(self, trans=None):
   #
   # get the year for which the new saldos have to be calculated
   #
   try:
     year = int(self.transaction.request().field('date','')[-4:])
   except ValueError:
     self.transaction.response().sendRedirect('Administration')
   else:
     bemerkung = self.transaction.request().field('bemerkung','')
     notice = self.transaction.request().field('notice','')
     globalSetVars = self._globalSetVars
     store = globalSetVars['store']
     #
     # BKZs einlesen
     #
     priceObjects = store.fetchObjectsOfClass(priceStore)
     prices = {}
     for x in priceObjects:
       a = x.allAttrs(0)
       prices[a['BKZ']] = a
     konto = prices['EL']['Konto']
     #
     # calculate new saldos from given year
     #
     transfers = store.fetchObjectsOfClass(self.storeName,'WHERE Jahr="%s" ORDER BY Datum' % str(year))
     saldos = {}
     for transfer in transfers:
       x = transfer.allAttrs(0)
       if saldos.has_key(x['Konto1']):
         saldo = saldos[x['Konto1']]
       else:
         saldo = 0.0
       if x['Haben'] != 0.0:
         saldo = saldo + x['Haben']
       if x['Soll'] != 0.0:
         saldo = saldo - x['Soll']
       if saldo != 0.0:
         saldos[x['Konto1']] = saldo
       elif saldos.has_key(x['Konto1']):
         del saldos[x['Konto1']]
       if (x['Konto1'] != x['Konto2']):
         if saldos.has_key(x['Konto2']):
           saldo = saldos[x['Konto2']]
         else:
           saldo = 0.0
         if x['Haben'] != 0.0:
           saldo = saldo - x['Haben']
         if x['Soll'] != 0.0:
           saldo = saldo + x['Soll']
         if saldo != 0.0:
           saldos[x['Konto2']] = saldo
         elif saldos.has_key(x['Konto2']):
           del saldos[x['Konto2']]
     #
     # book Lastschriften
     #
     taid = self.getSite() + DateTime.now().strftime("%Y%m%d%H%M%S") + uniqueId(self)[:4]
     for x in saldos.keys():
       if (x[:2] in self.accountStores.keys()) and (x[-1:] == '0') and (saldos[x] < 0.1):
         #
         # create transfer objectonly for Zahlungsart == "Lastschrift"
         #
         member = store.fetchObjectsOfClass(self.accountStores[x[:2]],'WHERE ID="%s"' % x)[0].allAttrs(0)
         if member['Zahlungsart'] == 'Lastschrift':
           transfer = Transfers()
           transfer.setTAID(taid)
           transfer.setImportWho(member['Nachname'] + ', ' + member['Vorname'])
           if notice:
             transfer.setImportBeschreibung(bemerkung + "(%s)" % notice)
             transfer.setBeschreibung(bemerkung + "(%s)" % notice)
           else:
             transfer.setImportBeschreibung(bemerkung)
             transfer.setBeschreibung(bemerkung)
           transfer.setWho(member['Nachname'] + ', ' + member['Vorname'])
           transfer.setBKZ('EL')
           transfer.setTransferID(x + "_EL")
           transfer.setHaben(saldos[x] * -1.0)
           transfer.setSoll(0.0)
           if x < konto:
             transfer.setKonto1(x)
             transfer.setKonto2(konto)
           else:
             transfer.setKonto1(konto)
             transfer.setKonto2(x)
           transfer.setChangedBy(self.transaction.session().value('authenticated_user',''))
           transfer.setChangedAt(DateTime.now())
           transfer.setJahr(year)
           transfer.setDatum(DateTime.now())
           transfer.setChangedOn(self.getSite())
           store.addObject(transfer)
     for x in self.accountStores.keys():
       storeObjects = store.fetchObjectsOfClass('IDs','WHERE %s = "%s"' % ('Tablename',self.accountStores[x]))
       if (len(storeObjects) == 1):
         id = storeObjects[0]
         id.setLastschriften(taid)
     store.saveChanges()
     self.transaction.response().sendRedirect('Administration')
コード例 #4
0
 def writeContent(self, trans=None):
   #
   # read in database
   #
   globalSetVars = self._globalSetVars
   store = globalSetVars['store']
   priceObjects = store.fetchObjectsOfClass(priceStore)
   prices = {}
   for x in priceObjects:
     a = x.allAttrs(0)
     prices[a['BKZ']] = a
   taid = self.getSite() + DateTime.now().strftime("%Y%m%d%H%M%S") + uniqueId(self)[:4]
   if tableStore != '':
     date = DateTime.DateTimeFrom(self.transaction.request().field('date',''))
     notice = self.transaction.request().field('notice','')
     bookdate = DateTime.DateTimeFrom(self.transaction.request().field('bookdate',''))
     #
     # read all objects from database
     #
     storeObjects = store.fetchObjectsOfClass(tableStore,'WHERE ID like "%%0"')
     for entry in storeObjects:
       attrs = entry.allAttrs(0)
       for y in range(Anzahl_Beitragsarten):
         #
         # Aufnahmegebuehr kalkulieren
         #
         if (attrs['Beitragsart'+str(y+1)] != '') \
             and (attrs['BeitragsartErhebungAb'+str(y+1)] == attrs['Eintrittsdatum']) \
             and not (attrs['BeitragsartFreiAb'+str(y+1)] and (attrs['BeitragsartFreiAb'+str(y+1)] <= attrs['Eintrittsdatum'])) \
             and (attrs['BeitragsartErhebungAb'+str(y+1)] < date):
           price = prices['11' + attrs['Beitragsart'+str(y+1)][2:]]
           if attrs['BeitragsartErhebungAb'+str(y+1)] >= price['Ab']:
             price_haben = price['AbHaben']
             price_soll = price['AbSoll']
           else:
             price_haben = price['Haben']
             price_soll = price['Soll']
           transfer = Transfers()
           transfer.setTAID(taid)
           transfer.setTransferID(attrs['ID'] + "_" + price['BKZ'])
           transfer.setWho(attrs['Nachname'] + ', ' + attrs['Vorname'])
           transfer.setImportWho(attrs['Nachname'] + ', ' + attrs['Vorname'])
           transfer.setBeschreibung(price['Beschreibung'])
           transfer.setImportBeschreibung(price['Beschreibung'])
           transfer.setHaben(price_haben)
           transfer.setSoll(price_soll)
           if attrs['ID'] < price['Konto']:
             transfer.setKonto1(price['Konto'])
             transfer.setKonto2(attrs['ID'])
           else:
             transfer.setKonto1(attrs['ID'])
             transfer.setKonto2(price['Konto'])
           transfer.setChangedBy(self.transaction.session().value('authenticated_user',''))
           transfer.setChangedAt(DateTime.now())
           if bookdate:
             transfer.setJahr(bookdate.year)
             transfer.setDatum(bookdate)
           else:
             transfer.setJahr(DateTime.now().year)
             transfer.setDatum(DateTime.now())
           transfer.setBKZ(price['BKZ'])
           transfer.setChangedOn(self.getSite())
           #
           # store transfer in database
           #
           store.addObject(transfer)
           #
         #
         # Beitrag kalkulieren
         #
         if attrs['Beitragsart'+str(y+1)] \
             and not ((attrs['BeitragsartFreiAb'+str(y+1)] == attrs['BeitragsartErhebungAb'+str(y+1)]) \
               and attrs['BeitragsartFreiAb'+str(y+1)] \
               and attrs['BeitragsartErhebungAb'+str(y+1)]) \
             and (attrs['BeitragsartAb'+str(y+1)] < date) \
             and (attrs['BeitragsartErhebungAb'+str(y+1)] \
               and (attrs['BeitragsartErhebungAb'+str(y+1)] < date)) \
             and (not attrs['BeitragsartFreiAb'+str(y+1)] \
               or (attrs['BeitragsartFreiAb'+str(y+1)] >= attrs['BeitragsartErhebungAb'+str(y+1)])) \
             and (not attrs['Austrittsdatum'] \
               or (attrs['Austrittsdatum'] >= attrs['BeitragsartErhebungAb'+str(y+1)])):
           price = prices[attrs['Beitragsart'+str(y+1)]]
           price_soll,price_haben,bkz,beschreibung = fee(attrs['Beitragsart'+str(y+1)],attrs['Eintrittsdatum'],attrs['BeitragsartAb'+str(y+1)],attrs['BeitragsartFreiAb'+str(y+1)],attrs['BeitragsartErhebungAb'+str(y+1)],date,price,notice)
           transfer = Transfers()
           transfer.setTAID(taid)
           transfer.setTransferID(attrs['ID'] + "_" + price['BKZ'])
           transfer.setWho(attrs['Nachname'] + ', ' + attrs['Vorname'])
           transfer.setImportWho(attrs['Nachname'] + ', ' + attrs['Vorname'])
           transfer.setBeschreibung(beschreibung)
           transfer.setImportBeschreibung(beschreibung)
           transfer.setHaben(price_haben)
           transfer.setSoll(price_soll)
           if attrs['ID'] < price['Konto']:
             transfer.setKonto1(price['Konto'])
             transfer.setKonto2(attrs['ID'])
           else:
             transfer.setKonto1(attrs['ID'])
             transfer.setKonto2(price['Konto'])
           transfer.setChangedBy(self.transaction.session().value('authenticated_user',''))
           transfer.setChangedAt(DateTime.now())
           if bookdate:
             transfer.setJahr(bookdate.year)
             transfer.setDatum(bookdate)
           else:
             transfer.setJahr(DateTime.now().year)
             transfer.setDatum(DateTime.now())
           transfer.setBKZ(bkz)
           transfer.setChangedOn(self.getSite())
           #
           # store transfer in database
           #
           store.addObject(transfer)
           if attrs['BeitragsartFreiAb'+str(y+1)] and (date >= attrs['BeitragsartFreiAb'+str(y+1)]):
             entry.setValueForKey('BeitragsartErhebungAb'+str(y+1), attrs['BeitragsartFreiAb'+str(y+1)])
           else:
             entry.setValueForKey('BeitragsartErhebungAb'+str(y+1), date)
     #
     # save changes
     #
     try:
       store.saveChanges()
     except OperationalError,x:
       store.discardEverything()
       errorCode,errorText = x
       #
       # back to error page
       #
       self.transaction.response().sendRedirect('Error?problem=Daten+konnten+nicht+gespeichert+werden!&reason=' + urlEncode(str(errorText)))
     except Warning,x:
       pass