add NoteSpecial update and cleaning
This commit is contained in:
parent
3a636ce189
commit
5a4e3473be
|
@ -44,6 +44,12 @@ class Command(ImportCommand):
|
|||
def add_arguments(self, parser):
|
||||
parser.add_argument('-a', '--alias', action='store_true', help="import alias")
|
||||
|
||||
def import_special_account(self, cur):
|
||||
cur.execute("SELECT idbde, solde from comptes where idbde <=0")
|
||||
for row in cur:
|
||||
note = Note.objects.get(pk=MAP_IDBDE[row["idbde"]])
|
||||
note.amount = row["solde"]
|
||||
note.save()
|
||||
|
||||
@timed
|
||||
@transaction.atomic
|
||||
|
@ -73,7 +79,7 @@ class Command(ImportCommand):
|
|||
# clean date
|
||||
note_dict = {
|
||||
"pk": pk_note,
|
||||
"balance": 0,
|
||||
"balance": row['solde'],
|
||||
"last_negative": None,
|
||||
"is_active": True,
|
||||
"display_image": "",
|
||||
|
@ -157,7 +163,6 @@ class Command(ImportCommand):
|
|||
MAP_IDBDE[row["idbde"]] = pk_note
|
||||
pk_note += 1
|
||||
bulk_mgr.done()
|
||||
self.print_success("comptes table imported")
|
||||
|
||||
@timed
|
||||
def import_alias(self, cur, chunk_size):
|
||||
|
@ -179,7 +184,6 @@ class Command(ImportCommand):
|
|||
if alias_norm in ALIAS_SET:
|
||||
continue
|
||||
else:
|
||||
print(alias_norm)
|
||||
ALIAS_SET.add(alias_norm)
|
||||
obj_dict = {
|
||||
"pk": pk_alias,
|
||||
|
@ -191,7 +195,6 @@ class Command(ImportCommand):
|
|||
bulk_mgr.add(Alias(**obj_dict))
|
||||
bulk_mgr.done()
|
||||
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
# default args, provided by ImportCommand.
|
||||
nk15db, nk15user = kwargs['nk15db'], kwargs['nk15user']
|
||||
|
@ -199,6 +202,7 @@ class Command(ImportCommand):
|
|||
conn = pg.connect(database=nk15db, user=nk15user)
|
||||
cur = conn.cursor(cursor_factory=pge.DictCursor)
|
||||
|
||||
self.import_special_account(cur)
|
||||
self.import_account(cur, kwargs["chunk"])
|
||||
# Alias Management
|
||||
if kwargs["alias"]:
|
||||
|
|
Loading…
Reference in New Issue