コード例 #1
0
def activity_select_domain(domain_id):

    print("Valittu editoitavaksi kustannuspaikka id = " + domain_id)

    editdomainform = DomainForm(request.form)
    domain = Domain.query.filter(
        Domain.entity_id == current_user.get_entity_id(),
        Domain.id == domain_id).first()
    editdomainform.id.data = domain_id
    editdomainform.orderer.data = domain.orderer
    editdomainform.code.data = domain.code
    editdomainform.name.data = domain.name
    editdomainform.description.data = domain.description
    editdomainform.inuse.data = domain.inuse

    return render_template("subjects/list.html",
                           action="EditDomain",
                           targetactivity=domain.activity_id,
                           targetdomain=domain_id,
                           subjects=Activity.findAllActivitiesAndDomains(
                               current_user.get_entity_id()),
                           newactivityform=ActivityForm(),
                           newdomainform=DomainForm(),
                           editdomainform=editdomainform)
コード例 #2
0
def getLedgerDocumentInAForm(ledgerdocument_id):

    ledgerdocument = LedgerDocument.query.filter(
        LedgerDocument.entity_id == current_user.get_entity_id(),
        LedgerDocument.id == ledgerdocument_id).first()

    ledgerdocumentform = LedgerDocumentForm()
    ledgerdocumentform.id.data = ledgerdocument.id
    ledgerdocumentform.documenttype_id.data = ledgerdocument.documenttype_id
    ledgerdocumentform.documentnumber.data = ledgerdocument.documentnumber
    ledgerdocumentform.ledgerdate.data = ledgerdocument.ledgerdate
    ledgerdocumentform.description.data = ledgerdocument.description
    ledgerdocumentform.recorded_by.data = ledgerdocument.recorded_by
    ledgerdocumentform.approved_by.data = ledgerdocument.approved_by

    return ledgerdocumentform
コード例 #3
0
def entity_edit():

    print("Yritetään tallentaa")

    form = EntityEditForm(request.form)

    if not form.validate():
        return render_template("entity/edit.html", form=form)

    entity = Entity.query.get(current_user.get_entity_id())
    entity.code = form.code.data
    entity.name = form.name.data
    entity.description = form.description.data
    db.session().commit()

    return redirect(url_for("entity_select_for_edit"))
コード例 #4
0
def getLedgerRowInAForm(ledgerrow_id):

    ledgerrow = LedgerRow.query.filter(
        LedgerRow.entity_id == current_user.get_entity_id(),
        LedgerRow.id == ledgerrow_id).first()

    ledgerrowform = LedgerRowForm()
    ledgerrowform.id.data = ledgerrow.id
    ledgerrowform.account_id.data = ledgerrow.account_id
    if ledgerrow.amount > 0:
        ledgerrowform.debit.data = ledgerrow.amount
        ledgerrowform.credit.data = 0
    else:
        ledgerrowform.debit.data = 0
        ledgerrowform.credit.data = ledgerrow.amount * (-1)
    ledgerrowform.domain_id.data = ledgerrow.domain_id
    ledgerrowform.description.data = ledgerrow.description
    ledgerrowform.recorded_by.data = ledgerrow.recorded_by
    ledgerrowform.ledgerdocument_id.data = ledgerrow.ledgerdocument_id

    return ledgerrowform
コード例 #5
0
def getDomains():
    return Domain.query.filter(
        Domain.entity_id == current_user.get_entity_id()).order_by(Domain.code)
コード例 #6
0
def getAccounts():
    return Account.query.filter(
        Account.entity_id == current_user.get_entity_id()).order_by(
            Account.number)
コード例 #7
0
def getDocumentTypes():
    return DocumentType.query.filter(
        DocumentType.entity_id == current_user.get_entity_id()).order_by(
            DocumentType.doctype)
コード例 #8
0
def ledgers_edit_ledgerrow(ledgerrow_id):

    print("*** ledgers_edit_ledgerrow ***")

    editledgerrowform = LedgerRowForm(request.form)
    ledgerdocument_id = editledgerrowform.ledgerdocument_id.data

    if not editledgerrowform.validate():

        documenttypes = getDocumentTypes()
        accounts = getAccounts()
        domains = getDomains()

        ledgerdocumentform = getLedgerDocumentInAForm(ledgerdocument_id)

        ledgerrows = LedgerRow.query.filter(
            LedgerRow.entity_id == current_user.get_entity_id(),
            LedgerRow.ledgerdocument_id == ledgerdocument_id).order_by(
                LedgerRow.id)
        newledgerrowform = newLedgerRowForm(ledgerdocument_id)

        return render_template("ledgers/document.html",
                               action="EditLedgerRow",
                               userrole=current_user.get_role(),
                               targetledgerrow=ledgerrow_id,
                               documenttypes=documenttypes,
                               accounts=accounts,
                               domains=domains,
                               ledgerrows=ledgerrows,
                               ledgerdocumentform=ledgerdocumentform,
                               editledgerrowform=editledgerrowform,
                               newledgerrowform=newledgerrowform)

    if "action_update" in request.form:
        print("Yritetään tallentaa")
        ledgerrow = LedgerRow.query.filter(
            LedgerRow.entity_id == current_user.get_entity_id(),
            LedgerRow.id == ledgerrow_id).first()
        ledgerrow.account_id = editledgerrowform.account_id.data
        editledgerrowform.fixAmounts()
        ledgerrow.amount = (editledgerrowform.debit.data -
                            editledgerrowform.credit.data)
        ledgerrow.domain_id = editledgerrowform.domain_id.data
        ledgerrow.description = editledgerrowform.description.data
        ledgerrow.recorded_by = current_user.get_username()
        try:
            db.session().commit()
        except:
            ## TÄHÄN VIRHETILANTEEN KÄSITTELY
            pass

    elif "action_delete" in request.form:
        print("Yritetään poistaa")
        obsolete = LedgerRow.query.filter(
            LedgerRow.entity_id == current_user.get_entity_id(),
            LedgerRow.id == ledgerrow_id).first()
        try:
            db.session().delete(obsolete)
            db.session.commit()
        except:
            ## TÄHÄN VIRHETILANTEEN KÄSITTELY
            pass

    return redirect(
        url_for("ledgers_document", ledgerdocument_id=ledgerdocument_id))
コード例 #9
0
ファイル: views.py プロジェクト: majormalfunk/kirjanpito
def fiscalperiod_new_year():

    fiscalyearform = FiscalYearForm(request.form)

    if not fiscalyearform.validate():
        print("Validointi ei onnistunut")
        print("Alkupvm: ", fiscalyearform.startdate)
        print("Loppupvm: ", fiscalyearform.enddate)
        return render_template(
            "fiscalperiods/list.html",
            action="FixNewFiscalYear",
            targetyear=-1,
            targetperiod=-1,
            fiscalperiods=FiscalYear.findAllFiscalYearsAndPeriods(
                current_user.get_entity_id()),
            fixnewfiscalyearform=fiscalyearform,
            newfiscalyearform=FiscalYearForm(),
            newfiscalperiodform=FiscalPeriodForm())

    print("Yritetään tallentaa tietokantaan")

    newyear = FiscalYear(fiscalyearform.name.data,
                         fiscalyearform.startdate.data,
                         fiscalyearform.enddate.data,
                         fiscalyearform.closed.data,
                         fiscalyearform.locked.data,
                         current_user.get_entity_id())
    try:
        db.session().add(newyear)
        db.session().commit()
        print("Tilikauden " + newyear.name + " tallennus onnistui")

    except:
        ## TÄHÄN VIRHETILANTEEN KÄSITTELY
        print("Tapahtui virhe lisättäessä tilikautta tietokantaan")
        pass

    ## LISÄTÄÄN TILIKAUDELLE OLETUSJAKSOT
    periodstart = newyear.startdate
    periodend = newyear.enddate
    for p in range(newyear.startdate.month, newyear.enddate.month + 1):
        periodname = str(p)
        periodstart = date(newyear.startdate.year, p, 1)
        if p == 12:
            periodend = newyear.enddate
        else:
            periodtemp = date(newyear.startdate.year, p + 1, 1)
            periodend = periodtemp + timedelta(-1)
        if p < 10:
            periodname = "0" + periodname
        periodname = newyear.name + periodname
        ##print(periodname + " : " + str(periodstart) + " -> " + str(periodend))
        newperiod = FiscalPeriod(periodname, periodstart, periodend,
                                 newyear.closed, newyear.locked, newyear.id,
                                 current_user.get_entity_id())

        try:
            db.session().add(newperiod)
            db.session().commit()
            print("Jakson " + newperiod.name + " tallennus onnistui")

        except:
            ## TÄHÄN VIRHETILANTEEN KÄSITTELY
            print("Tapahtui virhe lisättäessä tilikautta tietokantaan")
            pass

    return redirect(url_for("fiscalperiods_index"))
コード例 #10
0
def entity_index():

    print("Userin entity_id on " + str(current_user.get_entity_id()))
    return render_template("entity/edit.html",
                           entity=Entity.query.get(
                               current_user.get_entity_id()))