def test_test1 (self): trans = Transmission (data_sender='11223344', transmission_number='1234567') order = PaymentClaim (order_account = 15035149098, order_number = 7654321) # Note: All orders/transactions inside a PaymentClaim must # be to the same customer! order.add (due='200516', amount=250*100, kid='00010001') order.add (due='270616', amount=300*100, kid='00010002', abbreviated_name = 'Abbr. name', external_reference = 'External reference', specification = 'Hello\nLine two\n\nLast line') order.add (due='140316', amount=500*100, kid='00010003') cancellation = CancellationRequest (account=15035149098, number=7654321) cancellation.add ('200516', 250*100, '00010001') cancellation.add ('140316', 500*100, '00010003') trans.add (order) trans.add (cancellation) from io import BytesIO buf = BytesIO() trans.render (buf) #with open('fixture/test1','wb') as fp: fp.write (buf.getvalue()) self.assertEqual (buf.getvalue(), open('fixture/test1').read())
# Note: Must be unique per year + one day. #def make_order_number_generator (value=0): # while True: # yield value # value += 1 # if value >= 1e8: # raise RuntimeError ('order number to large. max 7 digits.') #next_order_number = make_order_number_generator (1).next from ordernumber import next_order_number from datetime import date, timedelta #from kidgen import generate_kid # kidgen.member(), kidgen.donor() import kidgen trans = Transmission (data_sender=args.sender, transmission_number=args.trans_no) o1 = PaymentClaim (args.account, next_order_number()) #o1.add (date.today()+timedelta(days=14), 250*100, kidgen.donor (123,1)) o1.add (date.today()+timedelta(days=14), 250*100, kidgen.donor (123), abbreviated_name = 'Abbr. name', external_reference = 'External reference', specification = 'This is the specification line') # @todo test multiple claims per order # But note: Et oppdrag kan kun inneholde transaksjoner for 1 oppdragstype # som gjelder 1 avtale. #o1.add (date.today()+timedelta(days=20), 100*100, kidgen.member (123,0)) o2 = PaymentClaim (args.account, next_order_number()) o2.add (date.today()+timedelta(days=30), 500*100, kidgen.donor (321))