Adaptación a normativa SEPA XML - Terminado y probado con banco.
git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@246 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
This commit is contained in:
parent
8aaaa03bf0
commit
e293699abf
@ -443,6 +443,7 @@ begin
|
||||
else
|
||||
Presentador.Nombre := AEmpresa.DatosBancarios.NOMBRE_PRESENTADOR;
|
||||
|
||||
Presentador.Pais := 'ES';
|
||||
GenerarCabeceraPresentador;
|
||||
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ type
|
||||
Nombre : string;
|
||||
NIFCIF : string;
|
||||
Sufijo : string;
|
||||
Pais: string;
|
||||
end;
|
||||
|
||||
TSEPAXMLFichero = record
|
||||
@ -87,6 +88,8 @@ type
|
||||
FDDTransInfo: TDirectDebitTransactionInformation;
|
||||
|
||||
procedure ComprobarDatos(sParte: string);
|
||||
function IdentificadorAcreedorSEPA(): String;
|
||||
function IdentificadorPresentadorSEPA(): String;
|
||||
protected
|
||||
procedure Error(iErr: integer); dynamic;
|
||||
public
|
||||
@ -141,7 +144,7 @@ begin
|
||||
_PAIS_DEFECTO_ := 'ES';
|
||||
|
||||
FDDInit := TDirectDebitInitiation.Create;
|
||||
FDDInit.Schema := SCHEMA_PAIN_008_002_02;
|
||||
FDDInit.Schema := SCHEMA_PAIN_008_001_02;
|
||||
end;
|
||||
|
||||
destructor TCVBNorma19SEPAXML.Destroy;
|
||||
@ -177,11 +180,11 @@ procedure TCVBNorma19SEPAXML.GenerarCabeceraPresentador;
|
||||
begin
|
||||
HayError := False;
|
||||
FDDInit.GrpHdrInitgPtyName := Presentador.Nombre;
|
||||
FDDInit.GrpHdrInitgPtyId := IdentificadorPresentadorSEPA();
|
||||
end;
|
||||
|
||||
procedure TCVBNorma19SEPAXML.GenerarRegistroAdeudo;
|
||||
var
|
||||
auxDC : integer;
|
||||
auxCadena : string;
|
||||
begin
|
||||
HayError := False;
|
||||
@ -196,8 +199,8 @@ begin
|
||||
FDDTransInfo.DbtrNm := Deudor.Nombre;
|
||||
FDDTransInfo.DbtrAcct.IBAN := Deudor.CuentaIBAN;
|
||||
FDDTransInfo.DbtrAgt.BIC := Deudor.CodigoBIC;
|
||||
FDDTransInfo.DbtrAgt.OthrID := '';
|
||||
FDDTransInfo.RmtInfUstrd := '';
|
||||
FDDTransInfo.DbtrAgt.OthrID := FIN_INSTN_NOTPROVIDED;
|
||||
FDDTransInfo.RmtInfUstrd := Adeudo.Referencia;
|
||||
FDDTransInfo.DrctDbtTxMndtRltdInf.MndtId := Adeudo.Referencia;
|
||||
FDDTransInfo.DrctDbtTxMndtRltdInf.DtOfSgntr := Now;
|
||||
{FDDTransInfo.DrctDbtTxMndtRltdInf.AmdmntInd := DD_MandateAmendmentInformationDetails_CheckBox.Checked;
|
||||
@ -214,6 +217,30 @@ procedure TCVBNorma19SEPAXML.GenerarTotalAcreedor;
|
||||
begin
|
||||
end;
|
||||
|
||||
function TCVBNorma19SEPAXML.IdentificadorAcreedorSEPA(): String;
|
||||
var
|
||||
dcstr : String;
|
||||
dc: integer;
|
||||
begin
|
||||
dcstr := Acreedor.NIFCIF;
|
||||
dcstr := Trim(StringReplace(AnsiUpperCase(dcstr), ' ', '', [rfReplaceAll]));
|
||||
dcstr := dcstr + Acreedor.Pais + '00';
|
||||
dc := 98 - SEPAModulo97(dcstr);
|
||||
result := Acreedor.Pais + IntToStr(dc) + Acreedor.Sufijo + Acreedor.NIFCIF;
|
||||
end;
|
||||
|
||||
function TCVBNorma19SEPAXML.IdentificadorPresentadorSEPA: String;
|
||||
var
|
||||
dcstr : String;
|
||||
dc: integer;
|
||||
begin
|
||||
dcstr := Presentador.NIFCIF;
|
||||
dcstr := Trim(StringReplace(AnsiUpperCase(dcstr), ' ', '', [rfReplaceAll]));
|
||||
dcstr := dcstr + Presentador.Pais + '00';
|
||||
dc := 98 - SEPAModulo97(dcstr);
|
||||
result := Presentador.Pais + IntToStr(dc) + Presentador.Sufijo + Presentador.NIFCIF;
|
||||
end;
|
||||
|
||||
procedure TCVBNorma19SEPAXML.GenerarCabeceraAcreedor;
|
||||
begin
|
||||
HayError := False;
|
||||
@ -226,12 +253,10 @@ begin
|
||||
FDDPayInfo.CdtrAcct.IBAN := Acreedor.CuentaIBAN;
|
||||
FDDPayInfo.CdtrAgt.BIC := '';
|
||||
FDDPayInfo.CdtrAgt.OthrID := FIN_INSTN_NOTPROVIDED;
|
||||
FDDPayInfo.CdtrSchmeIdIdPrvtIdOthrId := Acreedor.CuentaIBAN;
|
||||
FDDPayInfo.CdtrSchmeIdIdPrvtIdOthrId := IdentificadorAcreedorSEPA();
|
||||
FDDInit.AppendPmtInfEntry(FDDPayInfo);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TCVBNorma19SEPAXML.ComprobarDatos(sParte: string);
|
||||
var
|
||||
bError: boolean;
|
||||
@ -423,6 +448,4 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
end.
|
||||
|
||||
@ -39,6 +39,7 @@ uses
|
||||
const
|
||||
SCHEMA_PAIN_001_002_03 = 'pain.001.002.03';
|
||||
SCHEMA_PAIN_001_003_03 = 'pain.001.003.03';
|
||||
SCHEMA_PAIN_008_001_02 = 'pain.008.001.02';
|
||||
SCHEMA_PAIN_008_002_02 = 'pain.008.002.02';
|
||||
SCHEMA_PAIN_008_003_02 = 'pain.008.003.02';
|
||||
|
||||
@ -165,6 +166,9 @@ type
|
||||
procedure SaveToStream(const stream: TStream; const schema: String);
|
||||
end;
|
||||
|
||||
|
||||
function ConvertAlphaToNumber(const s: String): String;
|
||||
|
||||
function SEPAGenerateUUID: String;
|
||||
|
||||
function SEPACleanIBANorBICorCI(s: String): String;
|
||||
@ -505,7 +509,7 @@ end;
|
||||
procedure SEPAWriteLine(const stream: TStream; const line: String);
|
||||
begin
|
||||
WriteString(stream, line);
|
||||
WriteString(stream, sLineBreak);
|
||||
//WriteString(stream, sLineBreak);
|
||||
end;
|
||||
|
||||
// TFinancialInstitution
|
||||
|
||||
@ -196,10 +196,12 @@ type
|
||||
fGrpHdrMsgId: String; // group header: message identification
|
||||
fGrpHdrCreDtTm: TDateTime; // group header: time of file creation
|
||||
fGrpHdrInitgPtyName: String; // group header: initiator name
|
||||
fGrpHdrInitgPtyId: String; // group header: initiator id
|
||||
fPmtInf: array of TDirectDebitPaymentInformation;
|
||||
|
||||
function GetSchema: String;
|
||||
procedure SetGrpHdrInitgPtyName(const str: String);
|
||||
procedure SetGrpHdrInitgPtyId(const Value: String);
|
||||
|
||||
function GetGrpHdrNbOfTxs: Integer;
|
||||
function GetPmtInfEntry(const i: Integer): TDirectDebitPaymentInformation;
|
||||
@ -215,6 +217,8 @@ type
|
||||
property GrpHdrNbOfTxs: Integer read GetGrpHdrNbOfTxs;
|
||||
property GrpHdrInitgPtyName: String read fGrpHdrInitgPtyName write SetGrpHdrInitgPtyName;
|
||||
|
||||
property GrpHdrInitgPtyId: String read fGrpHdrInitgPtyId write SetGrpHdrInitgPtyId;
|
||||
|
||||
procedure AppendPmtInfEntry(const instruction: TDirectDebitPaymentInformation);
|
||||
property PmtInfEntry[const i: Integer]: TDirectDebitPaymentInformation read GetPmtInfEntry;
|
||||
property PmtInfCount: Integer read GetPmtInfCount;
|
||||
@ -673,6 +677,7 @@ begin
|
||||
|
||||
SEPAWriteLine(stream, '<PmtInfId>'+SEPACleanString(PmtInfId)+'</PmtInfId>');
|
||||
SEPAWriteLine(stream, '<PmtMtd>'+SEPACleanString(PmtMtd)+'</PmtMtd>');
|
||||
SEPAWriteLine(stream, '<BtchBookg>false</BtchBookg>');
|
||||
SEPAWriteLine(stream, '<NbOfTxs>'+IntToStr(NbOfTxs)+'</NbOfTxs>');
|
||||
SEPAWriteLine(stream, '<CtrlSum>'+SEPAFormatAmount(CtrlSum)+'</CtrlSum>');
|
||||
|
||||
@ -732,6 +737,11 @@ begin
|
||||
Result := SCHEMA_PAIN_008_003_02;
|
||||
end;
|
||||
|
||||
procedure TDirectDebitInitiation.SetGrpHdrInitgPtyId(const Value: String);
|
||||
begin
|
||||
fGrpHdrInitgPtyId := SEPACleanString(Value);
|
||||
end;
|
||||
|
||||
procedure TDirectDebitInitiation.SetGrpHdrInitgPtyName(const str: String);
|
||||
begin
|
||||
fGrpHdrInitgPtyName := SEPACleanString(str);
|
||||
@ -825,16 +835,24 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
SEPAWriteLine(stream, '<?xml version="1.0" encoding="UTF-8"?>');
|
||||
SEPAWriteLine(stream, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:'+Schema+'"'+
|
||||
{SEPAWriteLine(stream, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:'+Schema+'"'+
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'+
|
||||
' xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:'+Schema+' '+Schema+'.xsd">');
|
||||
' xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:'+Schema+' '+Schema+'.xsd">');}
|
||||
SEPAWriteLine(stream, '<Document'+
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'+
|
||||
' xmlns="urn:iso:std:iso:20022:tech:xsd:'+Schema+'">');
|
||||
SEPAWriteLine(stream, '<CstmrDrctDbtInitn>');
|
||||
|
||||
SEPAWriteLine(stream, '<GrpHdr>');
|
||||
SEPAWriteLine(stream, '<MsgId>'+SEPACleanString(GrpHdrMsgId)+'</MsgId>');
|
||||
SEPAWriteLine(stream, '<CreDtTm>'+SEPAFormatDateTime(GrpHdrCreDtTm)+'</CreDtTm>');
|
||||
SEPAWriteLine(stream, '<NbOfTxs>'+IntToStr(GrpHdrNbOfTxs)+'</NbOfTxs>');
|
||||
SEPAWriteLine(stream, '<InitgPty><Nm>'+SEPACleanString(GrpHdrInitgPtyName, INITG_PTY_NAME_MAX_LEN)+'</Nm></InitgPty>');
|
||||
SEPAWriteLine(stream, '<InitgPty>');
|
||||
SEPAWriteLine(stream, '<Nm>'+SEPACleanString(GrpHdrInitgPtyName, INITG_PTY_NAME_MAX_LEN)+'</Nm>');
|
||||
SEPAWriteLine(stream, '<Id><PrvtId><Othr><Id>');
|
||||
SEPAWriteLine(stream, fGrpHdrInitgPtyId);
|
||||
SEPAWriteLine(stream, '</Id></Othr></PrvtId></Id>');
|
||||
SEPAWriteLine(stream, '</InitgPty>');
|
||||
SEPAWriteLine(stream, '</GrpHdr>');
|
||||
|
||||
for i := 0 to PmtInfCount-1 do
|
||||
|
||||
Reference in New Issue
Block a user