2018-07-07 22:01:06 +00:00
|
|
|
# -*- mode: python; coding: utf-8 -*-
|
|
|
|
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
|
|
|
# se veut agnostique au réseau considéré, de manière à être installable en
|
|
|
|
# quelques clics.
|
|
|
|
#
|
|
|
|
# Copyright © 2018 Hugo Levy-Falk
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2018-06-21 18:03:46 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.shortcuts import redirect
|
|
|
|
from django.urls import reverse
|
2018-06-23 17:54:20 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2018-06-21 18:03:46 +00:00
|
|
|
|
2018-07-02 19:13:13 +00:00
|
|
|
from cotisations.models import Paiement
|
|
|
|
from cotisations.payment_methods.mixins import PaymentMethodMixin
|
2018-06-21 18:03:46 +00:00
|
|
|
|
|
|
|
|
2018-07-02 19:13:13 +00:00
|
|
|
class ChequePayment(PaymentMethodMixin, models.Model):
|
2018-06-21 18:03:46 +00:00
|
|
|
"""
|
2018-07-02 19:13:13 +00:00
|
|
|
The model allowing you to pay with a cheque.
|
2018-06-21 18:03:46 +00:00
|
|
|
"""
|
2018-07-15 12:58:04 +00:00
|
|
|
|
|
|
|
class Meta:
|
2018-06-23 17:54:20 +00:00
|
|
|
verbose_name = _("Cheque")
|
2018-07-15 12:58:04 +00:00
|
|
|
|
2018-07-02 19:13:13 +00:00
|
|
|
payment = models.OneToOneField(
|
|
|
|
Paiement,
|
2018-07-07 22:01:06 +00:00
|
|
|
on_delete=models.CASCADE,
|
2019-11-03 20:46:18 +00:00
|
|
|
related_name='payment_method_cheque',
|
2018-07-02 19:13:13 +00:00
|
|
|
editable=False
|
|
|
|
)
|
2018-07-07 22:01:06 +00:00
|
|
|
|
2018-06-21 18:03:46 +00:00
|
|
|
def end_payment(self, invoice, request):
|
2018-07-07 22:01:06 +00:00
|
|
|
"""Invalidates the invoice then redirect the user towards a view asking
|
|
|
|
for informations to add to the invoice before validating it.
|
|
|
|
"""
|
2018-06-21 18:03:46 +00:00
|
|
|
return redirect(reverse(
|
|
|
|
'cotisations:cheque:validate',
|
|
|
|
kwargs={'invoice_pk': invoice.pk}
|
|
|
|
))
|
2018-06-23 17:54:20 +00:00
|
|
|
|