예제 #1
0
파일: orders.py 프로젝트: RMLL/resarmll
    def save_compta(self):
        from compta.models import Operation, PaymentMethod, ClientAccount, PlanComptable
        curdate = date.now()
        user_account = None
        try:
            user_account = ClientAccount.objects.filter(user=self.user)[0]
        except:
            user_account = None

        if not user_account:
            user_account = ClientAccount(
                    label="Client: %s #%d" % (self.user.get_full_name(), self.user.id),
                    plan=PlanComptable.get_client_account(),
                    user=self.user)
            user_account.save()

        method = PaymentMethod.get_internal_method()
        for o in self.orderdetail_set.all():
            for i in range(1, o.quantity+1):
                op = Operation(
                    debit=o.product.product_account,
                    credit=user_account,
                    label=o.product.label(),
                    comment='',
                    amount=o.price,
                    payment=method,
                    date=curdate,
                    order=self,
                    user=self.user)
                op.save()
예제 #2
0
파일: orders.py 프로젝트: RMLL/resarmll
    def save_paid(self, method, comment=None):
        from compta.models import Operation, ClientAccount
        curdate = date.now()
        self.payment_date = curdate
        self.save()
        for o in self.orderdetail_set.all():
            o.paid()

        user_account = None
        try:
            user_account = ClientAccount.objects.filter(user=self.user)[0]
        except:
            user_account = None
        if user_account:
            if comment is not None and comment != '':
                label = "Paiement '%s' (%s) commande #%d" % (method.label, comment, self.id)
            else:
                label = "Paiement '%s' commande #%d" % (method.label, self.id)
            op = Operation(
                    debit=user_account,
                    credit=method.account,
                    label=label,
                    comment='',
                    amount=self.totalamount(),
                    payment=method,
                    date=curdate,
                    date_payment=curdate,
                    order=self,
                    user=self.user)
            op.save()
예제 #3
0
    def save_compta(self):
        from compta.models import Operation, PaymentMethod, ClientAccount, PlanComptable
        curdate = date.now()
        user_account = None
        try:
            user_account = ClientAccount.objects.filter(user=self.user)[0]
        except:
            user_account = None

        if not user_account:
            user_account = ClientAccount(
                label="Client: %s #%d" %
                (self.user.get_full_name(), self.user.id),
                plan=PlanComptable.get_client_account(),
                user=self.user)
            user_account.save()

        method = PaymentMethod.get_internal_method()
        for o in self.orderdetail_set.all():
            for i in range(1, o.quantity + 1):
                op = Operation(debit=o.product.product_account,
                               credit=user_account,
                               label=o.product.label(),
                               comment='',
                               amount=o.price,
                               payment=method,
                               date=curdate,
                               order=self,
                               user=self.user)
                op.save()
예제 #4
0
    def save_paid(self, method, comment=None):
        from compta.models import Operation, ClientAccount
        curdate = date.now()
        self.payment_date = curdate
        self.save()
        for o in self.orderdetail_set.all():
            o.paid()

        user_account = None
        try:
            user_account = ClientAccount.objects.filter(user=self.user)[0]
        except:
            user_account = None
        if user_account:
            if comment is not None and comment != '':
                label = "Paiement '%s' (%s) commande #%d" % (method.label,
                                                             comment, self.id)
            else:
                label = "Paiement '%s' commande #%d" % (method.label, self.id)
            op = Operation(debit=user_account,
                           credit=method.account,
                           label=label,
                           comment='',
                           amount=self.totalamount(),
                           payment=method,
                           date=curdate,
                           date_payment=curdate,
                           order=self,
                           user=self.user)
            op.save()
예제 #5
0
파일: bank.py 프로젝트: RMLL/resarmll
 def order_paid(self, order, fee, user, data):
     curdate = date.now()
     method = self.get_paiement_method()
     order.save_paid(method, data)
     if fee > 0:
         account = self.get_supplier_account()
         if account:
             op = Operation(
                 debit=account,
                 credit=method.account,
                 label=_("Commission (fee) order #%d") % (order.id),
                 comment='',
                 amount=dec(fee),
                 payment=method,
                 date=curdate,
                 date_payment=curdate,
                 order=order,
                 user=user)
             op.save()
예제 #6
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)