Just sent Microsoft a suggestion on Microsoft Connect.

We where trying to import data into the Sales Header table and stopped on an error. The old code is

[code]
Payment Terms Code – OnValidate()
IF ("Payment Terms Code" <> ”) AND ("Document Date" <> 0D) THEN BEGIN
PaymentTerms.GET("Payment Terms Code");
IF (("Document Type" IN ["Document Type"::"Return Order","Document Type"::"Credit Memo"]) AND
NOT PaymentTerms."Calc. Pmt. Disc. on Cr. Memos")
THEN BEGIN
VALIDATE("Due Date","Document Date");
VALIDATE("Pmt. Discount Date",0D);
VALIDATE("Payment Discount %",0);
END ELSE BEGIN
"Due Date" := CALCDATE(PaymentTerms."Due Date Calculation","Document Date");
"Pmt. Discount Date" := CALCDATE(PaymentTerms."Discount Date Calculation","Document Date");
IF NOT UpdateDocumentDate THEN
VALIDATE("Payment Discount %",PaymentTerms."Discount %")
END;
END ELSE BEGIN
VALIDATE("Due Date","Document Date");
IF NOT UpdateDocumentDate THEN BEGIN
VALIDATE("Pmt. Discount Date",0D);
VALIDATE("Payment Discount %",0);
END;
END;
IF xRec."Payment Terms Code" = "Prepmt. Payment Terms Code" THEN BEGIN
IF xRec."Prepayment Due Date" = 0D THEN
"Prepayment Due Date" := CALCDATE(PaymentTerms."Due Date Calculation","Document Date");
VALIDATE("Prepmt. Payment Terms Code","Payment Terms Code");
END;[/code]

and I suggeste a change to the fourth last line

[code]
Payment Terms Code – OnValidate()
IF ("Payment Terms Code" <> ”) AND ("Document Date" <> 0D) THEN BEGIN
PaymentTerms.GET("Payment Terms Code");
IF (("Document Type" IN ["Document Type"::"Return Order","Document Type"::"Credit Memo"]) AND
NOT PaymentTerms."Calc. Pmt. Disc. on Cr. Memos")
THEN BEGIN
VALIDATE("Due Date","Document Date");
VALIDATE("Pmt. Discount Date",0D);
VALIDATE("Payment Discount %",0);
END ELSE BEGIN
"Due Date" := CALCDATE(PaymentTerms."Due Date Calculation","Document Date");
"Pmt. Discount Date" := CALCDATE(PaymentTerms."Discount Date Calculation","Document Date");
IF NOT UpdateDocumentDate THEN
VALIDATE("Payment Discount %",PaymentTerms."Discount %")
END;
END ELSE BEGIN
VALIDATE("Due Date","Document Date");
IF NOT UpdateDocumentDate THEN BEGIN
VALIDATE("Pmt. Discount Date",0D);
VALIDATE("Payment Discount %",0);
END;
END;
IF (xRec."Payment Terms Code" = "Prepmt. Payment Terms Code") AND (xRec."Payment Terms Code" <> ”) THEN BEGIN
IF xRec."Prepayment Due Date" = 0D THEN
"Prepayment Due Date" := CALCDATE(PaymentTerms."Due Date Calculation","Document Date");
VALIDATE("Prepmt. Payment Terms Code","Payment Terms Code");
END;[/code]

Leave a Reply

%d bloggers like this: