Ejemplo n.º 1
0
 def move(self, new_path, sqlconn=sql.getconn()):
     """
     Moves invoice and changes the object and SQL data
     """
     if len(self.pages) == 1:
         old_path = self.pages[0]
         self.pages = []
         self.pages.append(new_path + str(self.number) + "_1")
         if sql.execute(sql.move_query(self)):
             try:
                 shutil.move(old_path, new_path + str(self.number) + "_1")
                 sqlconn.commit()
                 sqlconn.close()
                 return True
             except Exception as e:
                 sqlconn.rollback()
                 sqlconn.close()
                 return errors.print_error("inv_move_move", e)
         else:
             sqlconn.rollback()
             sqlconn.close()
             return errors.print_error("inv_move_sql")
     else:  #TODO move multiple pages
         sqlconn.rollback()
         sqlconn.close()
         return errors.print_error("inv_move_nyi")
Ejemplo n.º 2
0
 def export(self):
     query = sql.export_query(self)
     sqlconn = sql.getconn()
     if sql.execute(query, sqlconn):
         if self.move(settings.processing_path, sqlconn):
             return True
         else:
             return False
     sqlconn.rollback()
     return False