1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2024-11-26 18:37:15 +00:00

Compare commits

..

No commits in common. "f41a5a32f7417a874b497640373ea3911eb1e133" and "1f300c3b7bac0b7a31c1a252a83ba68a8268d33d" have entirely different histories.

2 changed files with 3 additions and 8 deletions

View File

@ -11,7 +11,6 @@ from note.templatetags.pretty_money import pretty_money
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--sum-all', '-s', action='store_true', help='Check if the global sum is equal to zero')
parser.add_argument('--fix', '-f', action='store_true', help='Fix note balances')
def handle(self, *args, **options):
if options["sum_all"]:
@ -30,14 +29,11 @@ class Command(BaseCommand):
.annotate(total=F("quantity") * F("amount")).aggregate(Sum("total"))["total__sum"] or 0
outcoming = Transaction.objects.filter(valid=True, source=note)\
.annotate(total=F("quantity") * F("amount")).aggregate(Sum("total"))["total__sum"] or 0
calculated_balance = incoming - outcoming
if calculated_balance != balance:
expected_balance = incoming - outcoming
if expected_balance != balance:
self.stderr.write(self.style.NOTICE("LA SOMME DES TRANSACTIONS DE LA NOTE {} NE CORRESPOND PAS "
"AVEC LE MONTANT RÉEL".format(str(note))))
self.stderr.write(self.style.NOTICE("Attendu : {}, calculé : {}"
.format(pretty_money(balance), pretty_money(calculated_balance))))
if options["fix"]:
note.balance = calculated_balance
note.save()
.format(pretty_money(balance), pretty_money(expected_balance))))
error = True
exit(1 if error else 0)

View File

@ -236,7 +236,6 @@ class Command(ImportCommand):
(obj_dict0,
child_dict0,
child_transaction) = self._membership_transaction(row, obj_dict, child_dict, pk_membership)
obj_dict0["destination_id"] = 6 # Kfet note id
bde_dict = {
"pk": pk_membership,
"user_id": user_id,