Bug report NAV 5.0 Italian version

BeliasBelias Member Posts: 2,998
I can't launch (runtime error) vat statement print report (no. 12).
I am quite sure it's caused because of a wrong management of "key/CALCSUM" instruction.
anyone have already experienced it?

I'll give more details about it...
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Comments

  • BeliasBelias Member Posts: 2,998
    here is the code:

    VATStmtLine2.Type::"VAT Entry Totaling":
    BEGIN
    VATEntry.RESET;
    IF VATEntry.SETCURRENTKEY(
    Type,Closed,"VAT Bus. Posting Group","VAT Prod. Posting Group","Posting Date")
    THEN BEGIN
    VATEntry.SETRANGE("VAT Bus. Posting Group",VATStmtLine2."VAT Bus. Posting Group");
    VATEntry.SETRANGE("VAT Prod. Posting Group",VATStmtLine2."VAT Prod. Posting Group");
    END ELSE BEGIN
    VATEntry.SETCURRENTKEY(
    Type,Closed,"VAT Bus. Posting Group","VAT Prod. Posting Group",
    "Tax Jurisdiction Code","Use Tax","Tax Liable","VAT Period","Operation Occured Date");

    VATEntry.SETRANGE("Tax Jurisdiction Code",VATStmtLine2."Tax Jurisdiction Code");
    VATEntry.SETRANGE("Use Tax",VATStmtLine2."Use Tax");
    END;
    VATEntry.SETRANGE(Type,VATStmtLine2."Gen. Posting Type");
    IF (EndDateReq = 0D) AND (StartDate = 0D) THEN
    VATEntry.SETRANGE("Operation Occured Date")
    ELSE
    IF PeriodSelection = PeriodSelection::"Before and Within Period" THEN
    VATEntry.SETRANGE("Operation Occured Date",0D,EndDate)
    ELSE
    VATEntry.SETRANGE("Operation Occured Date",StartDate,EndDate);

    CASE Selection OF
    Selection::Open:
    VATEntry.SETRANGE(Closed,FALSE);
    Selection::Closed:
    BEGIN
    VATEntry.SETRANGE(Closed,TRUE);
    IF VATPeriod <> '' THEN BEGIN
    VATEntry.SETRANGE("VAT Period",VATPeriod);
    VATEntry.SETRANGE("Operation Occured Date");
    END;
    END;
    ELSE
    VATEntry.SETRANGE(Closed);
    END;
    CASE VATStmtLine2."Amount Type" OF
    VATStmtLine2."Amount Type"::Amount:
    BEGIN
    VATEntry.CALCSUMS(Amount,"Additional-Currency Amount");
    Amount := ConditionalAdd(0,VATEntry.Amount,VATEntry."Additional-Currency Amount");
    END;


    look at the bold lines: if setcurrentkey(k1) then...else setcurrentkey(k2)
    unfortunately, k1 actually exist, so, k2 will never be used and the filters applied on "operation occured date" field (which is included only in k2 key) will screw the calcsum instruction (underlined)...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.