Пример #1
0
    def insert_ti_ref(self):
        if not self.ti_ref and self.flex_module != 'RE':
            ti_ref_search = LC_REF_RE.search(self.narration)

            if ti_ref_search:
                self.ti_ref = ti_ref_search.group()
                return True

            for ref in TIFlexRecons.objects.filter(flex_ref=self.flex_ref):
                self.ti_ref = ref.ti_ref
                return True
        return False
Пример #2
0
    def parse(self, fobj):
        parser_utility = UploadCSVParserUtility()
        for row in csv.reader(fobj, delimiter="\t"):
            if self.ok_to_parse(row):
                booking_date = parser_utility.normalize_date(row[col.g], self.date_format)
                liq_date = parser_utility.normalize_date(row[col.h], self.date_format)
                fx_amt = parser_utility.normalize_amount(row[col.j])
                ngn_amt = parser_utility.normalize_amount(row[col.k])
                narration = parser_utility.normalize(row[col.l])
                flex_module = row[col.d]
                gl_code = row[col.b]
                ccy = row[col.i]

                ti_ref_pattern = LC_REF_RE.search(narration)
                ti_ref = ti_ref_pattern and ti_ref_pattern.group() or ""

                flex_ref = row[col.a]

                if not ContingentReport.objects.filter(
                    flex_ref=flex_ref,
                    gl_code=gl_code,
                    ccy=ccy,
                    booking_date=booking_date,
                    flex_module=flex_module,
                    fx_amt=fx_amt,
                    narration=narration,
                ).exists():
                    ContingentReport.objects.create(
                        flex_ref=flex_ref,
                        flex_module=flex_module,
                        gl_code=gl_code,
                        booking_date=booking_date,
                        liq_date=liq_date,
                        ccy=ccy,
                        fx_amt=fx_amt,
                        ngn_amt=ngn_amt,
                        ti_ref=ti_ref,
                        narration=narration,
                        acct_numb=ContingentAccount.objects.get(gl_code=gl_code),
                    )