Withdraw to deduct
* refactors all files and variable names * WIP: Models and attributes
This commit is contained in:
		
							parent
							
								
									3ab9081fe0
								
							
						
					
					
						commit
						3f6f576095
					
				@ -24,8 +24,8 @@ urlpatterns = [
 | 
			
		||||
    # Document remove route can be found in konova/urls.py
 | 
			
		||||
    path('<id>/document/new/', new_document_view, name='acc-new-doc'),
 | 
			
		||||
 | 
			
		||||
    # Eco-account withdraws
 | 
			
		||||
    path('<id>/remove/<withdraw_id>', withdraw_remove_view, name='withdraw-remove'),
 | 
			
		||||
    path('<id>/withdraw/new', new_withdraw_view, name='acc-new-withdraw'),
 | 
			
		||||
    # Eco-account deductions
 | 
			
		||||
    path('<id>/remove/<deduction_id>', deduction_remove_view, name='deduction-remove'),
 | 
			
		||||
    path('<id>/deduct/new', new_deduction_view, name='acc-new-deduction'),
 | 
			
		||||
 | 
			
		||||
]
 | 
			
		||||
@ -47,7 +47,7 @@ class PaymentAdmin(admin.ModelAdmin):
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class EcoAccountWithdrawAdmin(admin.ModelAdmin):
 | 
			
		||||
class EcoAccountDeductionAdmin(admin.ModelAdmin):
 | 
			
		||||
    list_display = [
 | 
			
		||||
        "id",
 | 
			
		||||
        "account",
 | 
			
		||||
@ -61,4 +61,4 @@ admin.site.register(Payment, PaymentAdmin)
 | 
			
		||||
admin.site.register(CompensationAction, CompensationActionAdmin)
 | 
			
		||||
admin.site.register(CompensationState, CompensationStateAdmin)
 | 
			
		||||
admin.site.register(EcoAccount, EcoAccountAdmin)
 | 
			
		||||
admin.site.register(EcoAccountWithdraw, EcoAccountWithdrawAdmin)
 | 
			
		||||
admin.site.register(EcoAccountWithdraw, EcoAccountDeductionAdmin)
 | 
			
		||||
 | 
			
		||||
@ -201,7 +201,7 @@ class Compensation(AbstractCompensation):
 | 
			
		||||
class EcoAccount(AbstractCompensation):
 | 
			
		||||
    """
 | 
			
		||||
    An eco account is a kind of 'prepaid' compensation. It can be compared to an account that already has been filled
 | 
			
		||||
    with some kind of currency. From this account one is able to 'withdraw' currency for current projects.
 | 
			
		||||
    with some kind of currency. From this account one is able to deduct currency for current projects.
 | 
			
		||||
    """
 | 
			
		||||
    # Users having access on this object
 | 
			
		||||
    # Not needed in regular Compensation since their access is defined by the linked intervention's access
 | 
			
		||||
@ -232,8 +232,8 @@ class EcoAccount(AbstractCompensation):
 | 
			
		||||
            self.identifier = new_id
 | 
			
		||||
        super().save(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    def get_surface_withdraws(self) -> float:
 | 
			
		||||
        """ Calculates the compensation's/account's surface
 | 
			
		||||
    def get_deductions_surface(self) -> float:
 | 
			
		||||
        """ Calculates the account's deductions sum surface
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            sum_surface (float)
 | 
			
		||||
@ -250,12 +250,12 @@ class EcoAccount(AbstractCompensation):
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        ret_val = 0
 | 
			
		||||
        withdraws = self.withdraws.filter(
 | 
			
		||||
        deductions = self.withdraws.filter(
 | 
			
		||||
            intervention__deleted=None,
 | 
			
		||||
        )
 | 
			
		||||
        withdraw_surfaces = withdraws.aggregate(Sum("surface"))["surface__sum"] or 0
 | 
			
		||||
        after_states_surfaces = self.after_states.all().aggregate(Sum("surface"))["surface__sum"] or withdraw_surfaces ## no division by zero
 | 
			
		||||
        ret_val = after_states_surfaces - withdraw_surfaces
 | 
			
		||||
        deductions_surfaces = deductions.aggregate(Sum("surface"))["surface__sum"] or 0
 | 
			
		||||
        after_states_surfaces = self.after_states.all().aggregate(Sum("surface"))["surface__sum"] or deductions_surfaces ## no division by zero
 | 
			
		||||
        ret_val = after_states_surfaces - deductions_surfaces
 | 
			
		||||
 | 
			
		||||
        if as_percentage:
 | 
			
		||||
            if after_states_surfaces > 0:
 | 
			
		||||
@ -301,20 +301,20 @@ class EcoAccount(AbstractCompensation):
 | 
			
		||||
 | 
			
		||||
class EcoAccountWithdraw(BaseResource):
 | 
			
		||||
    """
 | 
			
		||||
    A withdraw object for eco accounts
 | 
			
		||||
    A deduction object for eco accounts
 | 
			
		||||
    """
 | 
			
		||||
    account = models.ForeignKey(
 | 
			
		||||
        EcoAccount,
 | 
			
		||||
        on_delete=models.SET_NULL,
 | 
			
		||||
        null=True,
 | 
			
		||||
        blank=True,
 | 
			
		||||
        help_text="Withdrawn from",
 | 
			
		||||
        help_text="Deducted from",
 | 
			
		||||
        related_name="withdraws",
 | 
			
		||||
    )
 | 
			
		||||
    surface = models.FloatField(
 | 
			
		||||
        null=True,
 | 
			
		||||
        blank=True,
 | 
			
		||||
        help_text="Amount withdrawn (m²)",
 | 
			
		||||
        help_text="Amount deducted (m²)",
 | 
			
		||||
        validators=[
 | 
			
		||||
            MinValueValidator(limit_value=0.00),
 | 
			
		||||
        ]
 | 
			
		||||
@ -324,7 +324,7 @@ class EcoAccountWithdraw(BaseResource):
 | 
			
		||||
        on_delete=models.CASCADE,
 | 
			
		||||
        null=True,
 | 
			
		||||
        blank=True,
 | 
			
		||||
        help_text="Withdrawn for",
 | 
			
		||||
        help_text="Deducted for",
 | 
			
		||||
        related_name="withdraws",
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -252,7 +252,7 @@ class EcoAccountTable(BaseTable):
 | 
			
		||||
        """
 | 
			
		||||
        html = ""
 | 
			
		||||
        checked = value is not None
 | 
			
		||||
        tooltip = _("Not recorded yet. Can not be used for withdraws, yet.")
 | 
			
		||||
        tooltip = _("Not recorded yet. Can not be used for deductions, yet.")
 | 
			
		||||
        if checked:
 | 
			
		||||
            value = value.timestamp
 | 
			
		||||
            value = localtime(value)
 | 
			
		||||
 | 
			
		||||
@ -1,17 +1,17 @@
 | 
			
		||||
{% load i18n l10n fontawesome_5 humanize %}
 | 
			
		||||
<div id="eco-account-withdraws" class="card">
 | 
			
		||||
<div id="eco-account-deductions" class="card">
 | 
			
		||||
    <div class="card-header rlp-r">
 | 
			
		||||
        <div class="row">
 | 
			
		||||
            <div class="col-sm-6">
 | 
			
		||||
                <h5>
 | 
			
		||||
                    <span class="badge badge-light">{{withdraws.count}}</span>
 | 
			
		||||
                    {% trans 'Eco Account Withdraws' %}
 | 
			
		||||
                    <span class="badge badge-light">{{deductions.count}}</span>
 | 
			
		||||
                    {% trans 'Eco Account Deductions' %}
 | 
			
		||||
                </h5>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="col-sm-6">
 | 
			
		||||
                <div class="d-flex justify-content-end">
 | 
			
		||||
                    {% if is_default_member and has_access  %}
 | 
			
		||||
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:acc-new-withdraw' obj.id %}" title="{% trans 'Add new withdraw' %}">
 | 
			
		||||
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:acc-new-deduction' obj.id %}" title="{% trans 'Add new deduction' %}">
 | 
			
		||||
                        {% fa5_icon 'plus' %}
 | 
			
		||||
                        {% fa5_icon 'tree' %}
 | 
			
		||||
                    </button>
 | 
			
		||||
@ -42,25 +42,25 @@
 | 
			
		||||
            </tr>
 | 
			
		||||
            </thead>
 | 
			
		||||
            <tbody>
 | 
			
		||||
            {% for withdraw in withdraws %}
 | 
			
		||||
            {% for deduction in deductions %}
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td class="align-middle">
 | 
			
		||||
                    <a href="{% url 'intervention:open' withdraw.intervention.id %}">
 | 
			
		||||
                        {{ withdraw.intervention.identifier }}
 | 
			
		||||
                    <a href="{% url 'intervention:open' deduction.intervention.id %}">
 | 
			
		||||
                        {{ deduction.intervention.identifier }}
 | 
			
		||||
                    </a>
 | 
			
		||||
                </td>
 | 
			
		||||
                <td class="align-middle">
 | 
			
		||||
                    {% if withdraw.intervention.recorded %}
 | 
			
		||||
                        <em title='{{ withdraw.intervention.recorded_tooltip }}' class='fas fa-bookmark registered-bookmark'></em>
 | 
			
		||||
                    {% if deduction.intervention.recorded %}
 | 
			
		||||
                        <em title='{{ deduction.intervention.recorded_tooltip }}' class='fas fa-bookmark registered-bookmark'></em>
 | 
			
		||||
                    {% else %}
 | 
			
		||||
                        <em title='{{ withdraw.intervention.recorded_tooltip }}' class='far fa-bookmark'></em>
 | 
			
		||||
                        <em title='{{ deduction.intervention.recorded_tooltip }}' class='far fa-bookmark'></em>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                </td>
 | 
			
		||||
                <td class="align-middle">{{ withdraw.surface|floatformat:2|intcomma }} m²</td>
 | 
			
		||||
                <td class="align-middle">{{ withdraw.created.timestamp|default_if_none:""|naturalday}}</td>
 | 
			
		||||
                <td class="align-middle">{{ deduction.surface|floatformat:2|intcomma }} m²</td>
 | 
			
		||||
                <td class="align-middle">{{ deduction.created.timestamp|default_if_none:""|naturalday}}</td>
 | 
			
		||||
                <td>
 | 
			
		||||
                    {% if is_default_member and has_access  %}
 | 
			
		||||
                    <button data-form-url="{% url 'compensation:withdraw-remove' withdraw.account.id withdraw.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove Withdraw' %}">
 | 
			
		||||
                    <button data-form-url="{% url 'compensation:deduction-remove' deduction.account.id deduction.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove Deduction' %}">
 | 
			
		||||
                        {% fa5_icon 'trash' %}
 | 
			
		||||
                    </button>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
@ -110,7 +110,7 @@
 | 
			
		||||
            {% include 'compensation/detail/eco_account/includes/documents.html' %}
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="col-sm-12 col-md-12 col-lg-6">
 | 
			
		||||
            {% include 'compensation/detail/eco_account/includes/withdraws.html' %}
 | 
			
		||||
            {% include 'compensation/detail/eco_account/includes/deductions.html' %}
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@ from django.shortcuts import render, get_object_or_404
 | 
			
		||||
from compensation.forms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm
 | 
			
		||||
from compensation.models import EcoAccount
 | 
			
		||||
from compensation.tables import EcoAccountTable
 | 
			
		||||
from intervention.forms import NewWithdrawForm
 | 
			
		||||
from intervention.forms import NewDeductionForm
 | 
			
		||||
from konova.contexts import BaseContext
 | 
			
		||||
from konova.decorators import any_group_check, default_group_required, conservation_office_group_required
 | 
			
		||||
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordModalForm
 | 
			
		||||
@ -94,10 +94,10 @@ def open_view(request: HttpRequest, id: str):
 | 
			
		||||
    sum_after_states = after_states.aggregate(Sum("surface"))["surface__sum"] or 0
 | 
			
		||||
    diff_states = abs(sum_before_states - sum_after_states)
 | 
			
		||||
 | 
			
		||||
    # Calculate rest of available surface for withdraws
 | 
			
		||||
    # Calculate rest of available surface for deductions
 | 
			
		||||
    available = acc.get_available_rest(as_percentage=True)
 | 
			
		||||
 | 
			
		||||
    withdraws = acc.withdraws.filter(
 | 
			
		||||
    deductions = acc.withdraws.filter(
 | 
			
		||||
        intervention__deleted=None,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
@ -115,7 +115,7 @@ def open_view(request: HttpRequest, id: str):
 | 
			
		||||
        "is_zb_member": in_group(_user, ZB_GROUP),
 | 
			
		||||
        "is_ets_member": in_group(_user, ETS_GROUP),
 | 
			
		||||
        "LANIS_LINK": acc.get_LANIS_link(),
 | 
			
		||||
        "withdraws": withdraws,
 | 
			
		||||
        "deductions": deductions,
 | 
			
		||||
    }
 | 
			
		||||
    context = BaseContext(request, context).context
 | 
			
		||||
    return render(request, template, context)
 | 
			
		||||
@ -143,27 +143,27 @@ def remove_view(request: HttpRequest, id: str):
 | 
			
		||||
 | 
			
		||||
@login_required
 | 
			
		||||
@default_group_required
 | 
			
		||||
def withdraw_remove_view(request: HttpRequest, id: str, withdraw_id: str):
 | 
			
		||||
    """ Renders a modal view for removing withdraws
 | 
			
		||||
def deduction_remove_view(request: HttpRequest, id: str, deduction_id: str):
 | 
			
		||||
    """ Renders a modal view for removing deductions
 | 
			
		||||
 | 
			
		||||
    Args:
 | 
			
		||||
        request (HttpRequest): The incoming request
 | 
			
		||||
        id (str): The eco account's id
 | 
			
		||||
        withdraw_id (str): The withdraw's id
 | 
			
		||||
        deduction_id (str): The deduction's id
 | 
			
		||||
 | 
			
		||||
    Returns:
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    acc = get_object_or_404(EcoAccount, id=id)
 | 
			
		||||
    try:
 | 
			
		||||
        eco_withdraw = acc.withdraws.get(id=withdraw_id)
 | 
			
		||||
        eco_deduction = acc.withdraws.get(id=deduction_id)
 | 
			
		||||
    except ObjectDoesNotExist:
 | 
			
		||||
        raise Http404("Unknown withdraw")
 | 
			
		||||
        raise Http404("Unknown deduction")
 | 
			
		||||
 | 
			
		||||
    form = RemoveModalForm(request.POST or None, instance=eco_withdraw, user=request.user)
 | 
			
		||||
    form = RemoveModalForm(request.POST or None, instance=eco_deduction, user=request.user)
 | 
			
		||||
    return form.process_request(
 | 
			
		||||
        request=request,
 | 
			
		||||
        msg_success=_("Withdraw removed")
 | 
			
		||||
        msg_success=_("Deduction removed")
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -291,19 +291,19 @@ def new_document_view(request: HttpRequest, id: str):
 | 
			
		||||
 | 
			
		||||
@login_required
 | 
			
		||||
@default_group_required
 | 
			
		||||
def new_withdraw_view(request: HttpRequest, id: str):
 | 
			
		||||
    """ Renders a modal form view for creating withdraws
 | 
			
		||||
def new_deduction_view(request: HttpRequest, id: str):
 | 
			
		||||
    """ Renders a modal form view for creating deductions
 | 
			
		||||
 | 
			
		||||
    Args:
 | 
			
		||||
        request ():
 | 
			
		||||
        id ():
 | 
			
		||||
        request (HttpRequest): THe incoming request
 | 
			
		||||
        id (str): The eco account's id
 | 
			
		||||
 | 
			
		||||
    Returns:
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    acc = get_object_or_404(EcoAccount, id=id)
 | 
			
		||||
    form = NewWithdrawForm(request.POST or None, instance=acc, user=request.user)
 | 
			
		||||
    form = NewDeductionForm(request.POST or None, instance=acc, user=request.user)
 | 
			
		||||
    return form.process_request(
 | 
			
		||||
        request,
 | 
			
		||||
        msg_success=_("Withdraw added")
 | 
			
		||||
        msg_success=_("Deduction added")
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
@ -451,8 +451,8 @@ class RunCheckForm(BaseModalForm):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class NewWithdrawForm(BaseModalForm):
 | 
			
		||||
    """ Form for creating new withdraws
 | 
			
		||||
class NewDeductionForm(BaseModalForm):
 | 
			
		||||
    """ Form for creating new deduction
 | 
			
		||||
 | 
			
		||||
    Can be used for Intervention view as well as for EcoAccount views.
 | 
			
		||||
 | 
			
		||||
@ -463,7 +463,7 @@ class NewWithdrawForm(BaseModalForm):
 | 
			
		||||
    account = forms.ModelChoiceField(
 | 
			
		||||
        label=_("Eco-account"),
 | 
			
		||||
        label_suffix="",
 | 
			
		||||
        help_text=_("Only recorded accounts can be selected for withdraws"),
 | 
			
		||||
        help_text=_("Only recorded accounts can be selected for deductions"),
 | 
			
		||||
        queryset=EcoAccount.objects.filter(deleted=None),
 | 
			
		||||
        widget=autocomplete.ModelSelect2(
 | 
			
		||||
            url="accounts-autocomplete",
 | 
			
		||||
@ -497,8 +497,8 @@ class NewWithdrawForm(BaseModalForm):
 | 
			
		||||
 | 
			
		||||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
        self.form_title = _("New Withdraw")
 | 
			
		||||
        self.form_caption = _("Enter the information for a new withdraw from a chosen eco-account")
 | 
			
		||||
        self.form_title = _("New Deduction")
 | 
			
		||||
        self.form_caption = _("Enter the information for a new deduction from a chosen eco-account")
 | 
			
		||||
        self.is_intervention_initially = False
 | 
			
		||||
 | 
			
		||||
        # Add a placeholder for field 'surface' without having to define the whole widget above
 | 
			
		||||
@ -520,7 +520,7 @@ class NewWithdrawForm(BaseModalForm):
 | 
			
		||||
    def is_valid(self):
 | 
			
		||||
        """ Custom validity check
 | 
			
		||||
 | 
			
		||||
        Makes sure the withdraw can not contain more surface than the account still provides
 | 
			
		||||
        Makes sure the deduction can not contain more surface than the account still provides
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            is_valid (bool)
 | 
			
		||||
@ -534,20 +534,20 @@ class NewWithdrawForm(BaseModalForm):
 | 
			
		||||
        if not acc.recorded:
 | 
			
		||||
            self.add_error(
 | 
			
		||||
                "account",
 | 
			
		||||
                _("Eco-account {} is not recorded yet. You can only withdraw from recorded accounts.").format(acc.identifier)
 | 
			
		||||
                _("Eco-account {} is not recorded yet. You can only deduct from recorded accounts.").format(acc.identifier)
 | 
			
		||||
            )
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        # Calculate valid surface
 | 
			
		||||
        sum_surface = acc.get_surface()
 | 
			
		||||
        sum_surface_withdraws = acc.get_surface_withdraws()
 | 
			
		||||
        rest_surface = sum_surface - sum_surface_withdraws
 | 
			
		||||
        sum_surface_deductions = acc.get_deductions_surface()
 | 
			
		||||
        rest_surface = sum_surface - sum_surface_deductions
 | 
			
		||||
        form_surface = float(self.cleaned_data["surface"])
 | 
			
		||||
        is_valid_surface = form_surface < rest_surface
 | 
			
		||||
        if not is_valid_surface:
 | 
			
		||||
            self.add_error(
 | 
			
		||||
                "surface",
 | 
			
		||||
                    _("The account {} has not enough surface for a withdraw of {} m². There are only {} m² left").format(acc.identifier, form_surface, rest_surface),
 | 
			
		||||
                    _("The account {} has not enough surface for a deduction of {} m². There are only {} m² left").format(acc.identifier, form_surface, rest_surface),
 | 
			
		||||
            )
 | 
			
		||||
        return is_valid_surface and super_result
 | 
			
		||||
 | 
			
		||||
@ -566,19 +566,19 @@ class NewWithdrawForm(BaseModalForm):
 | 
			
		||||
            self.instance.modified = user_action_edit
 | 
			
		||||
            self.instance.save()
 | 
			
		||||
 | 
			
		||||
            # Create withdraw depending on Intervention or EcoAccount as the initial instance
 | 
			
		||||
            # Create deductions depending on Intervention or EcoAccount as the initial instance
 | 
			
		||||
            if self.is_intervention_initially:
 | 
			
		||||
                withdraw = EcoAccountWithdraw.objects.create(
 | 
			
		||||
                deduction = EcoAccountWithdraw.objects.create(
 | 
			
		||||
                    intervention=self.instance,
 | 
			
		||||
                    account=self.cleaned_data["account"],
 | 
			
		||||
                    surface=self.cleaned_data["surface"],
 | 
			
		||||
                    created=user_action_create,
 | 
			
		||||
                )
 | 
			
		||||
            else:
 | 
			
		||||
                withdraw = EcoAccountWithdraw.objects.create(
 | 
			
		||||
                deduction = EcoAccountWithdraw.objects.create(
 | 
			
		||||
                    intervention=self.cleaned_data["intervention"],
 | 
			
		||||
                    account=self.instance,
 | 
			
		||||
                    surface=self.cleaned_data["surface"],
 | 
			
		||||
                    created=user_action_create,
 | 
			
		||||
                )
 | 
			
		||||
        return withdraw
 | 
			
		||||
        return deduction
 | 
			
		||||
@ -1,17 +1,17 @@
 | 
			
		||||
{% load i18n l10n fontawesome_5 humanize %}
 | 
			
		||||
<div id="eco-account-withdraws" class="card">
 | 
			
		||||
<div id="eco-account-deductions" class="card">
 | 
			
		||||
    <div class="card-header rlp-r">
 | 
			
		||||
        <div class="row">
 | 
			
		||||
            <div class="col-sm-6">
 | 
			
		||||
                <h5>
 | 
			
		||||
                    <span class="badge badge-light">{{intervention.withdraws.count}}</span>
 | 
			
		||||
                    {% trans 'Eco Account Withdraws' %}
 | 
			
		||||
                    {% trans 'Eco Account Deductions' %}
 | 
			
		||||
                </h5>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="col-sm-6">
 | 
			
		||||
                <div class="d-flex justify-content-end">
 | 
			
		||||
                    {% if is_default_member and has_access  %}
 | 
			
		||||
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'intervention:acc-new-withdraw' intervention.id %}" title="{% trans 'Add new withdraw' %}">
 | 
			
		||||
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'intervention:acc-new-deduction' intervention.id %}" title="{% trans 'Add new deduction' %}">
 | 
			
		||||
                        {% fa5_icon 'plus' %}
 | 
			
		||||
                        {% fa5_icon 'tree' %}
 | 
			
		||||
                    </button>
 | 
			
		||||
@ -39,21 +39,21 @@
 | 
			
		||||
            </tr>
 | 
			
		||||
            </thead>
 | 
			
		||||
            <tbody>
 | 
			
		||||
            {% for withdraw in intervention.withdraws.all %}
 | 
			
		||||
            <tr {% if withdraw.account.deleted %}class="align-middle alert-danger" title="{% trans 'Eco-account deleted! Withdraw invalid!' %}" {% elif not withdraw.account.recorded %}class="align-middle alert-danger" title="{% trans 'Eco-account not recorded! Withdraw invalid!' %}"  {% endif %}>
 | 
			
		||||
            {% for deduction in intervention.withdraws.all %}
 | 
			
		||||
            <tr {% if deduction.account.deleted %}class="align-middle alert-danger" title="{% trans 'Eco-account deleted! Deduction invalid!' %}" {% elif not deduction.account.recorded %}class="align-middle alert-danger" title="{% trans 'Eco-account not recorded! Deduction invalid!' %}"  {% endif %}>
 | 
			
		||||
                <td class="align-middle">
 | 
			
		||||
                    <a href="{% url 'compensation:acc-open' withdraw.account.id %}">
 | 
			
		||||
                        {% if withdraw.account.deleted or not withdraw.account.recorded %}
 | 
			
		||||
                    <a href="{% url 'compensation:acc-open' deduction.account.id %}">
 | 
			
		||||
                        {% if deduction.account.deleted or not deduction.account.recorded %}
 | 
			
		||||
                        {% fa5_icon 'exclamation-triangle' %}
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                        {{ withdraw.account.identifier }}
 | 
			
		||||
                        {{ deduction.account.identifier }}
 | 
			
		||||
                    </a>
 | 
			
		||||
                </td>
 | 
			
		||||
                <td class="align-middle">{{ withdraw.surface|floatformat:2|intcomma }} m²</td>
 | 
			
		||||
                <td class="align-middle">{{ withdraw.created.timestamp|default_if_none:""|naturalday}}</td>
 | 
			
		||||
                <td class="align-middle">{{ deduction.surface|floatformat:2|intcomma }} m²</td>
 | 
			
		||||
                <td class="align-middle">{{ deduction.created.timestamp|default_if_none:""|naturalday}}</td>
 | 
			
		||||
                <td>
 | 
			
		||||
                    {% if is_default_member and has_access  %}
 | 
			
		||||
                    <button data-form-url="{% url 'compensation:withdraw-remove' withdraw.account.id withdraw.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove Withdraw' %}">
 | 
			
		||||
                    <button data-form-url="{% url 'compensation:deduction-remove' deduction.account.id deduction.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove Deduction' %}">
 | 
			
		||||
                        {% fa5_icon 'trash' %}
 | 
			
		||||
                    </button>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
@ -133,7 +133,7 @@
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="row">
 | 
			
		||||
        <div class="col-sm-12 col-md-12 col-lg-6">
 | 
			
		||||
            {% include 'intervention/detail/includes/withdraws.html' %}
 | 
			
		||||
            {% include 'intervention/detail/includes/deductions.html' %}
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="col-sm-12 col-md-12 col-lg-6">
 | 
			
		||||
            {% include 'intervention/detail/includes/revocation.html' %}
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@ Created on: 30.11.20
 | 
			
		||||
from django.urls import path
 | 
			
		||||
 | 
			
		||||
from intervention.views import index_view, new_view, open_view, edit_view, remove_view, new_document_view, share_view, \
 | 
			
		||||
    create_share_view, remove_revocation_view, new_revocation_view, run_check_view, log_view, new_withdraw_view, \
 | 
			
		||||
    create_share_view, remove_revocation_view, new_revocation_view, run_check_view, log_view, new_deduction_view, \
 | 
			
		||||
    record_view
 | 
			
		||||
 | 
			
		||||
app_name = "intervention"
 | 
			
		||||
@ -25,8 +25,8 @@ urlpatterns = [
 | 
			
		||||
    path('<id>/check', run_check_view, name='run-check'),
 | 
			
		||||
    path('<id>/record', record_view, name='record'),
 | 
			
		||||
 | 
			
		||||
    # Withdraws
 | 
			
		||||
    path('<id>/withdraw/new', new_withdraw_view, name='acc-new-withdraw'),
 | 
			
		||||
    # Deductions
 | 
			
		||||
    path('<id>/deduction/new', new_deduction_view, name='acc-new-deduction'),
 | 
			
		||||
 | 
			
		||||
    # Revocation routes
 | 
			
		||||
    path('<id>/revocation/new', new_revocation_view, name='new-revocation'),
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ from django.http import HttpRequest
 | 
			
		||||
from django.shortcuts import render, get_object_or_404
 | 
			
		||||
 | 
			
		||||
from intervention.forms import NewInterventionForm, EditInterventionForm, ShareInterventionForm, NewRevocationForm, \
 | 
			
		||||
    RunCheckForm, NewWithdrawForm
 | 
			
		||||
    RunCheckForm, NewDeductionForm
 | 
			
		||||
from intervention.models import Intervention, Revocation
 | 
			
		||||
from intervention.tables import InterventionTable
 | 
			
		||||
from konova.contexts import BaseContext
 | 
			
		||||
@ -341,21 +341,21 @@ def log_view(request: HttpRequest, id: str):
 | 
			
		||||
 | 
			
		||||
@login_required
 | 
			
		||||
@default_group_required
 | 
			
		||||
def new_withdraw_view(request: HttpRequest, id: str):
 | 
			
		||||
    """ Renders a modal form view for creating withdraws
 | 
			
		||||
def new_deduction_view(request: HttpRequest, id: str):
 | 
			
		||||
    """ Renders a modal form view for creating deductions
 | 
			
		||||
 | 
			
		||||
    Args:
 | 
			
		||||
        request (HttpRequest): The incoming request
 | 
			
		||||
        id (str): The intervention's id which shall get a new withdraw
 | 
			
		||||
        id (str): The intervention's id which shall benefit from this deduction
 | 
			
		||||
 | 
			
		||||
    Returns:
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    intervention = get_object_or_404(Intervention, id=id)
 | 
			
		||||
    form = NewWithdrawForm(request.POST or None, instance=intervention, user=request.user)
 | 
			
		||||
    form = NewDeductionForm(request.POST or None, instance=intervention, user=request.user)
 | 
			
		||||
    return form.process_request(
 | 
			
		||||
        request,
 | 
			
		||||
        msg_success=_("Withdraw added")
 | 
			
		||||
        msg_success=_("Deduction added")
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -127,7 +127,7 @@
 | 
			
		||||
                        <div class="col-sm">
 | 
			
		||||
                            <div class="row my-1">
 | 
			
		||||
                                <a href="{% url 'home' %}">
 | 
			
		||||
                                    <button class="btn btn-default">{% fa5_icon 'magic' %} {% trans 'Withdraw' %}</button>
 | 
			
		||||
                                    <button class="btn btn-default">{% fa5_icon 'magic' %} {% trans 'Deduct' %}</button>
 | 
			
		||||
                                </a>
 | 
			
		||||
                            </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							@ -172,7 +172,7 @@ msgstr "Maßnahmentyp wählen"
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/documents.html:34
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:39
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:39
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:37
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:37
 | 
			
		||||
#: ema/templates/ema/detail/includes/actions.html:37
 | 
			
		||||
#: ema/templates/ema/detail/includes/deadlines.html:37
 | 
			
		||||
#: ema/templates/ema/detail/includes/documents.html:34
 | 
			
		||||
@ -182,7 +182,7 @@ msgstr "Maßnahmentyp wählen"
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/documents.html:34
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/payments.html:37
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/revocation.html:41
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:37
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:37
 | 
			
		||||
#: templates/log.html:10
 | 
			
		||||
msgid "Action"
 | 
			
		||||
msgstr "Aktionen"
 | 
			
		||||
@ -196,8 +196,8 @@ msgid "Select the unit"
 | 
			
		||||
msgstr "Einheit wählen"
 | 
			
		||||
 | 
			
		||||
#: compensation/forms.py:334
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:31
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:31
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:31
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:31
 | 
			
		||||
msgid "Amount"
 | 
			
		||||
msgstr "Menge"
 | 
			
		||||
 | 
			
		||||
@ -353,7 +353,7 @@ msgid "Eco-account"
 | 
			
		||||
msgstr "Ökokonto"
 | 
			
		||||
 | 
			
		||||
#: compensation/tables.py:255
 | 
			
		||||
msgid "Not recorded yet. Can not be used for withdraws, yet."
 | 
			
		||||
msgid "Not recorded yet. Can not be used for deductions, yet."
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Noch nicht verzeichnet. Kann noch nicht für Abbuchungen genutzt werden."
 | 
			
		||||
 | 
			
		||||
@ -576,39 +576,39 @@ msgstr "Entzeichnen"
 | 
			
		||||
msgid "Record"
 | 
			
		||||
msgstr "Verzeichnen"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:8
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:8
 | 
			
		||||
msgid "Eco Account Withdraws"
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:8
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:8
 | 
			
		||||
msgid "Eco Account Deductions"
 | 
			
		||||
msgstr "Ökokonto Abbuchungen"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:14
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:14
 | 
			
		||||
msgid "Add new withdraw"
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:14
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:14
 | 
			
		||||
msgid "Add new deduction"
 | 
			
		||||
msgstr "Neue Abbuchung hinzufügen"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:28
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:28
 | 
			
		||||
msgid "Intervention Identifier"
 | 
			
		||||
msgstr "Eingriffskennung"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:34
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:34
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:34
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:34
 | 
			
		||||
#: user/models.py:51
 | 
			
		||||
msgid "Created"
 | 
			
		||||
msgstr "Erstellt"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:43
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:43
 | 
			
		||||
msgid "Eco-account deleted! Withdraw invalid!"
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:43
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:43
 | 
			
		||||
msgid "Eco-account deleted! Deduction invalid!"
 | 
			
		||||
msgstr "Ökokonto gelöscht! Abbuchung ungültig!"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:43
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:43
 | 
			
		||||
msgid "Eco-account not recorded! Withdraw invalid!"
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:43
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:43
 | 
			
		||||
msgid "Eco-account not recorded! Deduction invalid!"
 | 
			
		||||
msgstr "Ökokonto nicht verzeichnet! Abbuchung ungültig!"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:56
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:56
 | 
			
		||||
msgid "Remove Withdraw"
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:56
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:56
 | 
			
		||||
msgid "Remove Deduction"
 | 
			
		||||
msgstr "Abbuchung entfernen"
 | 
			
		||||
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/view.html:57
 | 
			
		||||
@ -687,7 +687,7 @@ msgid "Eco-account removed"
 | 
			
		||||
msgstr "Ökokonto entfernt"
 | 
			
		||||
 | 
			
		||||
#: compensation/views/eco_account_views.py:161
 | 
			
		||||
msgid "Withdraw removed"
 | 
			
		||||
msgid "Deduction removed"
 | 
			
		||||
msgstr "Abbuchung entfernt"
 | 
			
		||||
 | 
			
		||||
#: compensation/views/eco_account_views.py:204 ema/views.py:170
 | 
			
		||||
@ -701,7 +701,7 @@ msgid "{} recorded"
 | 
			
		||||
msgstr "{} verzeichnet"
 | 
			
		||||
 | 
			
		||||
#: compensation/views/eco_account_views.py:303 intervention/views.py:358
 | 
			
		||||
msgid "Withdraw added"
 | 
			
		||||
msgid "Deduction added"
 | 
			
		||||
msgstr "Abbuchung hinzugefügt"
 | 
			
		||||
 | 
			
		||||
#: compensation/views/payment_views.py:36
 | 
			
		||||
@ -874,7 +874,7 @@ msgstr ""
 | 
			
		||||
"wurden:"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms.py:464
 | 
			
		||||
msgid "Only recorded accounts can be selected for withdraws"
 | 
			
		||||
msgid "Only recorded accounts can be selected for deductions"
 | 
			
		||||
msgstr "Nur verzeichnete Ökokonten können für Abbuchungen verwendet werden."
 | 
			
		||||
 | 
			
		||||
#: intervention/forms.py:483 intervention/forms.py:490
 | 
			
		||||
@ -889,16 +889,16 @@ msgid "Only shared interventions can be selected"
 | 
			
		||||
msgstr "Nur freigegebene Eingriffe können gewählt werden"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms.py:498
 | 
			
		||||
msgid "New Withdraw"
 | 
			
		||||
msgid "New Deduction"
 | 
			
		||||
msgstr "Neue Abbuchung"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms.py:499
 | 
			
		||||
msgid "Enter the information for a new withdraw from a chosen eco-account"
 | 
			
		||||
msgid "Enter the information for a new deduction from a chosen eco-account"
 | 
			
		||||
msgstr "Geben Sie die Informationen für eine neue Abbuchung ein."
 | 
			
		||||
 | 
			
		||||
#: intervention/forms.py:535
 | 
			
		||||
msgid ""
 | 
			
		||||
"Eco-account {} is not recorded yet. You can only withdraw from recorded "
 | 
			
		||||
"Eco-account {} is not recorded yet. You can only deduct from recorded "
 | 
			
		||||
"accounts."
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Ökokonto {} ist noch nicht verzeichnet. Abbuchungen können nur von "
 | 
			
		||||
@ -906,7 +906,7 @@ msgstr ""
 | 
			
		||||
 | 
			
		||||
#: intervention/forms.py:548
 | 
			
		||||
msgid ""
 | 
			
		||||
"The account {} has not enough surface for a withdraw of {} m². There are "
 | 
			
		||||
"The account {} has not enough surface for a deduction of {} m². There are "
 | 
			
		||||
"only {} m² left"
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Das Ökokonto {} hat für eine Abbuchung von {} m² nicht ausreichend "
 | 
			
		||||
@ -992,7 +992,7 @@ msgstr "Vom"
 | 
			
		||||
msgid "Remove revocation"
 | 
			
		||||
msgstr "Widerspruch entfernen"
 | 
			
		||||
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/withdraws.html:28
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/deductions.html:28
 | 
			
		||||
msgid "Account Identifier"
 | 
			
		||||
msgstr "Ökokonto Kennung"
 | 
			
		||||
 | 
			
		||||
@ -1230,7 +1230,7 @@ msgid "Show"
 | 
			
		||||
msgstr "Anzeigen"
 | 
			
		||||
 | 
			
		||||
#: konova/templates/konova/home.html:130
 | 
			
		||||
msgid "Withdraw"
 | 
			
		||||
msgid "Deduct"
 | 
			
		||||
msgstr "Abbuchen"
 | 
			
		||||
 | 
			
		||||
#: konova/utils/message_templates.py:11
 | 
			
		||||
@ -2759,7 +2759,7 @@ msgstr ""
 | 
			
		||||
#~ msgid "New eco-account"
 | 
			
		||||
#~ msgstr "Neues Ökokonto"
 | 
			
		||||
 | 
			
		||||
#~ msgid "Withdraw from eco-account"
 | 
			
		||||
#~ msgid "Deduct from eco-account"
 | 
			
		||||
#~ msgstr "Von Konto abbuchen"
 | 
			
		||||
 | 
			
		||||
#~ msgid "You are currently working as "
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user