Esempio n. 1
0
 def __init__(self, csv_reader: Iterable[List[str]]) -> None:
     self.summary: List[Summary] = list()
     self.detail: List[Detail] = list()
     self.nuos: List[Nuos] = list()
     self.gsl: List[Gsl] = list()
     self.excludedservicecharge: List[ExcludedServiceCharge] = list()
     self.interestcharge: List[InterestCharge] = list()
     for row in csv_reader:
         record_type = int(row[0])
         if record_type == Header.get_record_type():
             self.header = Header.from_row(row)
         elif record_type == Summary.get_record_type():
             self.summary.append(Summary.from_row(row))
         elif record_type == Detail.get_record_type():
             self.detail.append(Detail.from_row(row))
         elif record_type == Nuos.get_record_type():
             self.nuos.append(Nuos.from_row(row))
         elif record_type == Gsl.get_record_type():
             self.gsl.append(Gsl.from_row(row))
         elif record_type == ExcludedServiceCharge.get_record_type():
             self.excludedservicecharge.append(
                 ExcludedServiceCharge.from_row(row))
         elif record_type == InterestCharge.get_record_type():
             self.interestcharge.append(InterestCharge.from_row(row))
         elif record_type == Footer.get_record_type():
             self.footer = Footer.from_row(row)
         else:
             raise base.UnexpectedRecordType(
                 "got {got} when parsing Invoice file row {row}".format(
                     got=record_type, row=row))
     if self.header is None:
         raise base.MissingHeader()
     if self.footer is None:
         raise base.MissingFooter()
Esempio n. 2
0
 def __init__(self, csv_reader: Iterable[List[str]]) -> None:
     self.detail: List[Detail] = list()
     for row in csv_reader:
         record_type = int(row[0])
         if record_type == Header.get_record_type():
             self.header = Header.from_row(row)
         elif record_type == Detail.get_record_type():
             self.detail.append(Detail.from_row(row))
         elif record_type == Footer.get_record_type():
             self.footer = Footer.from_row(row)
         else:
             raise base.UnexpectedRecordType(
                 "got {got} when parsing Servicecharge file row {row}".
                 format(got=record_type, row=row))
     if self.header is None:
         raise base.MissingHeader()
     if self.footer is None:
         raise base.MissingFooter()