OBJECT Codeunit 11 Gen. Jnl.-Check Line
{
  OBJECT-PROPERTIES
  {
    Date=09-09-14;
    Time=12:00:00;
    Version List=NAVW18.00;
  }
  PROPERTIES
  {
    TableNo=81;
    Permissions=TableData 252=rimd;
    OnRun=BEGIN
            GLSetup.GET;
            RunCheck(Rec);
          END;

  }
  CODE
  {
    VAR
      Text000@1000 : TextConst 'ENU=can only be a closing date for G/L entries';
      Text001@1001 : TextConst 'ENU=is not within your range of allowed posting dates';
      Text002@1002 : TextConst 'ENU=%1 or %2 must be G/L Account or Bank Account.';
      Text011@1011 : TextConst 'ENU=The combination of dimensions used in %1 %2, %3, %4 is blocked. %5';
      Text012@1012 : TextConst 'ENU=A dimension used in %1 %2, %3, %4 has caused an error. %5';
      GLSetup@1014 : Record 98;
      SalesDocAlreadyExistsErr@1026 : TextConst '@@@="%1 = Document Type; %2 = Document No.";ENU=Sales %1 %2 already exists.';
      PurchDocAlreadyExistsErr@1025 : TextConst '@@@="%1 = Document Type; %2 = Document No.";ENU=Purchase %1 %2 already exists.';

    PROCEDURE RunCheck@4(VAR GenJnlLine@1000 : Record 81);
    VAR
      PaymentTerms@1004 : Record 3;
      Cust@1005 : Record 18;
      Vendor@1006 : Record 23;
      ICPartner@1007 : Record 413;
      ICGLAcount@1008 : Record 410;
      TableID@1002 : ARRAY [10] OF Integer;
      No@1003 : ARRAY [10] OF Code[20];

    PROCEDURE ErrorIfPositiveAmt@2(GenJnlLine@1000 : Record 81);
    BEGIN
      IF GenJnlLine.Amount > 0 THEN
        GenJnlLine.FIELDERROR(Amount,Text008);
    END;

    PROCEDURE ErrorIfNegativeAmt@3(GenJnlLine@1000 : Record 81);
    BEGIN
      IF GenJnlLine.Amount < 0 THEN
        GenJnlLine.FIELDERROR(Amount,Text007);
    END;

    PROCEDURE SetOverDimErr@5();
    BEGIN
      OverrideDimErr := TRUE;
    END;

    PROCEDURE CheckSalesDocNoIsNotUsed@115(DocType@1000 : Option;DocNo@1001 : Code[20]);
    VAR
      OldCustLedgEntry@1002 : Record 21;
    BEGIN
      OldCustLedgEntry.SETRANGE("Document No.",DocNo);
      OldCustLedgEntry.SETRANGE("Document Type",DocType);
      IF OldCustLedgEntry.FINDFIRST THEN
        ERROR(SalesDocAlreadyExistsErr,OldCustLedgEntry."Document Type",DocNo);
    END;

    PROCEDURE CheckPurchDocNoIsNotUsed@107(DocType@1000 : Option;DocNo@1002 : Code[20]);
    VAR
      OldVendLedgEntry@1001 : Record 25;
    BEGIN
      OldVendLedgEntry.SETRANGE("Document No.",DocNo);
      OldVendLedgEntry.SETRANGE("Document Type",DocType);
      IF OldVendLedgEntry.FINDFIRST THEN
        ERROR(PurchDocAlreadyExistsErr,OldVendLedgEntry."Document Type",DocNo);
    END;

    LOCAL PROCEDURE CheckGenJnlLineDocType@7(GenJnlLine@1001 : Record 81);
  }
}
