Example #1
0
File: views.py Project: dbaty/Brouz
def delete(request):
    transaction_id = request.matchdict['transaction_id']
    if request.POST.get('confirm') != '1':
        msg = _('You did not confirm that you want to delete '
                'this transaction.')
        request.session.flash(msg, 'error')
        url = request.route_url('edit', transaction_id=transaction_id)
        return HTTPSeeOther(url)
    session = DBSession()
    transaction = session.query(Transaction).\
        filter_by(id=transaction_id).one()
    # FIXME: If transaction is composite, we should delete the related
    # transactions: filter_by(part_of=transaction_id)
    session.delete(transaction)
    request.session.flash(_('The transaction has been deleted.'), 'success')
    return HTTPSeeOther(request.route_url('home'))
Example #2
0
File: forms.py Project: dbaty/Brouz
def make_edit_form(request, transaction):
    if transaction.composite:
        schema = CompositeTransactionSchema()
    else:
        schema = UniqueTransactionSchema()
    schema = schema.bind(request=request)
    action = request.route_url('edit', transaction_id=transaction.id)
    return Form(schema, action,
                buttons=(Button(title=_('Save changes')), ))
Example #3
0
File: forms.py Project: dbaty/Brouz
def make_add_form(request, composite):
    if composite:
        schema = CompositeTransactionSchema()
        route_name = 'add-composite'
    else:
        schema = UniqueTransactionSchema()
        route_name = 'add-unique'
    schema = schema.bind(request=request)
    return Form(schema, request.route_url(route_name),
                buttons=(Button(title=_('Add transaction')), ))
Example #4
0
File: views.py Project: dbaty/Brouz

def add_unique(request):
    form = make_add_form(request, composite=False)
    try:
        data = form.validate(request.POST.items())
    except ValidationFailure, e:
        return add_unique_form(request, e)
    data['composite'] = False
    data['part_of'] = None
    data['net_amount'] = data['net_amount'].eurocents
    data['vat'] = data['vat'].eurocents
    transaction = Transaction(**data)
    session = DBSession()
    session.add(transaction)
    request.session.flash(_('The transaction has been added.'), 'success')
    return HTTPSeeOther(request.route_url('home'))


def add_composite_form(request, form=None):
    if form is None:
        form = make_add_form(request, composite=True)
    api = TemplateAPI(request, 'add')
    bindings = {'api': api,
                'form': form}
    return render_to_response('templates/add.pt', bindings)


def add_composite(request):
    form = make_add_form(request, composite=True)
    try:
Example #5
0
File: forms.py Project: dbaty/Brouz
from brouz.models import CATEGORY_EXPENDITURE_OTHER_MISC_EXPENSES
from brouz.models import CATEGORY_EXPENDITURE_OTHER_TAXES
from brouz.models import CATEGORY_EXPENDITURE_PURCHASE
from brouz.models import CATEGORY_EXPENDITURE_SMALL_FURNITURE
from brouz.models import CATEGORY_EXPENDITURE_TRAVEL_EXPENSES
from brouz.models import CATEGORY_EXPENDITURE_VAT
from brouz.models import CATEGORY_INCOME_MISC
from brouz.models import CATEGORY_REMUNERATION
from brouz.models import PAYMENT_MEAN_CHECK
from brouz.models import PAYMENT_MEAN_CREDIT_CARD
from brouz.models import PAYMENT_MEAN_DIRECT_DEBIT
from brouz.models import PAYMENT_MEAN_WIRE_TRANSFER


CATEGORIES = (
    ('', _('Select the category...')),
    (str(CATEGORY_INCOME_MISC), _('Income')),
    OptGroup(_('Expenditure'),
             (str(CATEGORY_EXPENDITURE_PURCHASE), _('Purchase')),
             (str(CATEGORY_EXPENDITURE_VAT), _('VAT')),
             (str(CATEGORY_EXPENDITURE_CET), _('CET')),
             (str(CATEGORY_EXPENDITURE_OTHER_TAXES),
              _('Other taxes')),
             (str(CATEGORY_EXPENDITURE_DEDUCTIBLE_CSG),
              _('Deductible CSG')),
             (str(CATEGORY_EXPENDITURE_NON_DEDUCTIBLE_CSG),
              _('Non-deductible CSG')),
             (str(CATEGORY_EXPENDITURE_SMALL_FURNITURE),
              _('Small furniture')),
             (str(CATEGORY_EXPENDITURE_FEES_NO_RETROCESSION),
              _('Fees that are not retrocessions')),