def do(self, *args, **options): # pylint: disable=too-many-branches files = list_dir_files(options["path"]) # pprint(files) for filename in files: plain_filename = os.path.basename(filename) if parse_filename_suffix( plain_filename).upper() not in SVM_STATEMENT_SUFFIXES: print("Ignoring non-SVM file {}".format(filename)) continue if options["resolve_original_filenames"]: found = ReferencePaymentBatchFile.objects.filter( referencepaymentbatch__name=plain_filename).first() if found and not found.original_filename: assert isinstance(found, ReferencePaymentBatchFile) found.original_filename = filename found.save(update_fields=["original_filename"]) logger.info( "Original SVM reference payment batch filename of %s resolved to %s", found, filename) if options["delete_old"]: ReferencePaymentBatch.objects.filter( name=plain_filename).delete() if options["test"]: batches = parse_svm_batches_from_file(filename) pprint(batches) continue if not ReferencePaymentBatch.objects.filter( name=plain_filename).first(): print("Importing statement file {}".format(filename)) batches = parse_svm_batches_from_file(filename) if options["verbose"]: pprint(batches) with transaction.atomic(): file = ReferencePaymentBatchFile( original_filename=filename, tag=options["tag"]) file.save() save_or_store_media(file.file, filename) file.save() for data in batches: if options["auto_create_accounts"]: for rec_data in data["records"]: account_number = rec_data.get("account_number") if account_number: get_or_create_bank_account(account_number) create_reference_payment_batch(data, name=plain_filename, file=file) # pytype: disable=not-callable file.get_total_amount(force=True) else: print("Skipping reference payment file {}".format(filename))
def do(self, *args, **options): files = list_dir_files(options["path"], ".XP") for f in files: print(f) with open(f, "rb") as fp: p = Pain002(fp.read()) print(p) # pytype: disable=not-callable
def do(self, *args, **kwargs): files = list_dir_files(kwargs["path"]) for filename in files: plain_filename = os.path.basename(filename) if parse_filename_suffix(plain_filename).upper() not in AEB43_STATEMENT_SUFFIXES: print("Ignoring non-AEB43 file {}".format(filename)) continue batches = parse_aeb43_statements_from_file(filename) pprint(batches)
def do(self, *args, **options): # pylint: disable=too-many-branches if options["parse_creditor_account_data"]: self.parse_creditor_account_data() return files = list_dir_files(options["path"], options["suffix"]) for filename in files: plain_filename = os.path.basename(filename) if parse_filename_suffix(plain_filename).upper() not in CAMT053_STATEMENT_SUFFIXES: print("Ignoring non-CAMT53 file {}".format(filename)) continue if options["resolve_original_filenames"]: found = StatementFile.objects.filter(statement__name=plain_filename).first() if found and not found.original_filename: assert isinstance(found, StatementFile) found.original_filename = filename found.save(update_fields=["original_filename"]) logger.info("Original XML statement filename of %s resolved to %s", found, filename) if options["test"]: statement = camt053_parse_statement_from_file(filename) pprint(statement) continue if options["delete_old"]: Statement.objects.filter(name=plain_filename).delete() if not Statement.objects.filter(name=plain_filename).first(): print("Importing statement file {}".format(plain_filename)) statement = camt053_parse_statement_from_file(filename) if options["verbose"]: pprint(statement) with transaction.atomic(): file = StatementFile(original_filename=filename, tag=options["tag"]) file.save() save_or_store_media(file.file, filename) file.save() for data in [statement]: if options["auto_create_accounts"]: account_number = camt053_get_iban(data) if account_number: get_or_create_bank_account(account_number) camt053_create_statement(data, name=plain_filename, file=file) # pytype: disable=not-callable else: print("Skipping statement file {}".format(filename))
def do(self, *args, **options): if options["set_default_paths"]: self._set_default_paths(options) return files = list_dir_files(options["path"], "." + options["suffix"]) for f in files: if PayoutStatus.objects.is_file_processed(f): if options["verbose"]: print("Skipping processed payment status file", f) continue if options["verbose"]: print("Importing payment status file", f) try: with open(f, "rb") as fp: process_pain002_file_content(fp.read(), f) except Exception: logger.error("Error while processing PayoutStatus id=%s: %s", f.id, traceback.format_exc()) # type: ignore if not options["ignore_errors"]: raise