Esempio n. 1
0
def ModifyDescriptionOfIncome(idOfIncome, description):
    """Based on the ID of the Income object the description
    is modified in database.

    Parameters
    ----------
    idOfIncome : integer
        Id of Income object.
    description : string
        Description of Income object.

    """

    logs.logger.debug(
        "Start to modify description of Income based on the ID (%s)." %
        idOfIncome)
    try:
        modifiedIncome = session.query(
            Income.Income).filter(Income.Income.id == idOfIncome).one()
        modifiedIncome.description = description
        session.commit()
        logs.logger.info("Modify description of Income based on the ID (%s)." %
                         idOfIncome)
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 2
0
def ModifyCategoryOfIncome(idOfIncome, category):
    """Based on the ID of the Income object the category
    is modified in database.

    Parameters
    ----------
    idOfIncome : integer
        Id of Income object.
    category : enum
        Category of Income object.

    """

    logs.logger.debug(
        "Start to modify category of Income based on the ID (%s)." %
        idOfIncome)
    try:
        modifiedIncome = session.query(
            Income.Income).filter(Income.Income.id == idOfIncome).one()
        modifiedIncome.category = category
        session.commit()
        logs.logger.info("Modify category of Income based on the ID (%s)." %
                         idOfIncome)
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 3
0
def ModifyRegistrationDateOfIncome(idOfIncome, registrationDate):
    """Based on the ID of the Income object the registration date
    is modified in database.

    Parameters
    ----------
    idOfIncome : integer
        Id of Income object.
    registrationDate : date
        Registration date of Income object.

    """

    logs.logger.debug("Start to modify registration date of Income based\
             on the ID (%s)." % idOfIncome)
    try:
        modifiedIncome = session.query(
            Income.Income).filter(Income.Income.id == idOfIncome).one()
        modifiedIncome.registrationDate = registrationDate
        session.commit()
        logs.logger.info(
            "Modify registration date of Income based on the ID (%s)." %
            idOfIncome)
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 4
0
def AddCost(Cost):
    """Add Cost object to the database.

    Parameters
    ----------
    Cost : object
        Cost object.

    """

    logs.logger.debug("Start to add Cost object to the database.")
    try:
        session.add(Cost)
        session.commit()
        logs.logger.info("Add Cost object to the database.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 5
0
def AddIncomes(Income):
    """Add Income object to the database.

    Parameters
    ----------
    Income : object
        Income object.

    """

    logs.logger.debug("Start to add Income object to the database.")
    try:
        session.add(Income)
        session.commit()
        logs.logger.info("Add Income object to the database.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 6
0
def InsertNewFiles(path):
    """Insert new file to the database

    Parameters
    ----------
    session : session
        Manages persistence operations for ORM-mapped objects.

    path : string
        the path of the file

    """

    logs.logger.debug("Start insert new file (%s) to the database" % path)
    try:
        newFile = File.File(path)
        session.add(newFile)
        session.commit()
        logs.logger.info("Insert new file (%s) to the database" % path)
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 7
0
def ModifyCategoryOfCost(idOfCost, category):
    """Based on the ID of the Cost object the category
    is modified in database.

    Parameters
    ----------
    idOfCost : integer
        Id of Cost object.
    category : enum
        Category of Cost object.

    """

    logs.logger.debug("Start to modify category of Cost based on the ID.")
    try:
        modifiedCost = session.query(Cost.Cost).filter(
            Cost.Cost.id == idOfCost).one()
        modifiedCost.category = category
        session.commit()
        logs.logger.info("Modify category of Cost based on the ID.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 8
0
def ModifyDescriptionOfCost(idOfCost, description):
    """Based on the ID of the Cost object the description
    is modified in database.

    Parameters
    ----------
    idOfCost : integer
        Id of Cost object.
    description : string
        Description of Cost object.

    """

    logs.logger.debug("Start to modify description of Cost based on the ID.")
    try:
        modifiedCost = session.query(Cost.Cost).filter(
            Cost.Cost.id == idOfCost).one()
        modifiedCost.description = description
        session.commit()
        logs.logger.info("Modify description of Cost based on the ID.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 9
0
def ModifyAmountOfCost(idOfCost, amount):
    """Based on the ID of the Cost object the amount
    is modified in database.

    Parameters
    ----------
    idOfCost : integer
        Id of Cost object.
    amount : integer
        Amount of Cost object.

    """

    logs.logger.debug("Start to modify amount of Cost based on the ID.")
    try:
        modifiedCost = session.query(Cost.Cost).filter(
            Cost.Cost.id == idOfCost).one()
        modifiedCost.amount = amount
        session.commit()
        logs.logger.info("Modify amount of Cost based on the ID.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 10
0
def ModifyTheFullRowOfCost(idOfCost, registrationDate, dateOfPayment,
                           amount, description, category):
    """Based on the all given properties of Cost as parameters this method
    modifys the properties of Cost object in database.

    Parameters
    ----------
    idOfCost : integer
        Id of Cost object.
    registrationDate : date
        Registration date of Cost object.
    dateOfPayment : date
        Payment date of Cost object.
    amount : integer
        Amount of Cost object.
    description : string
        Description of Cost object.
    category : enum
        Category of Cost object.

    """

    logs.logger.debug(
        "Start to modify the properties of Cost object in database "
        "based on the all given properties of Cost.")
    try:
        modifiedCost = session.query(Cost.Cost).filter(
            Cost.Cost.id == idOfCost).one()
        modifiedCost.registrationDate = registrationDate
        modifiedCost.dateOfPayment = dateOfPayment
        modifiedCost.amount = amount
        modifiedCost.description = description
        modifiedCost.category = category
        session.commit()
        logs.logger.info(
            "Modify the properties of Cost object in database "
            "based on the all given properties of Cost.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 11
0
def DeleteIncome(idOfIncome):
    """Based on Id parameter of the Income object this method deletes the Income
    object from database.

    Parameters
    ----------
    idOfIncome : integer
        Id of the Income object.

    """

    logs.logger.debug("Start to deletes the Income object from database "
                      "based on Id parameter (%s)." % idOfIncome)
    try:
        deletedIncome = session.query(
            Income.Income).filter(Income.Income.id == idOfIncome).one()
        session.delete(deletedIncome)
        session.commit()
        logs.logger.info("Deletes the Income object from database "
                         "based on Id parameter (%s)." % idOfIncome)
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 12
0
def ModifyStatusOfTheFileFromNewToOld(File):
    """Modify the status (new = 1, old = 0) of the file from new to old in DB.

    Parameters
    ----------
    File : object
        File object

    Returns
    -------
    File
        File object
    """
    logs.logger.debug(
        "Modify the status (new = 1, old = 0) of the file from new to old in\
             DB.")
    try:
        File.Status = 0
        session.commit()
        return File
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 13
0
def DeleteCost(idOfCost):
    """Based on Id parameter of the Cost object this method deletes the Cost
    object from database.

    Parameters
    ----------
    idOfCost : integer
        Id of the Cost object.

    """

    logs.logger.debug(
        "Start to deletes the Cost object from database "
        "based on Id parameter.")
    try:
        deletedCost = session.query(Cost.Cost).filter(
            Cost.Cost.id == idOfCost).one()
        session.delete(deletedCost)
        session.commit()
        logs.logger.info("Deletes the Cost object from database "
                         "based on Id parameter.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 14
0
def ModifyRegistrationDateOfCost(idOfCost, registrationDate):
    """Based on the ID of the Cost object the registration date
    is modified in database.

    Parameters
    ----------
    idOfCost : integer
        Id of Cost object.
    registrationDate : date
        Registration date of Cost object.

    """

    logs.logger.debug(
        "Start to modify registration date of Cost based on the ID.")
    try:
        modifiedCost = session.query(Cost.Cost).filter(
            Cost.Cost.id == idOfCost).one()
        modifiedCost.registrationDate = registrationDate
        session.commit()
        logs.logger.info("Modify registration date of Cost based on the ID.")
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 15
0
def ModifyAmountOfIncome(idOfIncome, amount):
    """Based on the ID of the Income object the amount
    is modified in database.

    Parameters
    ----------
    idOfIncome : integer
        Id of Income object.
    amount : integer
        Amount of Income object.

    """

    logs.logger.debug(
        "Start to modify amount of Income based on the ID (%s)." % idOfIncome)
    try:
        modifiedIncome = session.query(
            Income.Income).filter(Income.Income.id == idOfIncome).one()
        modifiedIncome.amount = amount
        session.commit()
        logs.logger.info("Modify amount of Income based on the ID (%s)." %
                         idOfIncome)
    except Exception as e:
        logs.logger.error(e, exc_info=True)
Esempio n. 16
0
def ModifyDateOfPaymentOfIncome(idOfIncome, dateOfPayment):
    """Based on the ID of the Income object the date of payment
    is modified in database.

    Parameters
    ----------
    idOfIncome : integer
        Id of Income object.
    dateOfPayment : date
        Payment date of Income object.

    """

    logs.logger.debug("Start to modify payment date of Income based on the\
             ID (%s)." % idOfIncome)
    try:
        modifiedIncome = session.query(
            Income.Income).filter(Income.Income.id == idOfIncome).one()
        modifiedIncome.dateOfPayment = dateOfPayment
        session.commit()
        logs.logger.info("Modify payment date of Income based on the ID(%s)." %
                         idOfIncome)
    except Exception as e:
        logs.logger.error(e, exc_info=True)