Ejemplo n.º 1
0
    def fetch_last_operations(self):
        self.fetch_csv()
        lines = self.csv.splitlines()
        operations = []

        for line in lines[1:]:
            field = line.split(self.FIELD_SEPARATOR)
            operation = Operation()
            operation.date_operation = datetime.datetime.strptime(
                field[0], self.DATE_FORMAT).date()
            operation.date_valeur = datetime.datetime.strptime(
                field[1], self.DATE_FORMAT).date()
            operation.montant = float(field[2])
            operation.libelle = field[3]
            operations.append(operation)

        return operations
Ejemplo n.º 2
0
def set_revenus(request):
    if request.method == 'POST':
        revenus = float(request.POST['revenus'])
        operation_id_saisie_manuelle = request.POST['operation_id_saisie_manuelle']

        operation = Operation() if operation_id_saisie_manuelle == '' else Operation.objects.get(
            pk=int(operation_id_saisie_manuelle))
        operation.raz_categorie()
        operation.libelle = 'Revenus ' + request.user.get_full_name()
        operation.date_operation = datetime.date.today()
        operation.date_valeur = operation.date_operation
        operation.montant = revenus
        operation.compte = Compte.objects.get(utilisateurs=request.user)
        operation.recette = request.user
        operation.saisie_manuelle = True
        operation.save()

        return redirect('compta:home')

    return HttpResponse("NOK", status=400)