1+ # coding: utf-8
2+
3+ from ....row import Row
4+ from ....characterType import numeric , alphaNumeric
5+
6+
7+ class HeaderLot :
8+
9+ def __init__ (self ):
10+ self .content = " " * 240
11+ self .defaultValues ()
12+
13+ def defaultValues (self ):
14+ structs = [
15+ ( 3 , 7 , 4 , numeric , "1" ),
16+ ( 7 , 8 , 1 , numeric , "1" ),
17+ ( 8 , 9 , 1 , alphaNumeric , "D" ),
18+ ( 13 , 16 , 3 , numeric , "030" ),
19+ ( 58 , 65 , 7 , numeric , "0000000" ),
20+ ]
21+ self .content = Row .setStructs (structs = structs , content = self .content )
22+
23+ def setSender (self , user ):
24+ structs = [
25+ (17 , 18 , 1 , numeric , "1" if len (user .identifier ) == 11 else "2" ),
26+ (18 , 32 , 14 , numeric , user .identifier ),
27+ (72 , 102 , 30 , alphaNumeric , user .name )
28+ ]
29+ self .content = Row .setStructs (structs = structs , content = self .content )
30+
31+ def setSenderBank (self , bank ):
32+ structs = [
33+ ( 0 , 3 , 3 , numeric , bank .bankId ),
34+ (52 , 57 , 5 , numeric , bank .branchCode ),
35+ (65 , 70 , 5 , numeric , bank .accountNumber ),
36+ (71 , 72 , 1 , numeric , bank .accountVerifier ),
37+ ]
38+ self .content = Row .setStructs (structs = structs , content = self .content )
39+
40+ def setSenderAddress (self , address ):
41+ structs = [
42+ (142 , 192 , 50 , alphaNumeric , "%s %s %s" % (address .streetLine1 , address .streetLine2 , address .district )),
43+ (192 , 212 , 20 , alphaNumeric , address .city ),
44+ (212 , 220 , 8 , numeric , address .zipCode ),
45+ (220 , 222 , 2 , alphaNumeric , address .stateCode ),
46+ ]
47+ self .content = Row .setStructs (structs = structs , content = self .content )
48+
49+ def setPositionInLot (self , index ):
50+ structs = [
51+ (3 , 7 , 4 , numeric , index )
52+ ]
53+ self .content = Row .setStructs (structs = structs , content = self .content )
54+
55+ def setInfo (self , kind , method ):
56+ structs = [
57+ ( 9 , 11 , 2 , numeric , kind ),
58+ (11 , 13 , 2 , numeric , method )
59+ ]
60+ self .content = Row .setStructs (structs = structs , content = self .content )
61+
62+ def setBankAgreementCode (self , code ):
63+ structs = [
64+ (32 , 45 , 13 , alphaNumeric , code ),
65+ ]
66+ self .content = Row .setStructs (structs = structs , content = self .content )
0 commit comments