Changeset 11 for import/navision_csv/UMainForm.pas
- Timestamp:
- Jul 13, 2011, 2:20:53 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
import/navision_csv/UMainForm.pas
r10 r11 18 18 { private declarations } 19 19 public 20 { public declarations }20 function CheckVAT(VAT: string): Boolean; 21 21 end; 22 22 … … 34 34 Source, Dest: TStringList; 35 35 I: Integer; 36 P: Integer; 36 37 DestLine: TStringList; 37 38 Line: TStringList; 39 VAT: string; 38 40 begin 39 41 try … … 50 52 DestLine.Add('address/city'); 51 53 DestLine.Add('vatin'); 52 DestLine.Add('vat');54 //DestLine.Add('vat'); 53 55 DestLine.Add('address/zip'); 54 DestLine.Add('address/country_id');56 //DestLine.Add('address/country_id'); 55 57 DestLine.Add('address/phone'); 56 58 DestLine.Add('address/fax'); … … 58 60 Dest.Add(DestLine.CommaText); 59 61 60 for I := 0to Source.Count - 1 do begin62 for I := 1 to Source.Count - 1 do begin 61 63 DestLine.Clear; 62 64 Line.CommaText := Source[I]; 65 66 //VAT := Trim(Line[8]); 67 //if not CheckVAT(VAT) then VAT := ''; 68 63 69 DestLine.Add('' + Line[3] + ''); 64 70 DestLine.Add('' + Line[4] + ''); … … 66 72 DestLine.Add('' + Line[6] + ''); 67 73 DestLine.Add('' + Line[7] + ''); 68 DestLine.Add('' + Line[8]+ '');74 //DestLine.Add('' + VAT + ''); 69 75 DestLine.Add('' + Line[14] + ''); 70 DestLine.Add('' + Line[15] + '');76 //DestLine.Add('' + Line[15] + ''); 71 77 DestLine.Add('' + Line[16] + ''); 72 78 DestLine.Add('' + Line[17] + ''); … … 83 89 end; 84 90 91 function TForm1.CheckVAT(VAT: string): Boolean; 92 var 93 VATNum: string; 94 Checksum: Integer; 95 VATChecksum: Integer; 96 P: Integer; 97 begin 98 VATNum := ''; 99 Checksum := 0; 100 101 P := 1; 102 while (P < Length(VAT)) and not ((VAT[P] >= '0') and (VAT[P] <= '9')) do Inc(P); 103 if (P < Length(VAT)) then VATNum := Copy(VAT, P, 255); 104 Memo1.Lines.Add(VAT + ': ' + IntToStr(P) + ': ' + VATNum); 105 VATChecksum := StrToInt(Copy(VATNum, Length(VATNum) - 1, 2)); 106 VATNum := Copy(VATNum, 1, Length(VATNum) - 2); 107 if VATNum <> '' then begin 108 for P := 1 to Length(VATNum) do begin 109 if P > 7 then begin 110 Result := False; 111 Break; 112 end; 113 Checksum := Checksum + StrToInt(VATNum[P]) * (9 - P); 114 end; 115 while Checksum >= 0 do Checksum := Checksum - 97; 116 Result := Abs(CheckSum) = VATChecksum; 117 end else Result := False; 118 end; 119 85 120 end. 86 121
Note:
See TracChangeset
for help on using the changeset viewer.